From 0d5edf94bfb7fc2ca6d84d84ffe6454f576051a2 Mon Sep 17 00:00:00 2001 From: dharaneesh-r Date: Wed, 7 Oct 2026 12:06:49 +0530 Subject: [PATCH] updates on the pricing page and navbar updates --- src/layouts/AdminLayout.jsx | 3 ++ src/pages/doormile/pricing/Pricing.jsx | 39 +++++++++++++++++--------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/layouts/AdminLayout.jsx b/src/layouts/AdminLayout.jsx index 1351112..2726c06 100644 --- a/src/layouts/AdminLayout.jsx +++ b/src/layouts/AdminLayout.jsx @@ -56,6 +56,9 @@ const NAV = [ { label: 'Deliveries', path: '/doormile/deliveries' }, { label: 'Milers', path: '/doormile/milers' }, { label: 'Clients', path: '/doormile/tenants' }, + // Staff manage every client's rate card here; a client login sees its own, + // read-only (the server scopes the list and refuses a client's changes). + { label: 'Pricing', path: '/doormile/pricing' }, ]; /** Destinations grouped behind a menu, in the order the console lists them. */ diff --git a/src/pages/doormile/pricing/Pricing.jsx b/src/pages/doormile/pricing/Pricing.jsx index 717f88f..2a29f64 100644 --- a/src/pages/doormile/pricing/Pricing.jsx +++ b/src/pages/doormile/pricing/Pricing.jsx @@ -11,6 +11,7 @@ import { useTenants, useUpdatePricing, } from '@/lib/doormileHooks'; import { currency, matchesQuery, orDash, useDebouncedValue } from '@/lib/doormileFormat'; +import { useAuth } from '@/lib/AuthContext'; /** * Client pricing — the per-tenant rate cards quotes are calculated from. @@ -18,6 +19,11 @@ import { currency, matchesQuery, orDash, useDebouncedValue } from '@/lib/doormil * This is `/admin/pricing`, the tenant-scoped rules. Doormile's own internal * banding lives on a separate resource with no tenant concept at all and is not * edited here. + * + * A client login sees its own rate card read-only: the server scopes the list + * to its tenant and refuses a client's create, edit, delete and quote (the + * quote picks a rule across every tenant, so it would show another client's + * rates). */ const VEHICLE_TYPES = ['Bike', 'Scooter', 'Bicycle', 'Car', 'Van']; @@ -48,6 +54,7 @@ const EMPTY_QUOTE = { tenantid: '', applocationid: '', vehicletype: 'Bike', weig const ALL_ZONES = 'all'; export default function Pricing() { + const { isClient } = useAuth(); const { data: pricing = [], isLoading, isFetching } = usePricing(); const { data: tenants = [] } = useTenants(); const { data: locations = [] } = useAppLocations(); @@ -234,7 +241,7 @@ export default function Pricing() { sortable: true, cell: (row) => , }, - { + !isClient && { key: 'actions', header: 'Actions', align: 'right', @@ -245,9 +252,9 @@ export default function Pricing() { ), }, - ], + ].filter(Boolean), - [tenantMap, zoneMap] + [tenantMap, zoneMap, isClient] ); const quoteResult = simulate.data?.data || simulate.data; @@ -282,14 +289,16 @@ export default function Pricing() { placeholder="Search by client, zone or vehicle" count={{ shown: rows.length, total: zonePricing.length, noun: 'rules' }} actions={ - <> - - - + isClient ? null : ( + <> + + + + ) } >