remove unnecessary context using

This commit is contained in:
vchikalkin 2025-02-17 17:27:09 +03:00
parent d4145a3c86
commit 05c6d72801

View File

@ -1,10 +1,8 @@
/* eslint-disable canonical/id-match */ /* eslint-disable canonical/id-match */
'use client'; 'use client';
import { ScheduleTimeContextProvider } from '../context';
import { type SlotComponentProps } from '../types'; import { type SlotComponentProps } from '../types';
import { ReadonlyTimeRange } from './time-range'; import { ReadonlyTimeRange } from './time-range';
import { useSlotQuery } from '@/hooks/slots'; import { useSlotQuery } from '@/hooks/slots';
import { withContext } from '@/utils/context';
import { Enum_Slot_State } from '@repo/graphql/types'; import { Enum_Slot_State } from '@repo/graphql/types';
import { Badge } from '@repo/ui/components/ui/badge'; import { Badge } from '@repo/ui/components/ui/badge';
import { cn } from '@repo/ui/lib/utils'; import { cn } from '@repo/ui/lib/utils';
@ -16,15 +14,7 @@ const MAP_BADGE_TEXT: Record<Enum_Slot_State, string> = {
reserved: 'Зарезервировано', reserved: 'Зарезервировано',
}; };
function getBadgeText(state: Enum_Slot_State) { export function SlotCard(props: Readonly<SlotComponentProps>) {
if (!state) return '';
return MAP_BADGE_TEXT[state];
}
export const SlotCard = withContext(ScheduleTimeContextProvider)(function (
props: Readonly<SlotComponentProps>,
) {
const { documentId } = props; const { documentId } = props;
const { data } = useSlotQuery({ documentId }); const { data } = useSlotQuery({ documentId });
@ -65,4 +55,10 @@ export const SlotCard = withContext(ScheduleTimeContextProvider)(function (
</div> </div>
</Link> </Link>
); );
}); }
function getBadgeText(state: Enum_Slot_State) {
if (!state) return '';
return MAP_BADGE_TEXT[state];
}