type ServiceLayoutProps = { children: any; detail: any; edit: any; create: any; params: Promise<{ segment: string[]; }>; }; export const ServiceLayout = async ({ children, detail, edit, create, params, }: ServiceLayoutProps) => { const { segment } = await params; const length = segment?.length ?? 0; const isCreate = length === 2 && segment[1] === "create"; const isEdit = length === 3 && segment[2] === "edit"; const id = length > 0 && !isCreate ? segment[1] : null; const isDetail = length === 2 && !!id && !isCreate && !isEdit; return ( <> {children} {isDetail && detail} {isEdit && edit} {isCreate && create} ); };