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

const ControlRenderBX = () => {
	const [wsphonedata, setWsphonedata] = useState({});
	useEffect(() => {
		setWsphonedata(window.alovoice_wsphone);
		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',
					},
				],
			});
		}
	}, []);
	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;