import React, { createContext, useState } from "react";

export const ChatContext = createContext();

export const ChatProvider = ({ children }) => {
    const [contacts, setContacts] = useState([]);
    const [currentChat, setCurrentChat] = useState({});
    const [lastMessages, setLastMessages] = useState([]);
    const [search,setSearch] = useState("");

    return (
        <ChatContext.Provider value={{
            contacts, setContacts,
            currentChat, setCurrentChat,
            lastMessages, setLastMessages,
            search,setSearch,
        }}>
            {children}
        </ChatContext.Provider>
    );
}