Graceful not found customer identifier handling

This commit is contained in:
2025-06-29 17:31:45 +03:00
parent 9c80c2905d
commit 2f6a88d224
3 changed files with 32 additions and 6 deletions

View File

@@ -3,6 +3,15 @@ export const fetchCustomerData = async (id: string) => {
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/loota/${id}`, {
method: 'GET',
});
if (response.status === 404) {
return {
identifier: 'Ei löydy',
location: 'Tuntematon',
boxes: [],
}
}
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
@@ -22,6 +31,7 @@ export const markBoxPickedUp = async (id: string) => {
},
body: JSON.stringify({ id: id, pickup_date: new Date().toISOString().split('.')[0] }),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}