Files
myeasycms-v2/apps/web/app/admin/accounts/[id]/page.tsx
giancarlo a75009c0df Update route check and add PageBody wrapper
Updated the `isRouteActive` check in the sidebar component to ensure it doesn't falsely identify nested routes as active. Additionally, introduced a `PageBody` wrapper in the account page component for consistent styling and padding.
2024-05-13 19:51:33 +07:00

51 lines
1.1 KiB
TypeScript

import { cache } from 'react';
import { AdminAccountPage } from '@kit/admin/components/admin-account-page';
import { AdminGuard } from '@kit/admin/components/admin-guard';
import { getSupabaseServerComponentClient } from '@kit/supabase/server-component-client';
import { PageBody } from '@kit/ui/page';
interface Params {
params: {
id: string;
};
}
export const generateMetadata = async ({ params }: Params) => {
const account = await loadAccount(params.id);
return {
title: `Admin | ${account.name}`,
};
};
async function AccountPage({ params }: Params) {
const account = await loadAccount(params.id);
return (
<PageBody className={'py-4'}>
<AdminAccountPage account={account} />
</PageBody>
);
}
export default AdminGuard(AccountPage);
const loadAccount = cache(async (id: string) => {
const client = getSupabaseServerComponentClient({
admin: true,
});
const { data, error } = await client
.from('accounts')
.select('*, memberships: accounts_memberships (*)')
.eq('id', id)
.single();
if (error) {
throw error;
}
return data;
});