'use client'; import * as React from 'react'; // import type { LessonCategory } from '@/types/lesson-type'; import { useSelection } from '@/hooks/use-selection'; import type { Selection } from '@/hooks/use-selection'; import { LpQuestion } from './type'; function noop(): void { return undefined; } export interface LpCategoriesSelectionContextValue extends Selection {} export const LpCategoriesSelectionContext = React.createContext({ deselectAll: noop, deselectOne: noop, selectAll: noop, selectOne: noop, selected: new Set(), selectedAny: false, selectedAll: false, }); interface LpCategoriesSelectionProviderProps { children: React.ReactNode; lessonQuestions: LpQuestion[]; } export function LpQuestionsSelectionProvider({ children, lessonQuestions: lessonCategories = [], }: LpCategoriesSelectionProviderProps): React.JSX.Element { const customerIds = React.useMemo(() => lessonCategories.map((customer) => customer.id), [lessonCategories]); const selection = useSelection(customerIds); return ( {children} ); } export function useLpCategoriesSelection(): LpCategoriesSelectionContextValue { return React.useContext(LpCategoriesSelectionContext); }