This update includes creating new files for the notifications feature along with adding two feature flags for enabling notifications and realtime notifications. All the code and package dependencies required for the notifications functionality have been added. The 'pnpm-lock.yaml' has also been updated due to the inclusion of new package dependencies.
108 lines
2.3 KiB
TypeScript
108 lines
2.3 KiB
TypeScript
'use client';
|
|
|
|
import Link from 'next/link';
|
|
|
|
import { LogOut, Menu } from 'lucide-react';
|
|
|
|
import { useSignOut } from '@kit/supabase/hooks/use-sign-out';
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from '@kit/ui/dropdown-menu';
|
|
import { Trans } from '@kit/ui/trans';
|
|
|
|
import { personalAccountSidebarConfig } from '~/config/personal-account-sidebar.config';
|
|
|
|
export function UserLayoutMobileNavigation() {
|
|
const signOut = useSignOut();
|
|
|
|
const Links = personalAccountSidebarConfig.routes.map((item, index) => {
|
|
if ('children' in item) {
|
|
return item.children.map((child) => {
|
|
return (
|
|
<DropdownLink
|
|
key={child.path}
|
|
Icon={child.Icon}
|
|
path={child.path}
|
|
label={child.label}
|
|
/>
|
|
);
|
|
});
|
|
}
|
|
|
|
if ('divider' in item) {
|
|
return <DropdownMenuSeparator key={index} />;
|
|
}
|
|
|
|
return (
|
|
<DropdownLink
|
|
key={item.path}
|
|
Icon={item.Icon}
|
|
path={item.path}
|
|
label={item.label}
|
|
/>
|
|
);
|
|
});
|
|
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger>
|
|
<Menu className={'h-9'} />
|
|
</DropdownMenuTrigger>
|
|
|
|
<DropdownMenuContent sideOffset={10} className={'w-screen rounded-none'}>
|
|
{Links}
|
|
|
|
<DropdownMenuSeparator />
|
|
|
|
<SignOutDropdownItem onSignOut={() => signOut.mutateAsync()} />
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
}
|
|
|
|
function DropdownLink(
|
|
props: React.PropsWithChildren<{
|
|
path: string;
|
|
label: string;
|
|
Icon: React.ReactNode;
|
|
}>,
|
|
) {
|
|
return (
|
|
<DropdownMenuItem asChild key={props.path}>
|
|
<Link
|
|
href={props.path}
|
|
className={'flex h-12 w-full items-center space-x-4'}
|
|
>
|
|
{props.Icon}
|
|
|
|
<span>
|
|
<Trans i18nKey={props.label} defaults={props.label} />
|
|
</span>
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
);
|
|
}
|
|
|
|
function SignOutDropdownItem(
|
|
props: React.PropsWithChildren<{
|
|
onSignOut: () => unknown;
|
|
}>,
|
|
) {
|
|
return (
|
|
<DropdownMenuItem
|
|
className={'flex h-12 w-full items-center space-x-4'}
|
|
onClick={props.onSignOut}
|
|
>
|
|
<LogOut className={'h-6'} />
|
|
|
|
<span>
|
|
<Trans i18nKey={'common:signOut'} defaults={'Sign out'} />
|
|
</span>
|
|
</DropdownMenuItem>
|
|
);
|
|
}
|