Commit 26ebe526 authored by Muhammadali's avatar Muhammadali

update

parent 418e4f89
{ {
"name": "boxdialer", "name": "boxdialer",
"version": "1.9.9", "version": "2.0.0",
"description": "", "description": "",
"main": "src/boxDialer.js", "main": "src/boxDialer.js",
"scripts": { "scripts": {
......
...@@ -9,8 +9,8 @@ import BxMiniWidjetUi from '../components/BxMiniWidjetUi'; ...@@ -9,8 +9,8 @@ import BxMiniWidjetUi from '../components/BxMiniWidjetUi';
import SecondNotifSip from '../components/SecondNotifSip'; import SecondNotifSip from '../components/SecondNotifSip';
const Root = ({ data, onSetDnd }) => { const Root = ({ data, onSetDnd }) => {
const [stateData, setStateData] = useState({}); let localValue = localStorage.getItem('activeValue') || false;
const [dataSecond, setDataSecond] = useState([]);
if (!data) { if (!data) {
data = { data = {
iscloud: true, iscloud: true,
...@@ -31,13 +31,6 @@ const Root = ({ data, onSetDnd }) => { ...@@ -31,13 +31,6 @@ const Root = ({ data, onSetDnd }) => {
onSetDnd = window.alovoice_onsetdnd; onSetDnd = window.alovoice_onsetdnd;
} }
useEffect(() => {
if (data || window.alovoice_wsphone) {
setStateData(data);
}
});
console.log('stateData:', stateData, data);
const [phoneModal, setPhoneModal] = useState(false); const [phoneModal, setPhoneModal] = useState(false);
const [dynamicValue, setDynamicValue] = useState('pending'); const [dynamicValue, setDynamicValue] = useState('pending');
const [modalState, setModalState] = useState(false); const [modalState, setModalState] = useState(false);
...@@ -54,25 +47,25 @@ const Root = ({ data, onSetDnd }) => { ...@@ -54,25 +47,25 @@ const Root = ({ data, onSetDnd }) => {
}, [secondLine]); }, [secondLine]);
useEffect(() => { useEffect(() => {
if (stateData && stateData?.number) { if (data && data?.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(stateData); boxDialer.sipRegister(data);
} }
setStateData(stateData); setDataSecond(data);
}, []); }, []);
const hangupButton = () => { const hangupButton = () => {
boxDialer.hangupButtonClick(); boxDialer.hangupButtonClick();
}; };
window.setWSData = (result) => { window.setWSData = (result) => {
setStateData(result); setDataSecond(result);
}; };
const reasonSelect = async (e) => { const reasonSelect = async (e) => {
let result = await onSetDnd(e); let result = await onSetDnd(e);
setStateData(result); setDataSecond(result);
// data = result; // data = result;
}; };
const selectWidjetType = (type) => { const selectWidjetType = (type) => {
...@@ -81,11 +74,11 @@ const Root = ({ data, onSetDnd }) => { ...@@ -81,11 +74,11 @@ const Root = ({ data, onSetDnd }) => {
return ( return (
<BxMiniWidjetUi <BxMiniWidjetUi
widjetState={dynamicValue} widjetState={dynamicValue}
phoneNumber={stateData?.number} phoneNumber={data?.number}
reason={stateData?.reason} reason={dataSecond?.reason}
widjetVersion={packageJson?.version} widjetVersion={packageJson?.version}
leftTime={stateData.lefttime} leftTime={dataSecond.lefttime || data.lefttime}
position={stateData.position || 'bottomLeft'} position={data.position || 'bottomLeft'}
onClick={() => { onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true); phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}} }}
...@@ -95,11 +88,11 @@ const Root = ({ data, onSetDnd }) => { ...@@ -95,11 +88,11 @@ const Root = ({ data, onSetDnd }) => {
return ( return (
<DefaultWidjetUi <DefaultWidjetUi
widjetState={dynamicValue} widjetState={dynamicValue}
phoneNumber={stateData?.number} phoneNumber={data?.number}
reason={stateData?.reason} reason={dataSecond?.reason}
widjetVersion={packageJson?.version} widjetVersion={packageJson?.version}
leftTime={stateData.lefttime} leftTime={data.lefttime}
position={stateData.position || 'bottomLeft'} position={data.position || 'bottomLeft'}
onClick={() => { onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true); phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}} }}
...@@ -108,21 +101,22 @@ const Root = ({ data, onSetDnd }) => { ...@@ -108,21 +101,22 @@ const Root = ({ data, onSetDnd }) => {
} }
}; };
if (!stateData || !stateData?.number || !stateData?.position) return; if (!data || !data?.number || !data?.position) return;
console.log(modalState, 'modalState');
return ( return (
<> <>
{selectWidjetType(stateData.variant)} {selectWidjetType(data.variant)}
<ModalPhoneNumpad <ModalPhoneNumpad
modalState={modalState} modalState={modalState}
phoneModal={phoneModal} phoneModal={phoneModal}
reasons={stateData?.reasons} reasons={data?.reasons}
reason={stateData?.reason} reason={dataSecond?.reason}
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
dynamicValue={dynamicValue} dynamicValue={dynamicValue}
onSetDnd={reasonSelect} onSetDnd={reasonSelect}
variant={stateData.variant || 'defaultWidjet'} variant={data.variant || 'defaultWidjet'}
position={stateData.position || 'bottomLeft'} position={data.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