Files
myeasycms-v2/apps/web/app/(dashboard)/home/[account]/layout.tsx
giancarlo 2c0c616a2d Rename component files and update code dependencies
Numerous component files have been renamed for better organization and readability. This includes changing 'app' to 'account-layout' in various instances and 'organization' to 'team' to ensure consistency across code. Additionally, dependencies within codes have been updated in line with the renaming. The pull request also includes a minor update to the pnpm-lock file, reflecting the latest version of Next.js.
2024-03-31 01:05:32 +08:00

54 lines
1.3 KiB
TypeScript

import { use } from 'react';
import { parseSidebarStateCookie } from '@kit/shared/cookies/sidebar-state.cookie';
import { parseThemeCookie } from '@kit/shared/cookies/theme.cookie';
import { Page } from '@kit/ui/page';
import { AccountLayoutSidebar } from '~/(dashboard)/home/[account]/_components/account-layout-sidebar';
import { loadTeamWorkspace } from '~/(dashboard)/home/[account]/_lib/load-team-account-workspace';
import { withI18n } from '~/lib/i18n/with-i18n';
interface Params {
account: string;
}
function TeamWorkspaceLayout({
children,
params,
}: React.PropsWithChildren<{
params: Params;
}>) {
const data = use(loadTeamWorkspace(params.account));
const ui = getUIStateCookies();
const sidebarCollapsed = ui.sidebarState === 'collapsed';
const accounts = data.accounts.map(({ name, slug, picture_url }) => ({
label: name,
value: slug,
image: picture_url,
}));
return (
<Page
sidebar={
<AccountLayoutSidebar
collapsed={sidebarCollapsed}
account={params.account}
accounts={accounts}
/>
}
>
{children}
</Page>
);
}
export default withI18n(TeamWorkspaceLayout);
function getUIStateCookies() {
return {
theme: parseThemeCookie(),
sidebarState: parseSidebarStateCookie(),
};
}