import { useEffect, useState, useCallback } from 'react'; import { useDispatch } from 'react-redux'; import PozoWeightScaleIcon from './Pozo retail icons/PozoWeightScaleIcon'; import { changeWeightScalePort, changeWeightScaleWeight, } from '../../../../Features/BookingScreen/BookingData/BookingData'; import WeightScaleComp from '../../../../Components/WeightScale/weightScale.jsx'; import { Messages } from '../../../../Components/Notifications/Messages'; import TooltipWrapper from '../../../../Components/Tooltip/Tooltip'; import { isMobile } from 'react-device-detect'; import WeightScaleApp from '../../WeightscaleApp.jsx'; const BSNavBarWeightScale = ({Combo}) => { const dispatch = useDispatch(); const [WeightScale, setWeightScale] = useState(false); const [wsport, setwsport] = useState(null); const [WeightScale2, setWeightScale2] = useState(false); const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); console.log(WeightScale,"WeightScale") useEffect(() => { if (WeightScale2 === true) { setWeightScale(true); } else { setWeightScale(false); } }, [WeightScale2]); const handleWeightScaleOpen = () => { setWeightScale2(!WeightScale2); dispatch(changeWeightScalePort(!WeightScale2)); }; const setWsport = async (e) => { if (e?.readable) { setwsport(e); } else { setMessageType('error'); setMessageData('Please check weightscale connection'); setWeightScale2(false); } }; const myfun = async (e) => { console.log(e,"weight") dispatch(changeWeightScaleWeight(e)); }; const onComplete = useCallback(() => { setMessageData(null); setMessageType(null); }, []); const msgAlert = async (e) => { setMessageType(e.type); setMessageData(e.msg); }; return (