@@ -17,17 +17,11 @@ export default function Collections() {
1717 const [ collectionToDelete , setCollectionToDelete ] = useState < Collection | null > ( null ) ;
1818 const [ showCreateDialog , setShowCreateDialog ] = useState ( false ) ;
1919 const [ showEditDialog , setShowEditDialog ] = useState ( false ) ;
20+ const [ collectionToEdit , setCollectionToEdit ] = useState < Collection | null > ( null ) ;
2021 const [ , navigate ] = useLocation ( ) ;
2122
2223 const {
23- deleteCollection,
24- openEditModal,
25- collectionToEdit,
26- isCreateModalOpen,
27- openCreateModal,
28- closeCreateModal,
29- isEditModalOpen,
30- closeEditModal,
24+ deleteCollection,
3125 setActiveCollectionId
3226 } = useCollectionContext ( ) ;
3327
@@ -42,15 +36,30 @@ export default function Collections() {
4236
4337 // Handle open create collection modal
4438 const handleOpenCreateModal = ( ) => {
39+ console . log ( '🚀 Opening create collection dialog' ) ;
4540 setShowCreateDialog ( true ) ;
4641 } ;
4742
43+ // Handle close create collection modal
44+ const handleCloseCreateModal = ( ) => {
45+ console . log ( '🚀 Closing create collection dialog' ) ;
46+ setShowCreateDialog ( false ) ;
47+ } ;
48+
4849 // Handle edit collection
4950 const handleEditCollection = ( collection : Collection ) => {
50- openEditModal ( collection ) ;
51+ console . log ( '🚀 Opening edit collection dialog for:' , collection . name ) ;
52+ setCollectionToEdit ( collection ) ;
5153 setShowEditDialog ( true ) ;
5254 } ;
5355
56+ // Handle close edit collection modal
57+ const handleCloseEditModal = ( ) => {
58+ console . log ( '🚀 Closing edit collection dialog' ) ;
59+ setShowEditDialog ( false ) ;
60+ setCollectionToEdit ( null ) ;
61+ } ;
62+
5463 // Handle delete collection
5564 const handleDeleteCollection = ( collection : Collection ) => {
5665 setCollectionToDelete ( collection ) ;
@@ -231,19 +240,19 @@ export default function Collections() {
231240 </ AlertDialogContent >
232241 </ AlertDialog >
233242
234- { /* Create Collection Dialog */ }
243+ { /* Create Collection Dialog - FIXED: Use local state instead of context */ }
235244 < CollectionDialog
236245 open = { showCreateDialog }
237- onOpenChange = { setShowCreateDialog }
246+ onOpenChange = { handleCloseCreateModal }
238247 />
239248
240- { /* Edit Collection Dialog */ }
249+ { /* Edit Collection Dialog - FIXED: Use local state instead of context */ }
241250 < CollectionDialog
242251 open = { showEditDialog }
243- onOpenChange = { setShowEditDialog }
252+ onOpenChange = { handleCloseEditModal }
244253 collectionToEdit = { collectionToEdit }
245254 isEditMode = { true }
246255 />
247256 </ Layout >
248257 ) ;
249- }
258+ }
0 commit comments