* Update Next.js and React versions in all packages * Replace onRedirect function with next/link in BillingSessionStatus, since it's no longer cached by default * Remove unused revalidatePath import in billing return page, since it's no longer cached by default * Add Turbopack module aliases to improve development server speed * Converted new Dynamic APIs to be Promise-based * Adjust mobile layout * Use ENABLE_REACT_COMPILER to enable the React Compiler in Next.js 15 * Report Errors using the new onRequestError hook
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import { cache } from 'react';
|
|
|
|
import { AdminAccountPage } from '@kit/admin/components/admin-account-page';
|
|
import { AdminGuard } from '@kit/admin/components/admin-guard';
|
|
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
|
|
import { PageBody } from '@kit/ui/page';
|
|
|
|
interface Params {
|
|
params: Promise<{
|
|
id: string;
|
|
}>;
|
|
}
|
|
|
|
export const generateMetadata = async (props: Params) => {
|
|
const params = await props.params;
|
|
const account = await loadAccount(params.id);
|
|
|
|
return {
|
|
title: `Admin | ${account.name}`,
|
|
};
|
|
};
|
|
|
|
async function AccountPage(props: Params) {
|
|
const params = await props.params;
|
|
const account = await loadAccount(params.id);
|
|
|
|
return (
|
|
<PageBody className={'py-4'}>
|
|
<AdminAccountPage account={account} />
|
|
</PageBody>
|
|
);
|
|
}
|
|
|
|
export default AdminGuard(AccountPage);
|
|
|
|
const loadAccount = cache(accountLoader);
|
|
|
|
async function accountLoader(id: string) {
|
|
const client = getSupabaseServerAdminClient();
|
|
|
|
const { data, error } = await client
|
|
.from('accounts')
|
|
.select('*, memberships: accounts_memberships (*)')
|
|
.eq('id', id)
|
|
.single();
|
|
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
|
|
return data;
|
|
}
|