feat: add dropdown component

This commit is contained in:
Sonny
2024-05-12 20:06:05 +02:00
committed by Sonny
parent 3531038321
commit 0f1dc9b69c
13 changed files with 142 additions and 16 deletions

View File

@@ -4,13 +4,16 @@ import { router } from '@inertiajs/react';
import { ReactNode } from 'react';
import { useHotkeys } from 'react-hotkeys-hook';
import useGlobalHotkeys from '~/hooks/use_global_hotkeys';
import useSearchParam from '~/hooks/use_search_param';
import { appendCollectionId } from '~/lib/navigation';
export default function BackToDashboard({ children }: { children: ReactNode }) {
const collectionId = useSearchParam('collectionId');
const { globalHotkeysEnabled } = useGlobalHotkeys();
useHotkeys(
KEYS.ESCAPE_KEY,
() => {
router.visit(PATHS.DASHBOARD);
router.visit(appendCollectionId(PATHS.DASHBOARD, collectionId));
},
{ enabled: globalHotkeysEnabled, enableOnFormTags: ['INPUT'] }
);