Commit 1298655f authored by Muhammadali's avatar Muhammadali

update

parent 2fd839c4
{
"name": "boxdialer",
"version": "1.9.2",
"version": "1.9.3",
"description": "",
"main": "src/boxDialer.js",
"scripts": {
......
......@@ -10,26 +10,35 @@ 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 [stateData, setStateData] = useState({});
if (window?.alovoice_wsphone) {
data = window.alovoice_wsphone;
onSetDnd = window.alovoice_onsetdnd;
}
// 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;
// onSetDnd = window.alovoice_onsetdnd;
// }
useEffect(() => {
if (window?.alovoice_wsphone) {
// data = window.alovoice_wsphone;
setStateData(window.alovoice_wsphone);
onSetDnd = window.alovoice_onsetdnd;
}
}, []);
const [phoneModal, setPhoneModal] = useState(false);
const [dynamicValue, setDynamicValue] = useState('pending');
......@@ -47,26 +56,25 @@ const Root = ({ data, onSetDnd }) => {
}, [secondLine]);
useEffect(() => {
if (data && data?.number) {
if (stateData && stateData?.number) {
boxDialer.setSipStateChangeCallback(setDynamicValue, 'dynamicValue');
boxDialer.setSipStateChangeCallback(setModalState, 'modalState');
boxDialer.setSipStateChangeCallback(setPhoneModal, 'phoneModal');
boxDialer.setSipStateChangeCallback(setSecondLine, 'secondLine');
boxDialer.sipRegister(data);
boxDialer.sipRegister(stateData);
}
setDataSecond(data);
setStateData(stateData);
}, []);
const hangupButton = () => {
boxDialer.hangupButtonClick();
};
window.setWSData = (result) => {
setDataSecond(result);
setStateData(result);
};
const reasonSelect = async (e) => {
let result = await onSetDnd(e);
console.log('result: ', result);
setDataSecond(result);
setStateData(result);
// data = result;
};
const selectWidjetType = (type) => {
......@@ -75,11 +83,11 @@ const Root = ({ data, onSetDnd }) => {
return (
<BxMiniWidjetUi
widjetState={dynamicValue}
phoneNumber={data?.number}
reason={dataSecond?.reason}
phoneNumber={stateData?.number}
reason={stateData?.reason}
widjetVersion={packageJson?.version}
leftTime={dataSecond.lefttime || data.lefttime}
position={data.position || 'bottomLeft'}
leftTime={stateData.lefttime}
position={stateData.position || 'bottomLeft'}
onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}}
......@@ -89,11 +97,11 @@ const Root = ({ data, onSetDnd }) => {
return (
<DefaultWidjetUi
widjetState={dynamicValue}
phoneNumber={data?.number}
reason={dataSecond?.reason}
phoneNumber={stateData?.number}
reason={stateData?.reason}
widjetVersion={packageJson?.version}
leftTime={data.lefttime}
position={data.position || 'bottomLeft'}
leftTime={stateData.lefttime}
position={stateData.position || 'bottomLeft'}
onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}}
......@@ -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');
return (
<>
{selectWidjetType(data.variant)}
{selectWidjetType(stateData.variant)}
<ModalPhoneNumpad
modalState={modalState}
phoneModal={phoneModal}
reasons={data?.reasons}
reason={dataSecond?.reason}
reasons={stateData?.reasons}
reason={stateData?.reason}
onClick={(e) => e.stopPropagation()}
dynamicValue={dynamicValue}
onSetDnd={reasonSelect}
variant={data.variant || 'defaultWidjet'}
position={data.position || 'bottomLeft'}
variant={stateData.variant || 'defaultWidjet'}
position={stateData.position || 'bottomLeft'}
/>
<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