refactor: remove react-hotkeys-hook and use inertia propos instead of recreating a local store

This commit is contained in:
Sonny
2025-08-19 23:47:52 +02:00
parent 1d1e182523
commit 42f391d99a
16 changed files with 122 additions and 182 deletions

View File

@@ -0,0 +1,25 @@
import { PageProps } from '@adonisjs/inertia/types';
import { usePage } from '@inertiajs/react';
import { CollectionWithLinks } from '~/types/app';
interface UseActiveCollectionProps {
activeCollection?: CollectionWithLinks;
}
export const useActiveCollection = () => {
const { props } = usePage<PageProps & UseActiveCollectionProps>();
return props.activeCollection;
};
export type WithActiveCollectionProps = {
activeCollection?: CollectionWithLinks;
};
export const withActiveCollection = (
Component: React.ComponentType<WithActiveCollectionProps>
) => {
return (props: WithActiveCollectionProps) => {
const activeCollection = useActiveCollection();
return <Component {...props} activeCollection={activeCollection} />;
};
};