From b8f1cd5f1d9f346ed50c10f420d3a7344441edb0 Mon Sep 17 00:00:00 2001 From: Suriya Date: Wed, 8 Jul 2026 17:54:36 +0530 Subject: [PATCH] fix: point customers page at /admin/customers instead of legacy path getallcustomers/getcustomersummary still called the old /customers/getallcustomers and /customers/getcustomersummary paths, which 403 on api.doormile.com (auth was accepted, route wasn't valid). Repointed both at /admin/customers per the original conversion plan. No Doormile customer response shape has been confirmed anywhere in this work (unlike bookings/clients/milers, which had example shapes given up front) -- field names in customers.js (firstname/contactno/address/ customerid/etc) are still the old NearlExpress shape and left as-is rather than guessed. Won't crash, just shows blanks for any field that doesn't exist on a real Doormile customer. Need the actual response body to do a real field-mapping pass, same as the login.js episode. updateCustomer (PUT /customers/update) is still unmapped -- flagged in a comment rather than guessed at, consistent with cancelOrder. --- src/pages/api/api.js | 44 +++++++++++++++---------- src/pages/nearle/customers/customers.js | 3 ++ 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/pages/api/api.js b/src/pages/api/api.js index 9c17ba1..e37aa4f 100644 --- a/src/pages/api/api.js +++ b/src/pages/api/api.js @@ -491,37 +491,45 @@ export const getallpricing = async ({ queryKey }) => { }; // ==============================|| getcustomersummary (customers) ||============================== // - -export const getcustomersummary = async ({ queryKey }) => { - const [, appId] = queryKey; +// No dedicated Doormile summary endpoint has been specified for customers — +// derives the count from the same /admin/customers list used below. +export const getcustomersummary = async () => { try { - const response = await axios.get(`${process.env.REACT_APP_URL}/customers/getcustomersummary?applocationid=${appId}`); - return response.data.summary; + const response = await axios.get(`${process.env.REACT_APP_URL}/admin/customers`); + const customers = response.data?.data || []; + return { Total: customers.length }; } catch (err) { const message = err.response?.data?.message || err.message || 'Something went wrong'; OpenToast(message); - return null; // return null for failure + return null; } }; // ==============================|| getallcustomers (customers) ||============================== // - +// NOTE: field names below (firstname/contactno/address/suburb/customerid/...) +// are still the old NearlExpress shape — no Doormile customer response shape +// has been confirmed yet. Fetches from the real endpoint; the UI will just +// show blanks for any field that doesn't exist on a Doormile customer until +// the actual shape is confirmed and this gets a proper field-mapping pass. export const getallcustomers = async ({ pageParam = 1, queryKey }) => { - const [, appId, debouncedSearch, rowsPerPage] = queryKey; + const [, , debouncedSearch, rowsPerPage] = queryKey; try { - const response = await axios.get(`${process.env.REACT_APP_URL}/customers/getallcustomers/`, { - params: { - applocationid: appId, - keyword: debouncedSearch, - pageno: pageParam, - pagesize: rowsPerPage - } - }); + const response = await axios.get(`${process.env.REACT_APP_URL}/admin/customers`); + let customers = response.data?.data || []; + if (debouncedSearch) { + const kw = debouncedSearch.toLowerCase(); + customers = customers.filter( + (c) => (c.firstname || c.name || '').toLowerCase().includes(kw) || (c.contactno || c.phone || '').includes(debouncedSearch) + ); + } + + // No documented pagination on /admin/customers — return everything as a + // single page rather than guess at pageno/pagesize semantics. return { - data: response.data.details || [], - nextPage: response.data.details?.length === rowsPerPage ? pageParam + 1 : undefined + data: pageParam === 1 ? customers : [], + nextPage: undefined }; } catch (err) { const message = err.response?.data?.message || err.message || 'Something went wrong'; diff --git a/src/pages/nearle/customers/customers.js b/src/pages/nearle/customers/customers.js index 0f0cc18..d3ef6f2 100644 --- a/src/pages/nearle/customers/customers.js +++ b/src/pages/nearle/customers/customers.js @@ -352,6 +352,9 @@ export default function Customers() { OpenToast('Enter Longitude', 'warning', 1500); } else { try { + // NOTE: no Doormile "update customer" endpoint has been specified — + // this still calls the old /customers/update path and will fail + // against api.doormile.com. Left as-is rather than guessed at. const postUpdateResponse = await axios.put(`${process.env.REACT_APP_URL}/customers/update`, { customerid: selectedCustomer.customerid, configid: 1,