Commit 0f75677e authored by Muhammadali's avatar Muhammadali

update

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