diff --git a/.env b/.env new file mode 100644 index 0000000..223030e --- /dev/null +++ b/.env @@ -0,0 +1 @@ +VITE_API_URL = http://localhost:3000/queue \ No newline at end of file diff --git a/db.json b/db.json new file mode 100644 index 0000000..25e1eb3 --- /dev/null +++ b/db.json @@ -0,0 +1,16 @@ +{ + "queue": [ + { "id": 1, "number": "P001", "counter": 1, "service": "Siap Print", "customer": { "name": "John Doe", "phone": "081234567890" }, "startTime": "2025-02-26T08:00:00", "endTime": null, "status": "waiting" }, + { "id": 2, "number": "D001", "counter": 2, "service": "Design", "customer": { "name": "Jane Smith", "phone": "081298765432" }, "startTime": "2025-02-26T08:05:00", "endTime": null, "status": "called" }, + { "id": 3, "number": "F001", "counter": 3, "service": "Fotocopy", "customer": { "name": "Emily Davis", "phone": "081678901234" }, "startTime": "2025-02-26T08:30:00", "endTime": "2025-02-26T08:45:00", "status": "completed" }, + { "id": 4, "number": "R001", "counter": 4, "service": "Retur Barang", "customer": { "name": "Sophia Lee", "phone": "081789012345" }, "startTime": "2025-02-26T08:35:00", "endTime": null, "status": "called" }, + { "id": 5, "number": "O001", "counter": 5, "service": "Online Pickup", "customer": { "name": "Daniel Martinez", "phone": "081890123456" }, "startTime": "2025-02-26T08:40:00", "endTime": null, "status": "waiting" }, + { "id": 6, "number": "T001", "counter": 6, "service": "Tamu", "customer": { "name": "Henry Adams", "phone": "081901234567" }, "startTime": "2025-02-26T08:50:00", "endTime": null, "status": "waiting" }, + { "id": 7, "number": "P002", "counter": 1, "service": "Siap Print", "customer": { "name": "James Thompson", "phone": "081234567891" }, "startTime": "2025-02-26T09:00:00", "endTime": null, "status": "waiting" }, + { "id": 8, "number": "D002", "counter": 2, "service": "Design", "customer": { "name": "Benjamin Clark", "phone": "081456789013" }, "startTime": "2025-02-26T09:10:00", "endTime": "2025-02-26T09:20:00", "status": "completed" }, + { "id": 9, "number": "F002", "counter": 3, "service": "Fotocopy", "customer": { "name": "Olivia Brown", "phone": "081567890124" }, "startTime": "2025-02-26T09:15:00", "endTime": null, "status": "waiting" }, + { "id": 10, "number": "R002", "counter": 4, "service": "Retur Barang", "customer": { "name": "William White", "phone": "081678901235" }, "startTime": "2025-02-26T09:20:00", "endTime": null, "status": "called" }, + { "id": 11, "number": "O002", "counter": 5, "service": "Online Pickup", "customer": { "name": "Sophia Harris", "phone": "081789012346" }, "startTime": "2025-02-26T09:25:00", "endTime": null, "status": "waiting" }, + { "id": 12, "number": "T002", "counter": 6, "service": "Tamu", "customer": { "name": "Alexander Nelson", "phone": "081890123457" }, "startTime": "2025-02-26T09:30:00", "endTime": null, "status": "waiting" } + ] +} diff --git a/public/c1.png b/public/c1.png new file mode 100644 index 0000000..2367225 Binary files /dev/null and b/public/c1.png differ diff --git a/public/c2.jpg b/public/c2.jpg new file mode 100644 index 0000000..ff1033e Binary files /dev/null and b/public/c2.jpg differ diff --git a/public/c3.jpg b/public/c3.jpg new file mode 100644 index 0000000..cfc6fa3 Binary files /dev/null and b/public/c3.jpg differ diff --git a/src/api/queueApi.js b/src/api/queueApi.js new file mode 100644 index 0000000..0773931 --- /dev/null +++ b/src/api/queueApi.js @@ -0,0 +1,56 @@ +import axios from "axios"; + +const API_URL = "http://localhost:5000/queue"; + +export const fetchOperators = async () => { + try { + const response = await axios.get(API_URL); + return response.data; + } catch (error) { + console.error("Error fetching operators", error); + return []; + } +}; + +export const addCustomerToOperator = async (operatorId, customerData) => { + try { + const response = await axios.get(`${API_URL}/${operatorId}`); + const operator = response.data; + + operator.customers.push(customerData); + + const updateResponse = await axios.put(`${API_URL}/${operatorId}`, operator); + return updateResponse.data; + } catch (error) { + console.error("Error adding customer", error); + } +}; + +export const updateCustomerStatus = async (operatorId, customerId, updatedData) => { + try { + const response = await axios.get(`${API_URL}/${operatorId}`); + const operator = response.data; + + operator.customers = operator.customers.map(customer => + customer.id === customerId ? { ...customer, ...updatedData } : customer + ); + + const updateResponse = await axios.put(`${API_URL}/${operatorId}`, operator); + return updateResponse.data; + } catch (error) { + console.error("Error updating customer status", error); + } +}; + +export const deleteCustomerFromOperator = async (operatorId, customerId) => { + try { + const response = await axios.get(`${API_URL}/${operatorId}`); + const operator = response.data; + + operator.customers = operator.customers.filter(customer => customer.id !== customerId); + + await axios.put(`${API_URL}/${operatorId}`, operator); + } catch (error) { + console.error("Error deleting customer", error); + } +}; diff --git a/src/components/Admin/AdminFooter.jsx b/src/components/Admin/AdminFooter.jsx index afa0538..ff9c1a7 100644 --- a/src/components/Admin/AdminFooter.jsx +++ b/src/components/Admin/AdminFooter.jsx @@ -2,7 +2,7 @@ import { Container } from "react-bootstrap"; const AdminFooter = () => { return ( -