mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 22:53:25 +00:00
16 lines
547 B
TypeScript
16 lines
547 B
TypeScript
import { router } from '@inertiajs/react';
|
|
import { ReactNode } from 'react';
|
|
import useSearchParam from '~/hooks/use_search_param';
|
|
import useShortcut from '~/hooks/use_shortcut';
|
|
import { routeWithCollectionId } from '~/lib/navigation';
|
|
|
|
export default function BackToDashboard({ children }: { children: ReactNode }) {
|
|
const collectionId = Number(useSearchParam('collectionId'));
|
|
useShortcut(
|
|
'ESCAPE_KEY',
|
|
() => router.visit(routeWithCollectionId('dashboard', collectionId)),
|
|
{ disableGlobalCheck: true }
|
|
);
|
|
return <>{children}</>;
|
|
}
|