import { useMemo } from 'react'; import { useLingui } from '@lingui/react/macro'; import { Trans } from '@lingui/react/macro'; import { ReadStatus } from '@prisma/client'; import { Link } from 'react-router'; import LogoImage from '@documenso/assets/logo.png'; import { authClient } from '@documenso/auth/client'; import { useSession } from '@documenso/lib/client-only/providers/session'; import { isPersonalLayout } from '@documenso/lib/utils/organisations'; import { trpc } from '@documenso/trpc/react'; import { Sheet, SheetContent } from '@documenso/ui/primitives/sheet'; import { ThemeSwitcher } from '@documenso/ui/primitives/theme-switcher'; import { useOptionalCurrentTeam } from '~/providers/team'; export type AppNavMobileProps = { isMenuOpen: boolean; onMenuOpenChange?: (_value: boolean) => void; }; export const AppNavMobile = ({ isMenuOpen, onMenuOpenChange }: AppNavMobileProps) => { const { t } = useLingui(); const { organisations } = useSession(); const currentTeam = useOptionalCurrentTeam(); const { data: unreadCountData } = trpc.document.inbox.getCount.useQuery( { readStatus: ReadStatus.NOT_OPENED, }, { // refetchInterval: 30000, // Refetch every 30 seconds }, ); const handleMenuItemClick = () => { onMenuOpenChange?.(false); }; const menuNavigationLinks = useMemo(() => { let teamUrl = currentTeam?.url || null; if (!teamUrl && isPersonalLayout(organisations)) { teamUrl = organisations[0].teams[0]?.url || null; } if (!teamUrl) { return [ { href: '/inbox', text: t`Inbox`, }, { href: '/settings/profile', text: t`Settings`, }, ]; } return [ { href: `/t/${teamUrl}/documents`, text: t`Documents`, }, { href: `/t/${teamUrl}/templates`, text: t`Templates`, }, { href: '/inbox', text: t`Inbox`, }, { href: '/settings/profile', text: t`Settings`, }, ]; }, [currentTeam, organisations]); return ( Documenso Logo
{menuNavigationLinks.map(({ href, text }) => ( handleMenuItemClick()} > {text} {href === '/inbox' && unreadCountData && unreadCountData.count > 0 && ( {unreadCountData.count > 99 ? '99+' : unreadCountData.count} )} ))}

© {new Date().getFullYear()} Documenso, Inc.
All rights reserved.

); };