The key changes made in this code include the addition of a Super Admin layout. Also, subscription functionalities are updated and optimized. This ensures read, write permissions are specific to the relevant user and a helper function has been implemented to check if an account has an active subscription. Furthermore, UI enhancements have been made to the accounts table in the administration section. The seed data has also been modified.
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { redirect } from 'next/navigation';
|
|
|
|
import { Home, Users } from 'lucide-react';
|
|
|
|
import { requireUser } from '@kit/supabase/require-user';
|
|
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
|
import {
|
|
Sidebar,
|
|
SidebarContent,
|
|
SidebarGroup,
|
|
SidebarItem,
|
|
} from '@kit/ui/sidebar';
|
|
|
|
import { AppLogo } from '~/components/app-logo';
|
|
import { ProfileAccountDropdownContainer } from '~/components/personal-account-dropdown-container';
|
|
|
|
export async function AdminSidebar() {
|
|
const client = getSupabaseServerActionClient();
|
|
const user = await requireUser(client);
|
|
|
|
if (user.error) {
|
|
redirect(user.redirectTo);
|
|
}
|
|
|
|
return (
|
|
<Sidebar>
|
|
<SidebarContent className={'py-4'}>
|
|
<AppLogo href={'/admin'} />
|
|
</SidebarContent>
|
|
|
|
<SidebarContent className={'mt-5'}>
|
|
<SidebarGroup label={'Admin'} collapsible={false}>
|
|
<SidebarItem end path={'/admin'} Icon={<Home className={'h-4'} />}>
|
|
Home
|
|
</SidebarItem>
|
|
|
|
<SidebarItem
|
|
path={'/admin/accounts'}
|
|
Icon={<Users className={'h-4'} />}
|
|
>
|
|
Accounts
|
|
</SidebarItem>
|
|
</SidebarGroup>
|
|
</SidebarContent>
|
|
|
|
<SidebarContent className={'absolute bottom-4'}>
|
|
<ProfileAccountDropdownContainer user={user.data} collapsed={false} />
|
|
</SidebarContent>
|
|
</Sidebar>
|
|
);
|
|
}
|