import type { HTMLAttributes } from 'react'; import { useEffect, useState } from 'react'; import { msg } from '@lingui/core/macro'; import { useLingui } from '@lingui/react'; import { Trans } from '@lingui/react/macro'; import { Search } from 'lucide-react'; import { Link, useLocation, useParams } from 'react-router'; import { getRootHref } from '@documenso/lib/utils/params'; import { cn } from '@documenso/ui/lib/utils'; import { Button } from '@documenso/ui/primitives/button'; const navigationLinks = [ { href: '/documents', label: msg`Documents`, }, { href: '/templates', label: msg`Templates`, }, ]; export type AppNavDesktopProps = HTMLAttributes & { setIsCommandMenuOpen: (value: boolean) => void; }; export const AppNavDesktop = ({ className, setIsCommandMenuOpen, ...props }: AppNavDesktopProps) => { const { _ } = useLingui(); const { pathname } = useLocation(); const params = useParams(); const [modifierKey, setModifierKey] = useState(() => 'Ctrl'); const rootHref = getRootHref(params, { returnEmptyRootString: true }); useEffect(() => { const userAgent = typeof navigator !== 'undefined' ? navigator.userAgent : 'unknown'; const isMacOS = /Macintosh|Mac\s+OS\s+X/i.test(userAgent); setModifierKey(isMacOS ? '⌘' : 'Ctrl'); }, []); return ( {navigationLinks.map(({ href, label }) => ( {_(label)} ))} setIsCommandMenuOpen(true)} > Search {modifierKey}+K ); };