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.
This commit is contained in:
2026-07-08 17:54:36 +05:30
parent 283c24942d
commit b8f1cd5f1d
2 changed files with 29 additions and 18 deletions

View File

@@ -491,37 +491,45 @@ export const getallpricing = async ({ queryKey }) => {
}; };
// ==============================|| getcustomersummary (customers) ||============================== // // ==============================|| getcustomersummary (customers) ||============================== //
// No dedicated Doormile summary endpoint has been specified for customers —
export const getcustomersummary = async ({ queryKey }) => { // derives the count from the same /admin/customers list used below.
const [, appId] = queryKey; export const getcustomersummary = async () => {
try { try {
const response = await axios.get(`${process.env.REACT_APP_URL}/customers/getcustomersummary?applocationid=${appId}`); const response = await axios.get(`${process.env.REACT_APP_URL}/admin/customers`);
return response.data.summary; const customers = response.data?.data || [];
return { Total: customers.length };
} catch (err) { } catch (err) {
const message = err.response?.data?.message || err.message || 'Something went wrong'; const message = err.response?.data?.message || err.message || 'Something went wrong';
OpenToast(message); OpenToast(message);
return null; // return null for failure return null;
} }
}; };
// ==============================|| getallcustomers (customers) ||============================== // // ==============================|| 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 }) => { export const getallcustomers = async ({ pageParam = 1, queryKey }) => {
const [, appId, debouncedSearch, rowsPerPage] = queryKey; const [, , debouncedSearch, rowsPerPage] = queryKey;
try { try {
const response = await axios.get(`${process.env.REACT_APP_URL}/customers/getallcustomers/`, { const response = await axios.get(`${process.env.REACT_APP_URL}/admin/customers`);
params: { let customers = response.data?.data || [];
applocationid: appId,
keyword: debouncedSearch,
pageno: pageParam,
pagesize: rowsPerPage
}
});
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 { return {
data: response.data.details || [], data: pageParam === 1 ? customers : [],
nextPage: response.data.details?.length === rowsPerPage ? pageParam + 1 : undefined nextPage: undefined
}; };
} catch (err) { } catch (err) {
const message = err.response?.data?.message || err.message || 'Something went wrong'; const message = err.response?.data?.message || err.message || 'Something went wrong';

View File

@@ -352,6 +352,9 @@ export default function Customers() {
OpenToast('Enter Longitude', 'warning', 1500); OpenToast('Enter Longitude', 'warning', 1500);
} else { } else {
try { 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`, { const postUpdateResponse = await axios.put(`${process.env.REACT_APP_URL}/customers/update`, {
customerid: selectedCustomer.customerid, customerid: selectedCustomer.customerid,
configid: 1, configid: 1,