11"use client" ;
2- import { ScheduleContext } from "@/contexts/schedule-provider " ;
2+ import { IEvent , IShift } from "@/lib/types " ;
33import clsx from "clsx" ;
44import { motion , AnimatePresence } from "motion/react" ;
55import {
@@ -12,15 +12,18 @@ import {
1212 useCallback ,
1313 useMemo ,
1414 Children ,
15- useContext ,
1615} from "react" ;
1716import { twMerge } from "tailwind-merge" ;
1817
19- interface IAnimatedOptionsSection {
18+ interface IAnimatedOptionsSection < T = IShift | IEvent > {
2019 children : [ ReactNode , ReactNode ] ;
2120 title ?: string ;
2221 titleEdit ?: string ;
2322 classNameOpenedSection ?: string ;
23+ isEditing : boolean ;
24+ setIsEditing : ( prev : boolean ) => void ;
25+ setEditingItems : ( prev : T [ ] ) => void ;
26+ currentItems : T [ ] ;
2427}
2528
2629const useIsMobile = ( ) => {
@@ -41,26 +44,29 @@ const useIsMobile = () => {
4144 return { isMobile, viewportHeight } ;
4245} ;
4346
44- export default function AnimatedOptionsSection ( {
47+ export default function AnimatedOptionsSection < T = IShift | IEvent > ( {
4548 children,
4649 title = "Options" ,
4750 titleEdit = "Edit Options" ,
4851 classNameOpenedSection,
49- } : IAnimatedOptionsSection ) {
52+ isEditing,
53+ setIsEditing,
54+ setEditingItems,
55+ currentItems,
56+ } : IAnimatedOptionsSection < T > ) {
5057 const [ isOpen , setIsOpen ] = useState ( false ) ;
5158
52- const { isEditing, setIsEditing, setEditingShifts, currentSchedule } =
53- useContext ( ScheduleContext ) ;
54-
5559 const handleClose = useCallback ( ( ) => {
5660 setIsOpen ( false ) ;
5761 setIsEditing ( false ) ;
5862 } , [ setIsEditing ] ) ;
5963
6064 const handleEditClick = useCallback ( ( ) => {
61- if ( isEditing ) setEditingShifts ( [ ...currentSchedule ] ) ;
65+ if ( isEditing ) {
66+ setEditingItems ( [ ...currentItems ] ) ;
67+ }
6268 setIsEditing ( ! isEditing ) ;
63- } , [ isEditing , setIsEditing , setEditingShifts , currentSchedule ] ) ;
69+ } , [ isEditing , setIsEditing , setEditingItems , currentItems ] ) ;
6470
6571 const handleMotionClick = useCallback ( ( ) => {
6672 if ( ! isOpen ) {
0 commit comments