chore: clean up some code in app router (#18541)
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
This commit is contained in:
co-authored by
Anik Dhabal Babu
parent
2fd8d24204
commit
ccf1d4430a
@@ -23,8 +23,8 @@ const querySchema = z.object({
|
||||
|
||||
const getSchedule = cache((id: number) => ScheduleRepository.findScheduleById({ id }));
|
||||
|
||||
export const generateMetadata = async ({ params, searchParams }: PageProps) => {
|
||||
const parsed = querySchema.safeParse({ ...params, ...searchParams });
|
||||
export const generateMetadata = async ({ params }: PageProps) => {
|
||||
const parsed = querySchema.safeParse(params);
|
||||
if (!parsed.success) {
|
||||
notFound();
|
||||
}
|
||||
@@ -41,8 +41,8 @@ export const generateMetadata = async ({ params, searchParams }: PageProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
const Page = async ({ params, searchParams }: PageProps) => {
|
||||
const parsed = querySchema.safeParse({ ...params, ...searchParams });
|
||||
const Page = async ({ params }: PageProps) => {
|
||||
const parsed = querySchema.safeParse(params);
|
||||
if (!parsed.success) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ export const generateStaticParams = async () => {
|
||||
return validStatuses.map((status) => ({ status }));
|
||||
};
|
||||
|
||||
const Page = ({ params, searchParams }: PageProps) => {
|
||||
const parsed = querySchema.safeParse({ ...params, ...searchParams });
|
||||
const Page = ({ params }: PageProps) => {
|
||||
const parsed = querySchema.safeParse(params);
|
||||
if (!parsed.success) {
|
||||
redirect("/bookings/upcoming");
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ import { withAppDirSsr } from "app/WithAppDirSsr";
|
||||
import type { PageProps as _PageProps } from "app/_types";
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
import { WithLayout } from "app/layoutHOC";
|
||||
import { notFound } from "next/navigation";
|
||||
import { z } from "zod";
|
||||
|
||||
import { BookingRepository } from "@calcom/lib/server/repository/booking";
|
||||
|
||||
@@ -10,10 +12,17 @@ import { getServerSideProps } from "@lib/video/meeting-not-started/[uid]/getServ
|
||||
import type { PageProps } from "~/videos/views/videos-meeting-not-started-single-view";
|
||||
import MeetingNotStarted from "~/videos/views/videos-meeting-not-started-single-view";
|
||||
|
||||
export const generateMetadata = async ({ params, searchParams }: _PageProps) => {
|
||||
const p = { ...params, ...searchParams };
|
||||
const querySchema = z.object({
|
||||
uid: z.string(),
|
||||
});
|
||||
|
||||
export const generateMetadata = async ({ params }: _PageProps) => {
|
||||
const parsed = querySchema.safeParse(params);
|
||||
if (!parsed.success) {
|
||||
notFound();
|
||||
}
|
||||
const booking = await BookingRepository.findBookingByUid({
|
||||
bookingUid: typeof p?.uid === "string" ? p.uid : "",
|
||||
bookingUid: parsed.data.uid,
|
||||
});
|
||||
|
||||
return await _generateMetadata(
|
||||
|
||||
@@ -21,8 +21,8 @@ const querySchema = z.object({
|
||||
|
||||
const getWorkflow = cache((id: number) => WorkflowRepository.getById({ id }));
|
||||
|
||||
export const generateMetadata = async ({ params, searchParams }: PageProps): Promise<Metadata | null> => {
|
||||
const parsed = querySchema.safeParse({ ...params, ...searchParams });
|
||||
export const generateMetadata = async ({ params }: PageProps): Promise<Metadata | null> => {
|
||||
const parsed = querySchema.safeParse(params);
|
||||
if (!parsed.success) {
|
||||
notFound();
|
||||
}
|
||||
@@ -38,11 +38,11 @@ export const generateMetadata = async ({ params, searchParams }: PageProps): Pro
|
||||
|
||||
export const generateStaticParams = () => [];
|
||||
|
||||
const Page = async ({ params, searchParams }: PageProps) => {
|
||||
const Page = async ({ params }: PageProps) => {
|
||||
// FIXME: Refactor me once next-auth endpoint is migrated to App Router
|
||||
// const session = await getServerSessionForAppDir();
|
||||
// const user = session?.user;
|
||||
const parsed = querySchema.safeParse({ ...params, ...searchParams });
|
||||
const parsed = querySchema.safeParse(params);
|
||||
if (!parsed.success) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user