Files
myeasycms-v2/apps/web/app/(dashboard)/home/[account]/layout.tsx
giancarlo 95793c42b4 Remove admin functionality related code
The admin functionality related code has been removed which includes various user and organization functionalities like delete, update, ban etc. This includes action logic, UI components and supportive utility functions. Notable deletions include the server action files, dialog components for actions like banning and deleting, and related utility functions. This massive cleanup is aimed at simplifying the codebase and the commit reflects adherence to project restructuring.
2024-03-25 15:40:43 +08:00

74 lines
1.7 KiB
TypeScript

import { use } from 'react';
import { parseSidebarStateCookie } from '@kit/shared/cookies/sidebar-state.cookie';
import { parseThemeCookie } from '@kit/shared/cookies/theme.cookie';
import { getSupabaseServerComponentClient } from '@kit/supabase/server-component-client';
import { Page } from '@kit/ui/page';
import { AppSidebar } from '~/(dashboard)/home/[account]/_components/app-sidebar';
import { loadOrganizationWorkspace } from '~/(dashboard)/home/[account]/_lib/load-workspace';
import { withI18n } from '~/lib/i18n/with-i18n';
interface Params {
account: string;
}
function OrganizationWorkspaceLayout({
children,
params,
}: React.PropsWithChildren<{
params: Params;
}>) {
const [data, session] = use(
Promise.all([loadOrganizationWorkspace(params.account), loadSession()]),
);
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={
<AppSidebar
collapsed={sidebarCollapsed}
account={params.account}
session={session}
accounts={accounts}
/>
}
>
{children}
</Page>
);
}
export default withI18n(OrganizationWorkspaceLayout);
function getUIStateCookies() {
return {
theme: parseThemeCookie(),
sidebarState: parseSidebarStateCookie(),
};
}
async function loadSession() {
const client = getSupabaseServerComponentClient();
const {
data: { session },
error,
} = await client.auth.getSession();
if (error) {
throw error;
}
return session;
}