refactor: migrate from @izzyjs/route to @tuyau

This commit is contained in:
Sonny
2024-10-28 01:05:45 +01:00
parent 05c867f44f
commit c308262ee0
44 changed files with 294 additions and 235 deletions

View File

@@ -1,16 +1,14 @@
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';
import { routeWithCollectionId } from '~/lib/navigation';
export default function BackToDashboard({ children }: { children: ReactNode }) {
const collectionId = Number(useSearchParam('collectionId'));
useShortcut(
'ESCAPE_KEY',
() =>
router.visit(appendCollectionId(route('dashboard').url, collectionId)),
() => router.visit(routeWithCollectionId('dashboard', collectionId)),
{ disableGlobalCheck: true }
);
return <>{children}</>;