From 88d1354944442d12b9865470106343797692884c Mon Sep 17 00:00:00 2001 From: "kelvin.yau" Date: Mon, 19 Jan 2026 08:03:32 +0800 Subject: [PATCH] fix --- src/app/api/warehouse/client.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/app/api/warehouse/client.ts b/src/app/api/warehouse/client.ts index 7b57f6a..526f09d 100644 --- a/src/app/api/warehouse/client.ts +++ b/src/app/api/warehouse/client.ts @@ -31,4 +31,25 @@ export const exportWarehouseQrCode = async (warehouseIds: number[]): Promise<{ b return { blobValue, filename }; }; + +export const fetchWarehouseListClient = async (): Promise => { + const token = localStorage.getItem("accessToken"); + + const response = await fetch(`${NEXT_PUBLIC_API_URL}/warehouse`, { + method: "GET", + headers: { + "Content-Type": "application/json", + ...(token && { Authorization: `Bearer ${token}` }), + }, + }); + + if (!response.ok) { + if (response.status === 401) { + throw new Error("Unauthorized: Please log in again"); + } + throw new Error(`Failed to fetch warehouse list: ${response.status} ${response.statusText}`); + } + + return response.json(); +}; //test \ No newline at end of file