Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dguyen committed Apr 16, 2024
1 parent aaccf12 commit 4263408
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
27 changes: 3 additions & 24 deletions apps/web/src/components/(dashboard)/layout/desktop-nav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import type { HTMLAttributes } from 'react';
import { useEffect, useState } from 'react';

Expand All @@ -12,8 +10,6 @@ import { getRootHref } from '@documenso/lib/utils/params';
import { cn } from '@documenso/ui/lib/utils';
import { Button } from '@documenso/ui/primitives/button';

import { CommandMenu } from '../common/command-menu';

const navigationLinks = [
{
href: '/documents',
Expand All @@ -26,20 +22,13 @@ const navigationLinks = [
];

export type DesktopNavProps = HTMLAttributes<HTMLDivElement> & {
isCommandMenuOpen?: boolean;
setIsCommandMenuOpen?: (value: boolean) => void;
setIsCommandMenuOpen: (value: boolean) => void;
};

export const DesktopNav = ({
className,
isCommandMenuOpen = false,
setIsCommandMenuOpen,
...props
}: DesktopNavProps) => {
export const DesktopNav = ({ className, setIsCommandMenuOpen, ...props }: DesktopNavProps) => {
const pathname = usePathname();
const params = useParams();

const [open, setOpen] = useState(isCommandMenuOpen);
const [modifierKey, setModifierKey] = useState(() => 'Ctrl');

const rootHref = getRootHref(params, { returnEmptyRootString: true });
Expand All @@ -51,14 +40,6 @@ export const DesktopNav = ({
setModifierKey(isMacOS ? '⌘' : 'Ctrl');
}, []);

const toggleCommandMenu = (_newState: boolean) => {
if (typeof setIsCommandMenuOpen === 'function') {
setIsCommandMenuOpen(_newState);
} else {
setOpen(_newState);
}
};

return (
<div
className={cn(
Expand Down Expand Up @@ -86,12 +67,10 @@ export const DesktopNav = ({
))}
</div>

<CommandMenu open={open} onOpenChange={toggleCommandMenu} />

<Button
variant="outline"
className="text-muted-foreground flex w-96 items-center justify-between rounded-lg"
onClick={() => toggleCommandMenu(true)}
onClick={() => setIsCommandMenuOpen(true)}
>
<div className="flex items-center">
<Search className="mr-2 h-5 w-5" />
Expand Down
5 changes: 1 addition & 4 deletions apps/web/src/components/(dashboard)/layout/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ export const Header = ({ className, user, teams, ...props }: HeaderProps) => {
<Logo className="h-6 w-auto" />
</Link>

<DesktopNav
isCommandMenuOpen={isCommandMenuOpen}
setIsCommandMenuOpen={setIsCommandMenuOpen}
/>
<DesktopNav setIsCommandMenuOpen={setIsCommandMenuOpen} />

<div className="flex gap-x-4 md:ml-8">
<MenuSwitcher user={user} teams={teams} />
Expand Down

0 comments on commit 4263408

Please sign in to comment.