/** @format */
import React, { useEffect, useState } from 'react';
import Root from '../root';
import {useColorConfig} from "../storage/globalColorConfig"

const ControlRenderBX = () => {
	const useColorConfigStore = useColorConfig((store)=> store)
	const [wsphonedata, setWsphonedata] = useState({});
	useEffect(() => {
		setWsphonedata(window.alovoice_wsphone);
		useColorConfigStore.getColors()
		if (!window.alovoice_wsphone) {
			setWsphonedata({
				iscloud: true,
				number: '2020',
				wsurl: 'cld.alovoice.uz:61040',
				server_id: 40,
				secret: '97bff7',
				lefttime: 231461,
				reasons: ['free', 'outcalls', 'home', 'totop'],
				reason: 'free',
				variant: 'bxmini',
				position: 'bottomRight',
				extnums: [
					{
						title: 'text-1',
						number: '994412860',
					},
					{
						title: 'test-2',
						number: '770412860',
					},
				],
			});
		}
		// getHistoryColor
	}, []);
	console.log('window_alovoice_wsphone: ', window.alovoice_wsphone);
	return (
		<div>
			{wsphonedata?.number && (
				<Root
					setWsphonedata={setWsphonedata}
					onSetDnd={window.alovoice_onsetdnd}
					wsphonedata={wsphonedata}
				/>
			)}
		</div>
	);
};

export default ControlRenderBX;
