| "use client"; | |
| import React, { createContext, useContext } from 'react'; | |
| import { useContactsCore } from '@/hooks/use-contacts'; | |
| type ContactsContextType = ReturnType<typeof useContactsCore>; | |
| const ContactsContext = createContext<ContactsContextType | null>(null); | |
| export const useContacts = () => { | |
| const context = useContext(ContactsContext); | |
| if (!context) { | |
| throw new Error('useContacts must be used within a ContactsProvider'); | |
| } | |
| return context; | |
| }; | |
| export const ContactsProvider = ({ children }: { children: React.ReactNode }) => { | |
| const contactsData = useContactsCore(); | |
| return ( | |
| <ContactsContext.Provider value={contactsData}> | |
| {children} | |
| </ContactsContext.Provider> | |
| ); | |
| }; | |