Card called GET /warehouse-inventory (staff perm) → 403 swallowed as

empty state. New customer-safe bookings/:id/location endpoint returns
location fields only; card now uses it.
This commit is contained in:
Hagernesh
2026-07-21 14:12:00 +00:00
parent 60743ca872
commit b54cb2483e
4 changed files with 36 additions and 2 deletions

View File

@@ -23,8 +23,8 @@ function Row({ label, value }: { label: string; value: React.ReactNode }) {
export function WarehouseLocationCard({ bookingId }: WarehouseLocationCardProps) {
const { data, isLoading } = useQuery({
queryKey: ["warehouse-inventory", bookingId],
queryFn: () => warehouseService.listInventory({ bookingId }),
queryKey: ["warehouse-inventory", "booking-location", bookingId],
queryFn: () => warehouseService.bookingLocation(bookingId),
});
const items = data ?? [];

View File

@@ -49,6 +49,12 @@ export const warehouseService = {
return data?.data ?? data ?? [];
},
/** Customer-safe location endpoint — the plain list is staff-only (403 for portal users). */
bookingLocation: async (bookingId: string): Promise<WarehouseInventoryItem[]> => {
const { data } = await client.get(`/warehouse-inventory/bookings/${bookingId}/location`);
return data?.data ?? data ?? [];
},
bookingSchedule: async (bookingId: string): Promise<BookingScheduleView> => {
const { data } = await client.get(`/warehouse-inventory/booking-schedule/${bookingId}`);
return data?.data ?? data ?? { schedule: null, wagon: null };