Commit 0f75677e authored by Muhammadali's avatar Muhammadali

update

parent 1af429c7
{
"name": "boxdialer",
"version": "2.0.3",
"version": "2.0.4",
"description": "",
"main": "src/boxDialer.js",
"scripts": {
......
......@@ -17,6 +17,6 @@ root.render(
<Toaster />
{/* {controlRenderBX({ rootComponent: <Root /> })} */}
{/* <Root /> */}
<ControlRenderBX rootComponent={<Root />} />
<ControlRenderBX />
</React.StrictMode>,
);
/** @format */
import React, { useEffect, useState } from 'react';
import Root from '../root';
const ControlRenderBX = ({ rootComponent }) => {
const ControlRenderBX = () => {
const [data, setData] = useState({});
// const intervalFetchToBx = null;
// window.alovoice_wsphone;
const [typeEnvironments, setTypeEnvironments] = useState('none');
var intervalFetchToBx;
useEffect(() => {
intervalFetchToBx = setInterval(intervalFunc, 1000);
}, []);
......@@ -17,8 +18,16 @@ const ControlRenderBX = ({ rootComponent }) => {
clearInterval(intervalFetchToBx);
}
};
console.log('check_data', Boolean(data?.number));
return rootComponent;
switch (typeEnvironments) {
case 'bitrix':
return <Root setData={setData} data={data} />;
case 'cloud':
return <Root setData={setData} data={data} />;
default:
return <Root setData={setData} data={data} />;
}
};
export default ControlRenderBX;
......@@ -9,22 +9,21 @@ import BxMiniWidjetUi from '../components/BxMiniWidjetUi';
import SecondNotifSip from '../components/SecondNotifSip';
const Root = ({ data, onSetDnd }) => {
let localValue = localStorage.getItem('activeValue') || false;
const [dataSecond, setDataSecond] = useState([]);
if (!data) {
data = {
iscloud: true,
number: '4003',
wsurl: 'cld.alovoice.uz:61040',
server_id: 40,
secret: '26a830',
lefttime: 231461,
reasons: ['free', 'outcalls', 'home', 'totop'],
reason: 'free',
variant: 'bxmini',
position: 'bottomRight',
};
}
// const [dataSecond, setDataSecond] = useState([]);
// if (!data) {
// data = {
// iscloud: true,
// number: '4003',
// wsurl: 'cld.alovoice.uz:61040',
// server_id: 40,
// secret: '26a830',
// lefttime: 231461,
// reasons: ['free', 'outcalls', 'home', 'totop'],
// reason: 'free',
// variant: 'bxmini',
// position: 'bottomRight',
// };
// }
if (window?.alovoice_wsphone) {
data = window.alovoice_wsphone;
......@@ -54,18 +53,18 @@ const Root = ({ data, onSetDnd }) => {
boxDialer.setSipStateChangeCallback(setSecondLine, 'secondLine');
boxDialer.sipRegister(data);
}
setDataSecond(data);
onSetDnd(data);
}, []);
const hangupButton = () => {
boxDialer.hangupButtonClick();
};
window.setWSData = (result) => {
setDataSecond(result);
onSetDnd(result);
};
const reasonSelect = async (e) => {
let result = await onSetDnd(e);
setDataSecond(result);
onSetDnd(result);
// data = result;
};
const selectWidjetType = (type) => {
......@@ -75,9 +74,9 @@ const Root = ({ data, onSetDnd }) => {
<BxMiniWidjetUi
widjetState={dynamicValue}
phoneNumber={data?.number}
reason={dataSecond?.reason}
reason={data?.reason}
widjetVersion={packageJson?.version}
leftTime={dataSecond.lefttime || data.lefttime}
leftTime={data.lefttime}
position={data.position || 'bottomLeft'}
onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true);
......@@ -89,7 +88,7 @@ const Root = ({ data, onSetDnd }) => {
<DefaultWidjetUi
widjetState={dynamicValue}
phoneNumber={data?.number}
reason={dataSecond?.reason}
reason={data?.reason}
widjetVersion={packageJson?.version}
leftTime={data.lefttime}
position={data.position || 'bottomLeft'}
......@@ -111,7 +110,7 @@ const Root = ({ data, onSetDnd }) => {
modalState={modalState}
phoneModal={phoneModal}
reasons={data?.reasons}
reason={dataSecond?.reason}
reason={data?.reason}
onClick={(e) => e.stopPropagation()}
dynamicValue={dynamicValue}
onSetDnd={reasonSelect}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment