Logic to change box as picked up

This commit is contained in:
2025-06-17 00:26:06 +03:00
parent cb9f9b3c00
commit cb06c560f8
3 changed files with 92 additions and 45 deletions

View File

@@ -1,3 +1,5 @@
import { Box, CustomerData } from "./types";
export const fetchCustomerData = async (id: string) => {
const baseUrl = "http://localhost:9090";
@@ -14,4 +16,26 @@ export const fetchCustomerData = async (id: string) => {
} catch (error) {
throw error;
}
}
export const markBoxPickedUp = async (id: string) => {
const baseUrl = "http://localhost:9090";
try {
const response = await fetch(`${baseUrl}/loota/`, {
method: 'POST',
mode: "cors",
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ id: id, pickup_date: new Date().toISOString().split('.')[0] }),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const updatedBox = await response.json();
return updatedBox;
} catch (error) {
throw error;
}
}