mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 23:15:36 +00:00
15 lines
561 B
TypeScript
15 lines
561 B
TypeScript
import { router } from '@inertiajs/react';
|
|
import { route } from '@izzyjs/route/client';
|
|
import { ReactNode } from 'react';
|
|
import useSearchParam from '~/hooks/use_search_param';
|
|
import useShortcut from '~/hooks/use_shortcut';
|
|
import { appendCollectionId } from '~/lib/navigation';
|
|
|
|
export default function BackToDashboard({ children }: { children: ReactNode }) {
|
|
const collectionId = useSearchParam('collectionId');
|
|
useShortcut('ESCAPE_KEY', () =>
|
|
router.visit(appendCollectionId(route('dashboard').url, collectionId))
|
|
);
|
|
return <>{children}</>;
|
|
}
|