diff --git a/src/App.js b/src/App.js index b6aacbd..4510532 100644 --- a/src/App.js +++ b/src/App.js @@ -8,7 +8,7 @@ import Notistack from 'components/third-party/Notistack'; import { useNavigate } from 'react-router'; import { useEffect } from 'react'; import InternetStatus from 'components/nearle_components/updateNetworkStatus'; -import { useDispatch, useSelector } from 'react-redux'; +import { useSelector } from 'react-redux'; // auth-provider // import { JWTProvider as AuthProvider } from 'contexts/JWTContext'; diff --git a/src/layout/MainLayout/AppSideNav.js b/src/layout/MainLayout/AppSideNav.js index b60cd8f..275cf25 100644 --- a/src/layout/MainLayout/AppSideNav.js +++ b/src/layout/MainLayout/AppSideNav.js @@ -25,14 +25,13 @@ const AppSideNav = ({ isCollapsed, onCollapsedChange }) => { // Wrap explicitly in Astryx's own rather than passing the bare // component and letting SideNavItem's renderIconSlot auto-detect it: // that detection only matches plain functions/forwardRef objects, not - // React.memo-wrapped ones (several @ant-design/icons v5 icons, as well - // as @mui/icons-material icons, are memo-wrapped) — those fell through + // React.memo-wrapped ones (several @ant-design/icons v5 icons are + // memo-wrapped) — those fell through // and got returned as a raw, uninstantiated element, crashing with // "Objects are not valid as a React child". Wrapping here always // renders through Icon's own component-mode path, which handles any // component type and gives every icon the same normalised size/colour - // regardless of source library (this menu mixes @ant-design/icons and - // @mui/icons-material). + // regardless of source library. const icon = item.icon ? : undefined; if (item.type === 'collapse') { diff --git a/src/layout/MainLayout/AppTopNav.js b/src/layout/MainLayout/AppTopNav.js index c248a70..1fe1fce 100644 --- a/src/layout/MainLayout/AppTopNav.js +++ b/src/layout/MainLayout/AppTopNav.js @@ -5,7 +5,6 @@ import { TopNav, TopNavHeading } from '@astryxdesign/core/TopNav'; import { DropdownMenu } from '@astryxdesign/core/DropdownMenu'; import { Avatar } from '@astryxdesign/core/Avatar'; import { HStack } from '@astryxdesign/core/HStack'; -import { Text } from '@astryxdesign/core/Text'; import { WindowsOutlined, EditOutlined, LogoutOutlined } from '@ant-design/icons'; import { TbBoxMultiple1 } from 'react-icons/tb'; @@ -31,7 +30,6 @@ const AppTopNav = () => { const topNavRef = useRef(null); const [headerHeight, setHeaderHeight] = useState(null); - const tenantname = localStorage.getItem('tenantname') || ''; const fullname = localStorage.getItem('fullname') || ''; const handleLogout = () => { diff --git a/src/menu-items/nearle.js b/src/menu-items/nearle.js index 46cc2be..05ce1b5 100644 --- a/src/menu-items/nearle.js +++ b/src/menu-items/nearle.js @@ -6,42 +6,8 @@ import { TbListDetails } from 'react-icons/tb'; import { LiaFileInvoiceSolid } from 'react-icons/lia'; import { MdDirectionsBike as DirectionsBikeOutlinedIcon, MdRoute as RouteOutlinedIcon, MdMoped as MopedOutlinedIcon } from 'react-icons/md'; -// assets -import { - BorderOutlined, - BoxPlotOutlined, - ChromeOutlined, - DeploymentUnitOutlined, - GatewayOutlined, - MenuUnfoldOutlined, - QuestionOutlined, - SmileOutlined, - StopOutlined, - DashboardOutlined, - ClockCircleOutlined, - UserOutlined, - SettingOutlined -} from '@ant-design/icons'; -import { Path } from 'leaflet'; import { MdLocationOn as LocationOnOutlined } from 'react-icons/md'; -// icons -const icons = { - ChromeOutlined, - MenuUnfoldOutlined, - BoxPlotOutlined, - StopOutlined, - BorderOutlined, - SmileOutlined, - GatewayOutlined, - QuestionOutlined, - DeploymentUnitOutlined, - DashboardOutlined, - ClockCircleOutlined, - UserOutlined, - SettingOutlined -}; - // ==============================|| MENU ITEMS - SUPPORT ||============================== // const nearle = { diff --git a/src/pages/nearle/api/api.js b/src/pages/nearle/api/api.js index 88694c0..608eded 100644 --- a/src/pages/nearle/api/api.js +++ b/src/pages/nearle/api/api.js @@ -94,7 +94,7 @@ export const fetchDeliveryLocationSummary = async () => { // fetchOrders.js export const fetchOrders1 = async ({ pageParam = 1, queryKey }) => { - const [_key, tenantid, locationid, status, startdate, enddate, searchword, rowsPerPage] = queryKey; + const [, tenantid, locationid, status, startdate, enddate, searchword, rowsPerPage] = queryKey; const res = await axios.get( `${process.env.REACT_APP_URL}/orders/tenant/getorders/?tenantid=${tenantid}&locationid=${locationid}&status=${status}&fromdate=${startdate}&todate=${enddate}&pageno=${pageParam}&pagesize=${rowsPerPage}&keyword=${searchword}` @@ -224,7 +224,7 @@ export const gettenantlocations = async ({ queryKey }) => { // ==============================|| fetchDeliverySummary (orders summary)||============================== // export const fetchDeliverySummary = async ({ queryKey }) => { - const [, startdate, enddate, currentStatus, locationId] = queryKey; + const [, startdate, enddate, , locationId] = queryKey; const response = await axios.get( `${process.env.REACT_APP_URL}/deliveries/deliverysummary?tenantid=${tenid}&locationid=${locationId}&fromdate=${startdate}&todate=${enddate}` ); diff --git a/src/pages/nearle/clients/createCustomer.js b/src/pages/nearle/clients/createCustomer.js index 711055c..5058080 100644 --- a/src/pages/nearle/clients/createCustomer.js +++ b/src/pages/nearle/clients/createCustomer.js @@ -24,37 +24,22 @@ const FieldGrid = ({ children }) => ( const CreateCustomer = () => { const appId = localStorage.getItem('applocationid'); - const [selectedImage, setSelectedImage] = useState(undefined); - const [avatar, setAvatar] = useState(); - const [businessname, setBusinessname] = useState(''); - const [businessno, setBusinessno] = useState(''); + const [selectedImage] = useState(undefined); + const [, setAvatar] = useState(); const [mobilenumber, setMobilenumber] = useState(''); const [emailaddress, setEmailaddress] = useState(''); - const [city, setCity] = useState(''); - const [zipcode, setZipcode] = useState(''); const [address, setAddress] = useState(''); - const [suburb, setSuburb] = useState(''); - const [latlong, setLatlong] = useState({}); const [firstname, setFirstname] = useState(''); const [doorno, setDoorno] = useState(''); const [landmark, setLandmark] = useState(''); - const [tenantinfo, setTenantinfo] = useState({}); + const [, setTenantinfo] = useState({}); const [inputValue2, setInputValue2] = useState(''); const [appLocaLat, setAppLocaLat] = useState(); const [appLocaLng, setAppLocaLng] = useState(); const [appLocaRadius, setAppLocaRadius] = useState(); - const [locaName, setLocoName] = useState('Select Location'); - const [locations, setLocations] = useState('Select Location'); - const [tenantlist, setTenantlist] = useState([]); + const [, setLocations] = useState('Select Location'); const userid = localStorage.getItem('userid'); - const [isAppLocation, setIsAppLocation] = useState(false); - const [tenantLocations, setTenantlocations] = useState([]); - const [isClient, setisclient] = useState(false); - const [tid, setTid] = useState(0); - const [isBusiness, setIsBusiness] = useState(false); - const [tenanatLocoId, setTenanatLocoId] = useState(localStorage.getItem('locationid')); - const [tenantlocation, setTenantlocation] = useState(''); - const [isLocation, setIsLocation] = useState(false); + const [tid] = useState(0); const [pickCust, setPickCust] = useState({}); const [startPoint, setStartPoint] = useState({ latitude: 0, longitude: 0 }); @@ -86,7 +71,6 @@ const CreateCustomer = () => { radius: appLocaRadius * 1000 }).getBounds() }); - let arr = []; // Event listener for autocomplete place changed autocomplete.addListener('place_changed', () => { const place = autocomplete.getPlace(); @@ -163,7 +147,7 @@ const CreateCustomer = () => { .get(`${process.env.REACT_APP_URL}/utils/getapplocations/?applocationid=${appId}`) .then((res) => { logger.info('getapplocations', res); - const { opentime, closetime, latitude, longitude, radius } = res.data.details?.[0] || {}; + const { latitude, longitude, radius } = res.data.details?.[0] || {}; if (res.data.status) { setAppLocaLat(latitude); setAppLocaLng(longitude); @@ -202,50 +186,6 @@ const CreateCustomer = () => { // ===================================================== || fetchtenantinfolist || ===================================================== - const fetchtenantinfolist = async (id) => { - setLoading(true); - await axios - .get(`${process.env.REACT_APP_URL}/tenants/gettenants/?applocationid=${id}&status=active`) - - .then((res) => { - logger.info(res); - if (res.data.status) { - let arr = []; - res.data.details.map((val) => { - arr.push({ - ...val, - label: `${val.tenantname}` - }); - }); - setTenantlist(arr); - } - setLoading(false); - }) - .catch((err) => { - logger.error(err); - setLoading(false); - }); - }; - // ============================================= || gettenantlocations (branches) || ============================================= - const gettenantlocations = async (id) => { - try { - const res = await axios.get(`${process.env.REACT_APP_URL}/tenants/gettenantlocations/?tenantid=${id}`); - logger.info('gettenantlocations', res.data.details); - if (res.data.details.length == 1) { - setIsLocation(true); - setTenantlocations(res.data.details); - setTenanatLocoId(res.data.details[0].locationid); - setTenantlocation(res.data.details[0].locationaddress); //client address - setIsBusiness(true); - } else { - setTenantlocations(res.data.details); - setIsBusiness(false); // became true after select from tenanatLocations - } - } catch (err) { - logger.error('gettenantlocations', err); - } - }; - const opentoast = (message) => { enqueueSnackbar(message, { variant: 'error', diff --git a/src/pages/nearle/deliveries/deliveries.js b/src/pages/nearle/deliveries/deliveries.js index f43d006..935c7c7 100644 --- a/src/pages/nearle/deliveries/deliveries.js +++ b/src/pages/nearle/deliveries/deliveries.js @@ -33,7 +33,6 @@ import { useHotkeyFocus } from 'components/nearle_components/useHotkeyFocus'; import DateFilterDialog from 'components/nearle_components/DateFilterDialog'; import CircularLoader from 'components/nearle_components/CircularLoader'; import { useQuery, useInfiniteQuery } from '@tanstack/react-query'; -import { useNavigate } from 'react-router-dom'; import logger from 'utils/logger'; // ============================================================================ @@ -201,7 +200,6 @@ const MetricCell = ({ value, color, icon, isMoney = false }) => { const noWrapStyle = { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }; const Deliveries = () => { - const navigate = useNavigate(); const tid = localStorage.getItem('tenantid'); const loadMoreRef = useRef(); const containerRef = useRef(); diff --git a/src/pages/nearle/dispatch/ActiveSection.js b/src/pages/nearle/dispatch/ActiveSection.js index 333fc69..8e88715 100644 --- a/src/pages/nearle/dispatch/ActiveSection.js +++ b/src/pages/nearle/dispatch/ActiveSection.js @@ -107,7 +107,7 @@ const ActiveSection = ({ ); } - const renderActiveDeliveryCard = (o, i) => { + const renderActiveDeliveryCard = (o) => { const rid = o.rider_id || o.userid; const rider = riders.find((r) => String(r.id) === String(rid)); const color = getRiderColor(rid); diff --git a/src/pages/nearle/dispatch/Dispatch.js b/src/pages/nearle/dispatch/Dispatch.js index 9ec35c5..2aa24a8 100644 --- a/src/pages/nearle/dispatch/Dispatch.js +++ b/src/pages/nearle/dispatch/Dispatch.js @@ -1,5 +1,5 @@ import React, { useState, useEffect, useMemo, useCallback, useRef } from 'react'; -import { MapContainer, TileLayer, Marker, Popup, Polyline, Tooltip, useMap, useMapEvents, ZoomControl } from 'react-leaflet'; +import { MapContainer, TileLayer, Marker, Popup, Polyline, Tooltip, useMap, ZoomControl } from 'react-leaflet'; import L from 'leaflet'; import 'leaflet/dist/leaflet.css'; // Side-effect import: patches L.Polyline so pathOptions.offset (in screen px) @@ -20,7 +20,6 @@ import { MdStraighten, MdLocationOn, MdMarkunreadMailbox, - MdMoveToInbox, MdPerson, MdPlace, MdTwoWheeler, @@ -40,10 +39,7 @@ import { MdChevronLeft, MdChevronRight, MdLocalMall, - MdCheckCircle, MdErrorOutline, - MdWarning, - MdClose, MdFormatListBulleted, MdTimer, MdCalendarToday, @@ -52,7 +48,6 @@ import { } from 'react-icons/md'; import { fetchDeliveries, fetchAppLocations, getRiderPeriodicLogs, fetchRidersLogs, fetchBatchEfficiency } from '../api/api'; import { - STATUS_STYLES, getStatusStyle, FINAL_STATUSES, SKIPPED_STATUSES, @@ -229,11 +224,6 @@ const getRowBatch = (r, fieldId = 'all', batches = BATCHES_DEFAULT) => { // the operator clicks empty map space. Markers' click events do NOT bubble // to the map, so this only fires on background clicks (which is what we // want — clicking elsewhere should release the pin). -function CompareMapClickUnpin({ onUnpin }) { - useMapEvents({ click: () => onUnpin() }); - return null; -} - // Captures the Leaflet map instance for the parent component via a ref. Kept // available even after the two-map Compare layout was unified into one map, // since future per-step imperative zoom logic still needs a handle on the @@ -751,14 +741,6 @@ const ANALYSIS_BATCH_WINDOWS = [ { key: 'evening', label: 'Evening', timeRange: '4:00 PM – 7:00 PM', sub: 'Dinner & end-of-day', color: '#6366f1', bg: '#eef2ff', border: '#c7d2fe' } ]; -// Tolerant field-name lookup so the Analysis card still renders cleanly even -// if the API response uses slightly different keys than expected. -const analysisPick = (obj, keys) => { - for (const k of keys) { - if (obj && obj[k] != null && obj[k] !== '') return obj[k]; - } - return null; -}; const analysisFormatNum = (v) => { if (v == null) return '—'; if (typeof v === 'number') return v.toLocaleString('en-IN'); @@ -766,14 +748,6 @@ const analysisFormatNum = (v) => { if (Number.isFinite(n)) return n.toLocaleString('en-IN'); return String(v); }; -const analysisFormatKm = (v) => (v == null ? '—' : `${parseFloat(v).toFixed(1)} km`); -const analysisFormatRupees = (v) => (v == null ? '—' : `₹${parseFloat(v).toFixed(0)}`); -const analysisFormatPct = (v) => { - if (v == null) return '—'; - const n = parseFloat(v); - if (!Number.isFinite(n)) return '—'; - return `${n > 1 ? n.toFixed(1) : (n * 100).toFixed(1)}%`; -}; const Dispatch = ({ data, @@ -795,7 +769,7 @@ const Dispatch = ({ // map + sidebar UI) or 'analysis' (batch efficiency panel). Embedded use // (Preview) never reaches the Analysis switcher, so default doesn't matter // there. - const [topView, setTopView] = useState('live'); + const [topView] = useState('live'); const [analysisResults, setAnalysisResults] = useState({}); const [analysisLoadingWindow, setAnalysisLoadingWindow] = useState(null); const [activeBatchKey, setActiveBatchKey] = useState(null); @@ -833,7 +807,7 @@ const Dispatch = ({ // Single delivery stop pinned by clicking its sidebar row — overrides the rider's full-route bounds on the map. const [focusedStop, setFocusedStop] = useState(null); // Fly-to target set by ActiveSection card clicks — zooms the map without touching sidebar or popup. - const [activeFlyTo, setActiveFlyTo] = useState(null); + const [activeFlyTo] = useState(null); // How the stops inside each trip block are ordered in the focused-rider sidebar: // 'planned' → the dispatched route order (by step) — the default. // 'time' → re-sorted by when each delivery was actually completed, so the @@ -863,7 +837,6 @@ const Dispatch = ({ // Short-lived close timer for the general map order/marker popups. // Gives the cursor a ~200ms window to travel from the marker onto the popup // or vice versa without immediately triggering a close. - const activePopupMarkerRef = useRef(null); const popupHoverTimerRef = useRef(null); // Order shown in the centered popup overlay. Rendered outside the leaflet // map (see `dispatch-popup-center` overlay near the bottom of the JSX) so @@ -887,9 +860,7 @@ const Dispatch = ({ // The user's last-picked location is mirrored into localStorage so it // survives reloads and stays in sync with other pages that read it. const initialAppLocationId = typeof window !== 'undefined' ? localStorage.getItem('applocationid') : null; - const [selectedAppLocationId, setSelectedAppLocationId] = useState( - initialAppLocationId != null ? Number(initialAppLocationId) : 0 - ); + const [selectedAppLocationId] = useState(initialAppLocationId != null ? Number(initialAppLocationId) : 0); const [locationMenuOpen, setLocationMenuOpen] = useState(false); const locationMenuRef = useRef(null); @@ -897,7 +868,7 @@ const Dispatch = ({ // orders bucket into Morning/Afternoon/Evening by when they were assigned, // per current spec. The status-wise time-field dropdown is hidden for now // (see commented-out block in JSX), so this stays fixed at 'assigned'. - const [selectedTimeField, setSelectedTimeField] = useState('assigned'); + const [selectedTimeField] = useState('assigned'); const [timeFieldMenuOpen, setTimeFieldMenuOpen] = useState(false); const timeFieldMenuRef = useRef(null); @@ -906,7 +877,7 @@ const Dispatch = ({ // id/label/range/startHour/endHour just like the default list — the rest // of the file reads BATCHES (derived below) without caring whether the // values came from defaults or from operator edits. - const [slotsConfig, setSlotsConfig] = useState(() => { + const [slotsConfig] = useState(() => { if (typeof window === 'undefined') return BATCHES_DEFAULT; try { const raw = window.localStorage.getItem(SLOTS_STORAGE_KEY); @@ -1064,21 +1035,6 @@ const Dispatch = ({ return match?.locationname || null; }, [appLocations, selectedAppLocationId]); - const handleLocationPick = (id) => { - logger.info('Switching hub/location ID:', id); - setSelectedAppLocationId(Number(id)); - setLocationMenuOpen(false); - if (typeof window !== 'undefined') { - try { localStorage.setItem('applocationid', String(id)); } catch (e) { /* ignore quota errors */ } - } - // Switching hubs invalidates the current focused rider/kitchen/zone since - // they belong to the previous hub's data. handleRiderFocus is declared - // further down the component but the closure is only called after click, - // so the reference resolves cleanly. - handleRiderFocus(null); - setFocusedKitchen(null); - setFocusedZone(null); - }; const [osrmRoutes, setOsrmRoutes] = useState({}); // Mirror of osrmRoutes held in a ref so fetchRoute can check the cache without @@ -1777,13 +1733,6 @@ const Dispatch = ({ }; }, [focusedRider, focusedKitchen, isAllActiveView, activeViewRiders, stats]); - // Count of in-progress deliveries shown in the Active view list. Derives from - // the sticky cache (via activeViewRiders) so header and card list always agree. - const activeDeliveryCount = useMemo( - () => (isAllActiveView ? activeViewRiders.reduce((sum, r) => sum + r.orders.length, 0) : 0), - [isAllActiveView, activeViewRiders] - ); - // List of deliveryids we want GPS logs for. Drives two pipelines: // • renderRoutes() — actual-route polylines on the main map for // every visible rider/trip @@ -1850,6 +1799,7 @@ const Dispatch = ({ // _ts on each ping to compute per-step dt, so we run it BEFORE // stripping _ts on the way out. const smoothed = kalmanSmoothGps(sorted); + // eslint-disable-next-line no-unused-vars return smoothed.map(({ _ts, ...p }) => p); }, // Always-on so the main map can render actual-route polylines (not just @@ -2787,7 +2737,7 @@ const Dispatch = ({ ? new Map(riderActualTracks.map((t) => [String(t.deliveryid), t.sequenceStep])) : null; - return ordersToRender.map((o, idx) => { + return ordersToRender.map((o) => { const rid = o.rider_id; const active = rid ? activeRiders.has(rid) : true; let color = getRiderColor(rid); @@ -3180,13 +3130,6 @@ const Dispatch = ({ return routes; }; - const toggleRider = (rid) => { - const newActive = new Set(activeRiders); - if (newActive.has(rid)) newActive.delete(rid); - else newActive.add(rid); - setActiveRiders(newActive); - }; - return (
{!embedded && ( @@ -4928,15 +4871,6 @@ const Dispatch = ({ (o) => o.deliveryid != null && String(o.deliveryid) === String(t.deliveryid) ); - const statusStyle = getStatusStyle(t.orderstatus); - const flagSvg = t.orderstatus - ? ` - - - ${isDelivered ? '' : ''} - ` - : ''; - const dropClasses = ['compare-step-pin']; if (isFocusedStep) dropClasses.push('is-focused'); if (isDelivered) dropClasses.push('is-delivered'); diff --git a/src/pages/nearle/dispatch/Preview.js b/src/pages/nearle/dispatch/Preview.js index 0ac7916..d76d24d 100644 --- a/src/pages/nearle/dispatch/Preview.js +++ b/src/pages/nearle/dispatch/Preview.js @@ -1,10 +1,7 @@ import React, { useEffect, useMemo, useState } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; import { useMutation } from '@tanstack/react-query'; -import dayjs from 'dayjs'; import { HiOutlineArrowLeft } from 'react-icons/hi'; -import { IoReload } from 'react-icons/io5'; -import { MdTwoWheeler } from 'react-icons/md'; import { Button } from '@astryxdesign/core/Button'; import { IconButton } from '@astryxdesign/core/IconButton'; @@ -12,27 +9,12 @@ import { Tooltip } from '@astryxdesign/core/Tooltip'; import { Stack } from '@astryxdesign/core/Stack'; import { Heading } from '@astryxdesign/core/Heading'; -import { - createAutomationDeliveries, - createOptimisationDeliveries, - finalCreatedeliveries, - notifyRider, - reconcileSteps -} from '../api/api'; +import { finalCreatedeliveries, notifyRider } from '../api/api'; import { OpenToast } from 'components/nearle_components/OpenToast'; -import CSVExport from 'components/third-party/ReactTable'; import CircularLoader from 'components/nearle_components/CircularLoader'; import Dispatch from './Dispatch'; -import { stepColor } from './dispatchShared'; import { BRAND, DT } from '../_shared/ordersDesign'; -const tuningTypes = [ - { tuneid: 1, type: 'Balanced', value: 'balanced' }, - { tuneid: 2, type: 'Aggressive Speed', value: 'aggressive_speed' }, - { tuneid: 3, type: 'Fuel Saver', value: 'fuel_saver' }, - { tuneid: 4, type: 'Zone Strict', value: 'zone_strict' } -]; - // Flatten the API's zoned shape into [{ rider_id, rider_name, orders }] for // the Reconcile tab UI and the reconcile-API payload. const extractRiders = (previewData) => { @@ -103,91 +85,6 @@ const flattenRiders = (riders) => { return out; }; -// Merge a reconcile-API response { riders:[{rider_id, orders}] } back into -// dispatchPreviewData. Replaces each rider's orders[] in zones (preserving -// zone containment), then rebuilds the flat details list from the new tree. -const applyReconcileResponse = (preview, response) => { - if (!preview || !Array.isArray(response?.riders)) return preview; - const next = JSON.parse(JSON.stringify(preview)); - - const newOrdersByRider = new Map( - response.riders.map((r) => [String(r.rider_id), r.orders || []]) - ); - - if (Array.isArray(next.zones) && next.zones.length) { - // Pass 1: wipe every existing copy of a responding rider's orders across - // ALL zones. The server's reconciled list is the single source of truth, - // and a rider can be present in multiple zones (one per delivery suburb). - // The previous "update first match, delete from map" loop left stale - // copies in the other zones, which extractRiders then concatenated into - // duplicate orderids — surfacing as duplicate deliveries on Assign. - next.zones.forEach((zone) => { - if (!Array.isArray(zone.riders)) return; - zone.riders.forEach((r) => { - const key = String(r.rider_id ?? r.userid); - if (newOrdersByRider.has(key)) r.orders = []; - }); - }); - - // Pass 2: drop the reconciled orders onto the first zone that already - // lists the rider. If the rider isn't anywhere in the tree, append a - // fresh rider entry to zone[0]. - newOrdersByRider.forEach((orders, riderKey) => { - let placed = false; - for (const zone of next.zones) { - if (!Array.isArray(zone.riders)) continue; - const target = zone.riders.find( - (r) => String(r.rider_id ?? r.userid) === riderKey - ); - if (target) { - target.orders = orders; - placed = true; - break; - } - } - if (!placed) { - const target = next.zones[0]; - target.riders = target.riders || []; - target.riders.push({ - rider_id: Number(riderKey) || riderKey, - rider_name: orders[0]?.rider_name || `Rider ${riderKey}`, - orders - }); - } - }); - } else { - next.zones = [ - { - zone_name: 'Reconciled', - riders: response.riders.map((r) => ({ - rider_id: r.rider_id, - rider_name: r.rider_name || `Rider ${r.rider_id}`, - orders: r.orders || [] - })) - } - ]; - } - - // Rebuild flat details from the updated zones->riders->orders tree. - const flatDetails = []; - next.zones.forEach((zone) => { - (zone.riders || []).forEach((r) => { - (r.orders || []).forEach((o) => { - flatDetails.push({ - ...o, - rider_id: r.rider_id, - userid: r.rider_id, - rider_name: r.rider_name, - rider: r.rider_name - }); - }); - }); - }); - next.details = flatDetails; - - return next; -}; - const Preview = () => { const navigate = useNavigate(); const location = useLocation(); @@ -197,7 +94,7 @@ const Preview = () => { // through this state. The Dispatch tab renders from it, the Reconcile tab // derives its rider list from it, and Assign Orders sends a flattened copy // of it to the API. - const [dispatchPreviewData, setDispatchPreviewData] = useState(stateData.dispatchPreviewData || null); + const [dispatchPreviewData] = useState(stateData.dispatchPreviewData || null); // The AI response arrives via location.state, which the browser stores in // history.state and persists across reloads. That means a reload of @@ -221,34 +118,11 @@ const Preview = () => { document.body.style.overflow = 'hidden'; return () => { document.body.style.overflow = prev; }; }, []); - const [csvExportData, setCsvExportData] = useState([]); + const [, setCsvExportData] = useState([]); const [isLoading, setIsLoading] = useState(false); - const [tabValue, setTabValue] = useState(0); - const [reconcileLoading, setReconcileLoading] = useState(false); - const [hasReconciled, setHasReconciled] = useState(false); - - // Tracks riders whose orders have been edited since the last AI response - // or successful reconcile. Only these are sent to the reconcile API — the - // server-side step re-ordering only needs to see what actually changed. - const [dirtyRiderIds, setDirtyRiderIds] = useState(() => new Set()); - - const aiMode = stateData.aiMode ?? 1; - const selectedMode = stateData.selectedMode || null; - const deliveryData = stateData.deliveryData || []; - const autoRiders = stateData.autoRiders || []; - const absentRidersPayload = stateData.absentRidersPayload || []; const rider = stateData.rider || null; - const appId = useMemo(() => { - if (stateData.appId) return stateData.appId; - if (typeof window !== 'undefined') { - const v = localStorage.getItem('applocationid'); - return v ? Number(v) : 0; - } - return 0; - }, [stateData.appId]); - // Derived: rider list for the Reconcile tab. Recomputes whenever the cache // (dispatchPreviewData) changes — so Reconcile reflects here without a separate state. const reconcileRiders = useMemo(() => extractRiders(dispatchPreviewData), [dispatchPreviewData]); @@ -293,23 +167,6 @@ const Preview = () => { onError: (error) => OpenToast(error.message, 'error', 2000) }); - const createDeliveryMutation = useMutation({ - mutationFn: aiMode == 0 ? createOptimisationDeliveries : createAutomationDeliveries, - onSuccess: (data) => { - OpenToast('Orders Optimised Successfully', 'success', 2000); - // Brand new response = brand new source of truth. - setDispatchPreviewData(data); - setHasReconciled(false); - setDirtyRiderIds(new Set()); - setIsLoading(false); - }, - onError: (error) => { - OpenToast(error.message, 'error', 4000); - setIsLoading(false); - }, - onSettled: () => setIsLoading(false) - }); - const createFinalDeliveryMutation = useMutation({ mutationFn: finalCreatedeliveries, onSuccess: () => { @@ -325,57 +182,6 @@ const Preview = () => { onSettled: () => setIsLoading(false) }); - const reconcileMutation = useMutation({ - mutationFn: reconcileSteps, - onMutate: () => setReconcileLoading(true), - onSuccess: (data) => { - if (Array.isArray(data?.riders)) { - // Merge: applyReconcileResponse replaces orders for riders present - // in the response and leaves the rest of the cache untouched. - setDispatchPreviewData((prev) => applyReconcileResponse(prev, data)); - setHasReconciled(true); - // Clear only the riders we just reconciled from the dirty set, so - // any unrelated edits made meanwhile are preserved. - setDirtyRiderIds((prev) => { - const next = new Set(prev); - data.riders.forEach((r) => next.delete(String(r.rider_id))); - return next; - }); - OpenToast('Steps reconciled — preview updated', 'success', 2000); - } else { - OpenToast('Reconcile returned no rider data', 'warning', 3000); - } - }, - onError: (error) => { - OpenToast(error.message || 'Reconcile failed', 'error', 4000); - }, - onSettled: () => setReconcileLoading(false) - }); - - const handleCreateDelivery = (tune) => { - setIsLoading(true); - if (aiMode == 0) { - createDeliveryMutation.mutate({ deliveries: deliveryData }); - } else if (selectedMode && selectedMode?.value == 1) { - createDeliveryMutation.mutate({ - deliveries: deliveryData, - hypertuning_params: tune || null, - selectedMode, - absent_riders: absentRidersPayload - }); - } else { - createDeliveryMutation.mutate({ - data: { - orders: deliveryData, - riders: autoRiders, - config: { pay_type: 'hourly', base_pay: 300.0, strategy: 'multi_trip' }, - absent_riders: absentRidersPayload - }, - selectedMode - }); - } - }; - const handleFinalCreateDelivery = () => { if (!finaldeliveryList?.length) { OpenToast('No deliveries to assign', 'error', 3000); @@ -385,29 +191,6 @@ const Preview = () => { createFinalDeliveryMutation.mutate({ deliveries: finaldeliveryList }); }; - const handleReconcile = () => { - if (!reconcileRiders.length) { - OpenToast('No riders to reconcile', 'warning', 3000); - return; - } - // Only send riders that were edited since the last AI response / reconcile. - // Their step ordering is the only thing that can be stale — untouched - // riders are skipped to keep the payload small. - const dirty = reconcileRiders.filter((r) => - dirtyRiderIds.has(String(r.rider_id)) - ); - if (!dirty.length) { - OpenToast('No edits to reconcile', 'info', 2500); - return; - } - reconcileMutation.mutate({ - riders: dirty.map((r) => ({ - rider_id: r.rider_id, - orders: r.orders - })) - }); - }; - return (
{ logger.info('previewSelect', location.state); const componentRef = useRef(null); const handlePrint = useReactToPrint({ contentRef: componentRef }); - const [tabletype, settabletype] = useState(true); const [paydialog, setpaydialog] = useState(false); const [refnumber, setRefnumber] = useState(''); const [remarks, setRemarks] = useState(''); diff --git a/src/pages/nearle/locations/ResponsiveLocationDrawer.js b/src/pages/nearle/locations/ResponsiveLocationDrawer.js index 5942a65..47f8918 100644 --- a/src/pages/nearle/locations/ResponsiveLocationDrawer.js +++ b/src/pages/nearle/locations/ResponsiveLocationDrawer.js @@ -66,9 +66,9 @@ const ResponsiveLocationDrawer = () => { const [loading, setLoading] = useState(false); const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(10); - const [pageCount, setPageCount] = React.useState(0); - const [startdate, setStartdate] = useState(dayjs().format('YYYY-MM-DD')); - const [enddate, setEnddate] = useState(dayjs().format('YYYY-MM-DD')); + const [, setPageCount] = React.useState(0); + const [startdate] = useState(dayjs().format('YYYY-MM-DD')); + const [enddate] = useState(dayjs().format('YYYY-MM-DD')); const [searchLocation, setSearchLocation] = useState(''); const [debouncedSearchLocation, setDebouncedSearchLocation] = useState(''); @@ -137,9 +137,7 @@ const ResponsiveLocationDrawer = () => { data: ordersData, fetchNextPage, hasNextPage, - isFetchingNextPage, - isLoading, - error + isFetchingNextPage } = useInfiniteQuery({ queryKey: [ 'orders', diff --git a/src/pages/nearle/orders/OrdersPreview.js b/src/pages/nearle/orders/OrdersPreview.js index 865d176..8609985 100644 --- a/src/pages/nearle/orders/OrdersPreview.js +++ b/src/pages/nearle/orders/OrdersPreview.js @@ -229,14 +229,6 @@ const OrdersPreview = () => { enabled: appId !== 0 // Ensures query runs only when appId is valid }); - const getRiderName = async (userid) => { - await ridersList.map((rider) => { - if (rider.userid == userid) { - return rider.firstname; - } - }); - }; - const paymentOptions = useMemo( () => (paymentModes || []).map((v) => ({ value: String(v.apptypeid), label: v.label })), [paymentModes] diff --git a/src/pages/nearle/orders/createorder1.js b/src/pages/nearle/orders/createorder1.js index 103a8bb..9481b44 100644 --- a/src/pages/nearle/orders/createorder1.js +++ b/src/pages/nearle/orders/createorder1.js @@ -11,7 +11,6 @@ import { FaLocationDot } from 'react-icons/fa6'; import axios from 'axios'; import Geocode from 'react-geocode'; import Loader from 'components/Loader'; -import * as geolib from 'geolib'; import { FaUser } from 'react-icons/fa6'; import dayjs from 'dayjs'; import { enqueueSnackbar } from 'notistack'; @@ -58,10 +57,10 @@ import { // ============================================================================ // Plain-CSS layout shims — Astryx has no Grid/Stack/Box/Typography/Paper -// equivalents, so these small local helpers (not @mui) stand in for the MUI +// equivalents, so these small local helpers stand in for the // layout primitives previously used here, translating the same `sx`-shaped // spacing shorthand (p/m/gap/borderRadius are ×8px steps, bgcolor→ -// backgroundColor) into real inline CSS. MUI pseudo-selector keys (e.g. +// backgroundColor) into real inline CSS. Pseudo-selector keys (e.g. // `'&:hover'`) are not representable inline and are dropped. // ============================================================================ const SPACING_KEYS = { @@ -321,37 +320,13 @@ function loadScript(src, position, id) { const Createorder1 = () => { Geocode.setApiKey(process.env.REACT_APP_GOOGLE_MAPS_API_KEY); // ================================================= || GoogleMaps (Drawer) || ================================================= - const [value, setValue] = React.useState(null); - const [value1, setValue1] = React.useState(null); - const [inputValue, setInputValue] = React.useState(''); - const [inputValue1, setInputValue1] = React.useState(''); + const [, setValue] = React.useState(null); + const [, setValue1] = React.useState(null); const [inputValue2, setInputValue2] = React.useState(''); const [inputValue3, setInputValue3] = React.useState(''); - const [options, setOptions] = React.useState([]); - const [options1, setOptions1] = React.useState([]); const loaded = React.useRef(false); - const loaded1 = React.useRef(false); - const [mobilenumber, setMobilenumber] = useState(''); - const [emailaddress, setEmailaddress] = useState(''); - const [city, setCity] = useState(''); - const [city1, setCity1] = useState(''); - const [zipcode, setZipcode] = useState(''); - const [zipcode1, setZipcode1] = useState(''); - const [state, setState] = useState(''); - const [state1, setState1] = useState(''); - const [suburb, setSuburb] = useState(''); - const [suburb1, setSuburb1] = useState(''); - const [pickContactName, setPickContactName] = useState(''); - const [dropContactName, setDropContactName] = useState(''); - const [pickdoorno, setPickDoorno] = useState(''); - const [dropDoorno, setDropDoorno] = useState(''); - const [pickLandmark, setPickLandmark] = useState(''); - const [dropLandmark, setDropLandmark] = useState(''); - const [address, setAddress] = useState(''); - const [address1, setAddress1] = useState(''); - const [latlong, setLatlong] = useState({}); - const [latlong1, setLatlong1] = useState({}); - const autocompleteService = useRef(null); + const [, setAddress] = useState(''); + const [, setAddress1] = useState(''); const [tenanatLocoId, setTenanatLocoId] = useState(localStorage.getItem('locationid')); const [isLocation, setIsLocation] = useState(false); const textFieldRef1 = useRef(null); @@ -359,28 +334,6 @@ const Createorder1 = () => { const [collectionamt, setCollectionamt] = useState(0); const [quantity, setQuantity] = useState(1); - const handleOkClick1 = () => { - // Set focus back to the text field after clicking the "OK" chip - if (textFieldRef1.current) { - textFieldRef1.current.focus(); - } - }; - - const handleOkClick2 = () => { - // Set focus back to the text field after clicking the "OK" chip - if (textFieldRef2.current) { - textFieldRef2.current.focus(); - } - }; - - const top100Films = [ - { label: 'The Shawshank Redemption', year: 1994 }, - { label: 'The Godfather', year: 1972 }, - { label: 'The Godfather: Part II', year: 1974 }, - { label: 'The Dark Knight', year: 2008 }, - { label: '12 Angry Men', year: 1957 } - ]; - // // // ====================================================== || address (pick)|| ====================================================== // useEffect(() => { // if (address) { @@ -603,52 +556,28 @@ const Createorder1 = () => { const appId = localStorage.getItem('applocationid'); const navigate = useNavigate(); - const [open, setOpen] = useState({}); - const [open1, setOpen1] = useState(''); - const [open2, setOpen2] = useState(false); - const [open3, setOpen3] = useState(false); const [open4, setOpen4] = useState(false); - const [shift, setShift] = useState(1); - const [clientlist, setClientlist] = useState([]); const [clientdetail, setClientdetail] = useState([]); - const [eventname, setEventname] = useState(''); const [startdate, setStartdate] = useState(dayjs().format('MM-DD-YYYY')); - const [enddate, setEnddate] = useState(dayjs().add(1, 'day').format('MM-DD-YYYY')); + const [, setEnddate] = useState(dayjs().add(1, 'day').format('MM-DD-YYYY')); // const [starttime, setStatrttime] = useState(`${dayjs().format('MM-DD-YYYY')} 08:00:00`); const [starttime, setStatrttime] = useState(); // const [endtime, setEndtime] = useState(`${dayjs().format('MM-DD-YYYY')} 20:00:00`); const [endtime, setEndtime] = useState(); const [timeslotarr, setTimeslotarr] = useState([]); - const [currentsno, setCurrentsno] = useState(''); - const [roleoptions, setRoleoptions] = useState([]); const [otherinstructions, setOtherinstructions] = useState(''); - const [attireslist, setAttireslist] = useState([]); - const [serviceaddonslist, setServiceaddonslist] = useState([]); - const [orderaddonobj, setOrderaddonobj] = useState([]); - const [stafflist, setStafflist] = useState([]); - const [loading2, setLoading2] = useState(false); + const [, setLoading2] = useState(false); const [loading, setLoading] = useState(false); const [btnLoading, setBtnLoading] = useState(false); - const [shiftarr, setShiftarr] = useState([]); - const [shiftarr1, setShiftarr1] = useState([]); - const [orderarr, setOrderarr] = useState([]); + const [shiftarr] = useState([]); + const [, setOrderarr] = useState([]); const [alertmessage, setAlertmessage] = useState(''); - const [tabstatus, setTabstatus] = useState(''); - const [tenantinfo, setTenantinfo] = useState({}); - const [searchword, setSearchword] = useState(''); - const [clientdetailarr, setClientdetailarr] = useState([]); - const [clientdetailbusinessarr, setClientdetailbusinessarr] = useState([]); + const [searchword] = useState(''); + const [, setClientdetailarr] = useState([]); const [admintoken, setAdmintoken] = useState(); - const [tenantlocationlist, setTenantlocationlist] = useState([]); const [tenant, setTenant] = useState({}); - const [clientinfo, setClientinfo] = useState({}); const [selectedtime, setSelectedtime] = useState(''); - const [tenantlist, setTenantlist] = useState([]); - const [tenantid, setTenantid] = useState(); - const [tenantlocation, setTenantlocation] = useState(''); - const [pickupswitch, setPickupswitch] = useState(true); - const [deliverytype, setDeliverytype] = useState('B'); - const [dropswitch, setDropswitch] = useState(false); + const [, setTenantid] = useState(); const [startPoint, setStartPoint] = useState({ latitude: 0, longitude: 0 }); const [endPoint, setEndPoint] = useState({ latitude: 0, longitude: 0 }); const [showDistance, setShowDistance] = useState(false); @@ -660,7 +589,7 @@ const Createorder1 = () => { const [subCat, setSubCat] = useState([]); const [subCatName, setSubCatName] = useState('Select '); const [subCatId, setSubCatId] = useState(); - const [weight, setWeight] = useState(''); + const [, setWeight] = useState(''); const tid = localStorage.getItem('tenantid'); const [selectedCatChip, setSelectedCatChip] = useState(null); const [isCustomerOpen, setIsCustomerOpen] = useState(false); @@ -717,26 +646,6 @@ const Createorder1 = () => { } }, [startPoint, endPoint]); - const getDistance = () => { - const dist = geolib.getPreciseDistance(startPoint, endPoint, 1); - logger.info(`Distance: ${dist} meters`); - const distanceInKm = (dist / 1000).toFixed(2); - const roundedDistance = Math.round(distanceInKm); - logger.info('roundedDistance', roundedDistance); - setDistance(roundedDistance.toFixed(2)); - if (roundedDistance < minKm) { - setTotalCharge(basePrice); - } else { - const total = (roundedDistance - minKm) * pricePerKm + basePrice; - setTotalCharge(total); - } - setShowDistance(true); - if (roundedDistance > appLocaRadius) { - setShowDistance(true); - setOpen4(true); - } - }; - const calculateDistance = async (pickup, drop) => { try { const roundedDistance = await calculateDrivingDistance(pickup, drop); @@ -904,9 +813,9 @@ const Createorder1 = () => { logger.info('endtime', `${dayjs().format('MM-DD-YYYY')} ${closetime} `); let arr = []; for ( - let i = `${dayjs().format('MM-DD-YYYY')} ${opentime}`, j = 0; + let i = `${dayjs().format('MM-DD-YYYY')} ${opentime}`; dayjs(`${dayjs().format('MM-DD-YYYY')} ${closetime} `).diff(i, 'm') >= 0; - j++, i = dayjs(i).add(30, 'm') + i = dayjs(i).add(30, 'm') ) { arr.push(i); } @@ -961,14 +870,6 @@ const Createorder1 = () => { logger.info(alertmessage); }; - function closeAddressModal() { - setOpen2(false); - } - function closetimemodal() { - setOpen3(false); - setCurrentsno(''); - } - // =============================================== || createsubmitobj1 (create orders) || =============================================== const createsubmitobj2 = async () => { @@ -1149,17 +1050,6 @@ const Createorder1 = () => { logger.info(shiftarr); }, [shiftarr]); - const clicked1 = (e) => { - setShift(e); - }; - - const dialogopen = (i, result) => { - logger.info(i, result); - setOpen({ shiftsno: result.sno, sno: i.sno }); - }; - const dialogclose = () => { - setOpen(''); - }; // ========================================================= || clientdetails || ========================================================= const clientdetails = async () => { setLoading2(true); @@ -1207,78 +1097,6 @@ const Createorder1 = () => { clientdetails(); // clientdetailsbusiness(); }, [searchCustList.length > 3, searchCustList == '']); - // ========================================================= || clientdetailsbusiness || ========================================================= - const clientdetailsbusiness = async () => { - setLoading2(true); - try { - await axios - .get(`${process.env.REACT_APP_URL}/customers/getbytid/?tenantid=${tid}&locationid=1`) - .then((res) => { - logger.info('clientdetailsbusiness', res.data.details); - if (res.data.status) { - setClientdetail(res.data.details); - // if (!searchword) { - // setClientdetailarr(res.data.details) - // } - let arr = []; - res.data.details.map((val) => { - arr.push({ - label: `${val.firstname} | ${val.contactno}`, - ...val - }); - }); - setClientdetailbusinessarr(arr); - } - setLoading2(false); - }) - .catch((err) => { - logger.error(err); - setLoading2(false); - opentoast('server error', 'warning'); - }); - } catch (err) { - logger.error(err); - setLoading2(false); - } - }; - - // ================================================== || sendnotifications || ================================================== - const sendnotifications = async () => { - setLoading(true); - await axios - .post(`${process.env.REACT_APP_URL}/utils/sendnotifications`, { - priority: 'high', - registration_ids: admintoken, - data: { - accessid: process.env.REACT_APP_RIDER_ACCESS_ID - }, - notification: { - title: 'Nearle Merchant', - body: 'An Order has been placed successfully,kindly process the same', - sound: 'ring' - } - }) - .then((res) => { - logger.info(res); - if (res.data.message == 'Success') { - enqueueSnackbar('Notification sent Successfully', { - variant: 'success', - anchorOrigin: { vertical: 'top', horizontal: 'right' }, - autoHideDuration: 1000 - }); - } - setLoading(false); - }) - .catch((err) => { - logger.error(err); - enqueueSnackbar(err.message, { - variant: 'error', - anchorOrigin: { vertical: 'top', horizontal: 'right' }, - autoHideDuration: 1000 - }); - setLoading(false); - }); - }; // ============================================= || Google Maps Autocomplete(pick) || ============================================= useEffect(() => { // Initialize Google Maps Autocomplete @@ -1294,7 +1112,6 @@ const Createorder1 = () => { radius: appLocaRadius * 1000 }).getBounds() }); - let arr = []; // Event listener for autocomplete place changed autocomplete.addListener('place_changed', () => { const place = autocomplete.getPlace(); @@ -1380,7 +1197,6 @@ const Createorder1 = () => { // radius: 100000 //km to m }).getBounds() }); - let arr = []; // Event listener for autocomplete place changed autocomplete.addListener('place_changed', () => { const place = autocomplete.getPlace(); diff --git a/src/pages/nearle/orders/details.js b/src/pages/nearle/orders/details.js index e9465f0..a7f1b71 100644 --- a/src/pages/nearle/orders/details.js +++ b/src/pages/nearle/orders/details.js @@ -241,7 +241,7 @@ const Details = () => { const [tenantaddress, setTenantaddress] = useState(''); const [dialogopen, setDialogopen] = useState(false); const [orderstatus, setOrderstatus] = useState(''); - const [currentrole, setCurrentrole] = useState(''); + const [currentrole] = useState(''); const [taxamount, setTaxamount] = useState(''); const [subtotal, setSubtotal] = useState(''); const [grandtotal, setGrandtotal] = useState(''); @@ -253,13 +253,13 @@ const Details = () => { const [staffarr, setStaffarr] = useState([]); const [orderheaderid, setOrderheaderid] = useState(''); const [tenantid, setTenantid] = useState(''); - const [starttime, setStarttime] = useState(''); - const [endtime, setEndtime] = useState(''); + const [starttime] = useState(''); + const [endtime] = useState(''); // const [orderstatus,setOrderstatus]=useStatus(''); const [pendingtime, setPendingtime] = useState(''); // const [processdate,setProcessdate]=useState(''); - const [orderdetailid, setOrderdetailid] = useState(''); - const [productid, setProductid] = useState(''); + const [orderdetailid] = useState(''); + const [productid] = useState(''); const [categoryarr, setcategoryarr] = useState([]) const [currentshiftobj, setCurrentshiftobj] = useState({ shifts: 0, @@ -268,7 +268,7 @@ const Details = () => { shiftid: 0, price: 0 }); - const [tabstatus, setTabstatus] = useState(0) + const [, setTabstatus] = useState(0) const { state } = useLocation(); const [assignedpendingcount, setAssignedpendingcount] = useState(''); // const [, forceUpdate] = useReducer(x => x + 1, 0); @@ -409,48 +409,6 @@ const Details = () => { }); } - const fetchroleslist = async (cid, starttime1, endtime1, hid, sid) => { - let fromdate = dayjs(starttime1).subtract(59, 'minutes') - .format('YYYY-MM-DD HH:mm:ss'); - // let todate = dayjs(endtime1).utc().format('YYYY-MM-DD HH:mm:ss'); - // let fromdate = dayjs(starttime1).utc().format('YYYY-MM-DD HH:mm:ss'); - let todate = dayjs(endtime1) - .format('YYYY-MM-DD HH:mm:ss'); - let url1; - if (starttime1) { - url1 = `${process.env.REACT_APP_URL2}/staffs/pools/getstaffs/?categoryid=${cid}&headerid=${hid}&shiftid=${sid}&starttime=${fromdate}&endtime=${todate}`; - } else { - url1 = `${process.env.REACT_APP_URL2}/staffs/pools/getstaffs/?categoryid=${cid}&headerid=${hid}&shiftid=${sid}` - } - setLoading(true); - setStafflist([]) - await axios - // .get(`${process.env.REACT_APP_URL2}/staffs/pools/getstaffs/?categoryid=${cid}&headerid=${hid}&starttime=${fromdate}&endtime=${todate}`) - .get(url1) - .then((res) => { - logger.info('rolelist'); - logger.info(res); - // logger.info(fromdate, todate) - // logger.info(dayjs(starttime1).format('YYYY-MM-DD HH:mm:ss')) - // logger.info(dayjs(endtime1).format('HH:mm:ss')) - - - setStafflist(res.data.Details || []) - // let result = res.data.Details.find((res1) => res1.orderheaderid == searchParams.get('id')) - // orderheaderid - // logger.info(result) - // setOrderaddons(result.orderaddons); - // setVenuetype(result.venuetype) - // setOtherinstructions(result.remarks) - setLoading(false); - }) - .catch((err) => { - logger.error(err); - setLoading(false); - }); - } - - const fetchstafflist = async (odid) => { setLoading(true) try { @@ -789,88 +747,6 @@ const Details = () => { } - const fetchassignedstaffs = async () => { - - // logger.info(obj1) - await axios.get(`${process.env.REACT_APP_URL2}/orders/getnotificationusers?orderheaderid=${orderheaderid}`) - .then((res) => { - if (res.data.status) { - let arr1 = []; - let data2; - let tokenarr = [] - logger.info(res) - - res.data.details.map((val) => { - arr1.push({ - "notificationid": 0, - "notificationdate": dayjs().format('YYYY-MM-DD HH:mm:ss'), - "Title": "Staff Asigned", - "message": `${val.staffname} has been assigned to the order ${orderid}`, - "configid": 2, - "tenantid": tenantid, - "orderheaderid": orderheaderid, - "orderprocessid": val.orderprocessid, - "shiftid": val.shiftid, - "userid": val.userid, - "orderid": orderid, - "success": 0, - "orderstatus": 'assigned', - "processing": dayjs().format('YYYY-MM-DD HH:mm:ss'), - "notifytype": 1, - "notifyreason": 'Staff Assigned' - // "sound": "ring", - // "click_action": "FLUTTER_NOTIFICATION_CLICK", - // "firstname": val.firstname - - }); - tokenarr.push(val.userfcmtoken); - - }) - - - - data2 = { - "Title": "Staff Asigned", - "message": `A Staff has been assigned to the order ${orderid}`, - "tenantid": tenantid, - "orderheaderid": orderheaderid, - "orderid": orderid, - "configid": 2, - // "click_action": "FLUTTER_NOTIFICATION_CLICK" - } - let fcmmodel = { - "priority": "high", - "registration_ids": tokenarr, - "data": data2, - "notification": { - "body": `An order has been assigned ${orderid}`, - "title": "Legendary", - "sound": "ring", - "content_available": true, - "click_action": "FLUTTER_NOTIFICATION_CLICK" - } - } - let grpnotifyobj = { - "notifications": arr1, - "fcmmodel": fcmmodel - } - logger.info("grpnotifyobj") - logger.info(grpnotifyobj) - sendgroupnotification(grpnotifyobj) - // notificationpush(obj2, val.userfcmtoken); - // notificationpush(arr1,tokenarr); - // enqueueSnackbar('Notifications sent successfully', { - // variant: 'success', anchorOrigin: { vertical: 'top', horizontal: 'right' }, - // autoHideDuration: 2000 - // }) - } - }) - .catch((err) => { - logger.error(err) - }) - - } - const sendgroupnotification = async (obj1) => { logger.info(obj1) diff --git a/src/pages/nearle/orders/multipleOrders.js b/src/pages/nearle/orders/multipleOrders.js index f0d14a2..01b713f 100644 --- a/src/pages/nearle/orders/multipleOrders.js +++ b/src/pages/nearle/orders/multipleOrders.js @@ -256,7 +256,7 @@ const MultipleOrders = () => { const tenantid = localStorage.getItem('tenantid'); // ============================== state ============================== - const [locations, setLocations] = useState([]); + const [, setLocations] = useState([]); const [tenantLocations, setTenantlocations] = useState([]); const [loading, setLoading] = useState(false); const [btnLoading, setBtnLoading] = useState(false); diff --git a/src/pages/nearle/orders/orders.js b/src/pages/nearle/orders/orders.js index a86a4fd..22e5992 100644 --- a/src/pages/nearle/orders/orders.js +++ b/src/pages/nearle/orders/orders.js @@ -30,7 +30,7 @@ import { useHotkeyFocus } from 'components/nearle_components/useHotkeyFocus'; import DateFilterDialog from 'components/nearle_components/DateFilterDialog'; import CircularLoader from 'components/nearle_components/CircularLoader'; import { useQuery, useMutation, useInfiniteQuery } from '@tanstack/react-query'; -import { useNavigate, useLocation } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import logger from 'utils/logger'; import { fetchPercentageData, @@ -141,7 +141,6 @@ const scrollbarStyle = ` const Orders = () => { const navigate = useNavigate(); - const location = useLocation(); const tid = localStorage.getItem('tenantid'); const loadMoreRef = useRef(); const containerRef = useRef(); @@ -162,7 +161,6 @@ const Orders = () => { const [debouncedSearch, setDebouncedSearch] = useState(''); // Floating button and Dialog states - const [speedDialOpen, setSpeedDialOpen] = useState(false); const [multiDeleteDialog, setMultiDeleteDialog] = useState(false); const [createloader, setCreateloader] = useState(false); const [isLoading, setIsLoading] = useState(false); @@ -190,7 +188,6 @@ const Orders = () => { // React Queries const { - data: percentageData, isLoading: fetchpercentageIsLoading, refetch: percentagedataRefetch } = useQuery({ @@ -378,12 +375,6 @@ const Orders = () => { }); }; - // KPI tile definitions. - const kpiCards = [ - { key: 'created', label: 'Created Orders', color: BRAND, icon: MdLocalShipping, value: percentageData?.created, percentage: percentageData?.percentage1 }, - { key: 'pending', label: 'Pending Orders', color: '#f59e0b', icon: MdHourglassEmpty, value: percentageData?.uncoveredOrders, percentage: percentageData?.percentage2 } - ]; - return ( @@ -648,17 +639,6 @@ const Orders = () => { )} {rows.map((row, index) => { - const isItemSelected = !!deliverylist.find((res) => res.orderheaderid === row.orderheaderid); - const handleCheckbox = (e) => { - if (e.target.checked) { - setDeliverylist((prev) => [...prev, { ...row, sno: prev.length + 1 }]); - } else { - setDeliverylist((prev) => - prev.filter((item) => item.orderheaderid !== row.orderheaderid).map((item, i) => ({ ...item, sno: i + 1 })) - ); - } - }; - return ( diff --git a/src/pages/nearle/reports/orderSummary.js b/src/pages/nearle/reports/orderSummary.js index 65254fc..d02caa1 100644 --- a/src/pages/nearle/reports/orderSummary.js +++ b/src/pages/nearle/reports/orderSummary.js @@ -122,7 +122,7 @@ export default function OrdersReport() { const [enddate, setEnddate] = useState(dayjs().format('YYYY-MM-DD')); const [openRow, setOpenRow] = useState(null); const [datestatus, setDatestatus] = useState('Today'); - const [total, settotal] = useState(0); + const [, settotal] = useState(0); const [totalOrders, settotalOrders] = useState(0); const [totalOrderPend, setTotalOrderPend] = useState(0); const [totalOrderComplete, setTotalOrderComplete] = useState(0); diff --git a/src/pages/nearle/reports/ordersDetails.js b/src/pages/nearle/reports/ordersDetails.js index 5bab123..dc5dd13 100644 --- a/src/pages/nearle/reports/ordersDetails.js +++ b/src/pages/nearle/reports/ordersDetails.js @@ -256,8 +256,8 @@ export default function OrdersDetails() { const [startdate, setStartdate] = useState(dayjs().format('YYYY-MM-DD')); const [enddate, setEnddate] = useState(dayjs().format('YYYY-MM-DD')); const [datestatus, setDatestatus] = useState('Today'); - const [totalCharge, settotalCharge] = useState(0); - const [totalAmount, settotalAmount] = useState(0); + const [, settotalCharge] = useState(0); + const [, settotalAmount] = useState(0); const [searchword, setSearchword] = useState(''); // Density toggle — operators choose how many rows to surface per screen. diff --git a/src/routes/MainRoutes.js b/src/routes/MainRoutes.js index 7440539..6a129d6 100644 --- a/src/routes/MainRoutes.js +++ b/src/routes/MainRoutes.js @@ -4,8 +4,6 @@ import { lazy } from 'react'; import MainLayout from 'layout/MainLayout'; import CommonLayout from 'layout/CommonLayout'; import Loadable from 'components/Loadable'; -import AuthGuard from 'utils/route-guard/AuthGuard'; -import { element } from 'prop-types'; // pages routing const MaintenanceError = Loadable(lazy(() => import('pages/maintenance/404'))); @@ -13,8 +11,6 @@ const MaintenanceError500 = Loadable(lazy(() => import('pages/maintenance/500')) const MaintenanceUnderConstruction = Loadable(lazy(() => import('pages/maintenance/under-construction'))); const MaintenanceComingSoon = Loadable(lazy(() => import('pages/maintenance/coming-soon'))); -// render - sample page -const SamplePage = Loadable(lazy(() => import('pages/extra-pages/sample-page'))); const Login = Loadable(lazy(() => import('pages/nearle/login'))); const Customers = Loadable(lazy(() => import('pages/nearle/clients/customers')));