Commit 1298655f authored by Muhammadali's avatar Muhammadali

update

parent 2fd839c4
{ {
"name": "boxdialer", "name": "boxdialer",
"version": "1.9.2", "version": "1.9.3",
"description": "", "description": "",
"main": "src/boxDialer.js", "main": "src/boxDialer.js",
"scripts": { "scripts": {
......
...@@ -10,26 +10,35 @@ import SecondNotifSip from '../components/SecondNotifSip'; ...@@ -10,26 +10,35 @@ import SecondNotifSip from '../components/SecondNotifSip';
const Root = ({ data, onSetDnd }) => { const Root = ({ data, onSetDnd }) => {
let localValue = localStorage.getItem('activeValue') || false; let localValue = localStorage.getItem('activeValue') || false;
const [dataSecond, setDataSecond] = useState([]); const [stateData, setStateData] = useState({});
if (!data) {
data = { // if (!data) {
iscloud: true, // data = {
number: '4003', // iscloud: true,
wsurl: 'cld.alovoice.uz:61040', // number: '4003',
server_id: 40, // wsurl: 'cld.alovoice.uz:61040',
secret: '26a830', // server_id: 40,
lefttime: 231461, // secret: '26a830',
reasons: ['free', 'outcalls', 'home', 'totop'], // lefttime: 231461,
reason: 'free', // reasons: ['free', 'outcalls', 'home', 'totop'],
variant: 'bxmini', // reason: 'free',
position: 'bottomRight', // variant: 'bxmini',
}; // position: 'bottomRight',
} // };
// }
// if (window?.alovoice_wsphone) {
// data = window.alovoice_wsphone;
// onSetDnd = window.alovoice_onsetdnd;
// }
useEffect(() => {
if (window?.alovoice_wsphone) { if (window?.alovoice_wsphone) {
data = window.alovoice_wsphone; // data = window.alovoice_wsphone;
setStateData(window.alovoice_wsphone);
onSetDnd = window.alovoice_onsetdnd; onSetDnd = window.alovoice_onsetdnd;
} }
}, []);
const [phoneModal, setPhoneModal] = useState(false); const [phoneModal, setPhoneModal] = useState(false);
const [dynamicValue, setDynamicValue] = useState('pending'); const [dynamicValue, setDynamicValue] = useState('pending');
...@@ -47,26 +56,25 @@ const Root = ({ data, onSetDnd }) => { ...@@ -47,26 +56,25 @@ const Root = ({ data, onSetDnd }) => {
}, [secondLine]); }, [secondLine]);
useEffect(() => { useEffect(() => {
if (data && data?.number) { if (stateData && stateData?.number) {
boxDialer.setSipStateChangeCallback(setDynamicValue, 'dynamicValue'); boxDialer.setSipStateChangeCallback(setDynamicValue, 'dynamicValue');
boxDialer.setSipStateChangeCallback(setModalState, 'modalState'); boxDialer.setSipStateChangeCallback(setModalState, 'modalState');
boxDialer.setSipStateChangeCallback(setPhoneModal, 'phoneModal'); boxDialer.setSipStateChangeCallback(setPhoneModal, 'phoneModal');
boxDialer.setSipStateChangeCallback(setSecondLine, 'secondLine'); boxDialer.setSipStateChangeCallback(setSecondLine, 'secondLine');
boxDialer.sipRegister(data); boxDialer.sipRegister(stateData);
} }
setDataSecond(data); setStateData(stateData);
}, []); }, []);
const hangupButton = () => { const hangupButton = () => {
boxDialer.hangupButtonClick(); boxDialer.hangupButtonClick();
}; };
window.setWSData = (result) => { window.setWSData = (result) => {
setDataSecond(result); setStateData(result);
}; };
const reasonSelect = async (e) => { const reasonSelect = async (e) => {
let result = await onSetDnd(e); let result = await onSetDnd(e);
console.log('result: ', result); setStateData(result);
setDataSecond(result);
// data = result; // data = result;
}; };
const selectWidjetType = (type) => { const selectWidjetType = (type) => {
...@@ -75,11 +83,11 @@ const Root = ({ data, onSetDnd }) => { ...@@ -75,11 +83,11 @@ const Root = ({ data, onSetDnd }) => {
return ( return (
<BxMiniWidjetUi <BxMiniWidjetUi
widjetState={dynamicValue} widjetState={dynamicValue}
phoneNumber={data?.number} phoneNumber={stateData?.number}
reason={dataSecond?.reason} reason={stateData?.reason}
widjetVersion={packageJson?.version} widjetVersion={packageJson?.version}
leftTime={dataSecond.lefttime || data.lefttime} leftTime={stateData.lefttime}
position={data.position || 'bottomLeft'} position={stateData.position || 'bottomLeft'}
onClick={() => { onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true); phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}} }}
...@@ -89,11 +97,11 @@ const Root = ({ data, onSetDnd }) => { ...@@ -89,11 +97,11 @@ const Root = ({ data, onSetDnd }) => {
return ( return (
<DefaultWidjetUi <DefaultWidjetUi
widjetState={dynamicValue} widjetState={dynamicValue}
phoneNumber={data?.number} phoneNumber={stateData?.number}
reason={dataSecond?.reason} reason={stateData?.reason}
widjetVersion={packageJson?.version} widjetVersion={packageJson?.version}
leftTime={data.lefttime} leftTime={stateData.lefttime}
position={data.position || 'bottomLeft'} position={stateData.position || 'bottomLeft'}
onClick={() => { onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true); phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}} }}
...@@ -102,22 +110,22 @@ const Root = ({ data, onSetDnd }) => { ...@@ -102,22 +110,22 @@ const Root = ({ data, onSetDnd }) => {
} }
}; };
if (!data || !data?.number || !data?.position) return; if (!stateData || !stateData?.number || !stateData?.position) return;
console.log(modalState, 'modalState'); console.log(modalState, 'modalState');
return ( return (
<> <>
{selectWidjetType(data.variant)} {selectWidjetType(stateData.variant)}
<ModalPhoneNumpad <ModalPhoneNumpad
modalState={modalState} modalState={modalState}
phoneModal={phoneModal} phoneModal={phoneModal}
reasons={data?.reasons} reasons={stateData?.reasons}
reason={dataSecond?.reason} reason={stateData?.reason}
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
dynamicValue={dynamicValue} dynamicValue={dynamicValue}
onSetDnd={reasonSelect} onSetDnd={reasonSelect}
variant={data.variant || 'defaultWidjet'} variant={stateData.variant || 'defaultWidjet'}
position={data.position || 'bottomLeft'} position={stateData.position || 'bottomLeft'}
/> />
<Modal <Modal
......
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