Create/detail updates
This commit is contained in:
parent
b0fb643b6a
commit
0997e449bb
26 changed files with 684 additions and 108 deletions
33
apps/bridge-frontend/app/_components/ServiceLayout.tsx
Normal file
33
apps/bridge-frontend/app/_components/ServiceLayout.tsx
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
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 === 1 && segment[0] === "create";
|
||||
const isEdit = length === 2 && segment[1] === "edit";
|
||||
const id = length > 0 && !isCreate ? segment[0] : null;
|
||||
const isDetail = length === 1 && !!id && !isCreate && !isEdit;
|
||||
|
||||
console.log({ isCreate, isEdit, isDetail, id });
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
{isDetail && detail}
|
||||
{isEdit && edit}
|
||||
{isCreate && create}
|
||||
</>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue