updates on the api integration and the design changes on the whole website
This commit is contained in:
@@ -168,7 +168,8 @@ const emptyForm = {
|
||||
priceperkm: '',
|
||||
handlingcharges: '',
|
||||
priority: 1,
|
||||
status: 'active'
|
||||
// Confirmed live: matches every real pricing row's casing ("Active").
|
||||
status: 'Active'
|
||||
};
|
||||
|
||||
// ==============================|| Pricing page ||============================== //
|
||||
@@ -207,24 +208,30 @@ const ClientsPricing = () => {
|
||||
const zoneName = (row) =>
|
||||
row.applocation || locationMap.get(row.applocationid)?.locationname || (row.applocationid ? `Zone #${row.applocationid}` : '—');
|
||||
|
||||
// getallpricing() takes no zone arg (see api.js) — the LocationAutocomplete
|
||||
// only ever changed the header subtitle text, not which rows were shown.
|
||||
// Filter client-side instead; pricing rows already carry applocationid
|
||||
// (used by zoneName above), so this is the same real field, just applied.
|
||||
const zonePricing = useMemo(() => (appId ? pricing.filter((r) => r.applocationid === appId) : pricing), [pricing, appId]);
|
||||
|
||||
const rows = useMemo(() => {
|
||||
if (!debouncedSearch) return pricing;
|
||||
if (!debouncedSearch) return zonePricing;
|
||||
const q = debouncedSearch.toLowerCase().trim();
|
||||
return pricing.filter((row) =>
|
||||
return zonePricing.filter((row) =>
|
||||
[tenantName(row), row.vehicletype, zoneName(row), String(row.pricingid)]
|
||||
.filter(Boolean)
|
||||
.some((field) => String(field).toLowerCase().includes(q))
|
||||
);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [pricing, debouncedSearch, tenantMap, locationMap]);
|
||||
}, [zonePricing, debouncedSearch, tenantMap, locationMap]);
|
||||
|
||||
const stats = useMemo(() => {
|
||||
const total = pricing.length;
|
||||
const tenantsPriced = new Set(pricing.map((r) => r.tenantid).filter(Boolean)).size;
|
||||
const avgBase = total ? pricing.reduce((sum, r) => sum + (Number(r.baseprice) || 0), 0) / total : 0;
|
||||
const activeCount = pricing.filter((r) => String(r.status).toLowerCase() === 'active').length;
|
||||
const total = zonePricing.length;
|
||||
const tenantsPriced = new Set(zonePricing.map((r) => r.tenantid).filter(Boolean)).size;
|
||||
const avgBase = total ? zonePricing.reduce((sum, r) => sum + (Number(r.baseprice) || 0), 0) / total : 0;
|
||||
const activeCount = zonePricing.filter((r) => String(r.status).toLowerCase() === 'active').length;
|
||||
return { total, tenantsPriced, avgBase, activeCount };
|
||||
}, [pricing]);
|
||||
}, [zonePricing]);
|
||||
|
||||
const KPI_META = [
|
||||
{ key: 'total', label: 'Total Pricing Rules', color: BRAND, icon: MdOutlineLocalOffer, value: stats.total },
|
||||
@@ -305,7 +312,7 @@ const ClientsPricing = () => {
|
||||
priceperkm: row.priceperkm ?? '',
|
||||
handlingcharges: row.handlingcharges ?? '',
|
||||
priority: row.priority ?? 1,
|
||||
status: row.status || 'active'
|
||||
status: row.status || 'Active'
|
||||
});
|
||||
setDialogOpen(true);
|
||||
};
|
||||
@@ -326,6 +333,8 @@ const ClientsPricing = () => {
|
||||
return;
|
||||
}
|
||||
// POST/PUT /admin/pricing body per express-console-api.md.
|
||||
// effectivefrom is required and confirmed live to reject a bare
|
||||
// YYYY-MM-DD date ("invalid request body") — needs a full ISO datetime.
|
||||
const data = {
|
||||
tenantid: form.tenant.tenantid,
|
||||
applocationid: form.location?.applocationid,
|
||||
@@ -336,6 +345,7 @@ const ClientsPricing = () => {
|
||||
basedistance: Number(form.basedistance) || 0,
|
||||
priceperkm: Number(form.priceperkm),
|
||||
handlingcharges: Number(form.handlingcharges) || 0,
|
||||
effectivefrom: new Date().toISOString(),
|
||||
currency: 'INR',
|
||||
priority: Number(form.priority) || 1,
|
||||
status: form.status
|
||||
@@ -765,8 +775,8 @@ const ClientsPricing = () => {
|
||||
<Stack spacing={1}>
|
||||
<InputLabel>Status</InputLabel>
|
||||
<Select fullWidth value={form.status} onChange={(e) => setForm((f) => ({ ...f, status: e.target.value }))}>
|
||||
<MenuItem value="active">Active</MenuItem>
|
||||
<MenuItem value="inactive">Inactive</MenuItem>
|
||||
<MenuItem value="Active">Active</MenuItem>
|
||||
<MenuItem value="Inactive">Inactive</MenuItem>
|
||||
</Select>
|
||||
</Stack>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user