Generalize WIP
This commit is contained in:
parent
a3e8b89128
commit
cb7a3a08dc
31 changed files with 657 additions and 106 deletions
32
apps/bridge-frontend/app/(main)/[...segment]/layout.tsx
Normal file
32
apps/bridge-frontend/app/(main)/[...segment]/layout.tsx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
type ServiceLayoutProps = {
|
||||
children: any;
|
||||
detail: any;
|
||||
edit: any;
|
||||
create: any;
|
||||
params: {
|
||||
segment: string[];
|
||||
};
|
||||
};
|
||||
|
||||
export const ServiceLayout = ({
|
||||
children,
|
||||
detail,
|
||||
edit,
|
||||
create,
|
||||
params: { segment },
|
||||
}: ServiceLayoutProps) => {
|
||||
const length = segment?.length ?? 0;
|
||||
const isCreate = length === 2 && segment[1] === "create";
|
||||
const isEdit = length === 3 && segment[2] === "edit";
|
||||
const id = length > 1 && !isCreate ? segment[1] : null;
|
||||
const isDetail = length === 2 && !!id && !isCreate && !isEdit;
|
||||
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
{isDetail && detail}
|
||||
{isEdit && edit}
|
||||
{isCreate && create}
|
||||
</>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue