import CallWidgetDialog from "@/components/layouts/Dashboard/CallWidget/CallWidgetDialog";
import {AnswersProvider} from "@/lib/callWidget/contexts/answers";
import useSocket from "@/lib/app/hooks/useSocket";
import {useEffect} from "react";

const CallWidget = () => {
    const socket = useSocket()

    useEffect(() => {
        if (socket.connected) return

        socket.connect()

        return () => {
            socket.disconnect()
        }
    }, []);

    return (
        <AnswersProvider>
            <CallWidgetDialog/>
        </AnswersProvider>
    )
}

export default CallWidget