From c60ace5155b08b6a24b33caa1bd3b0577c94047a Mon Sep 17 00:00:00 2001 From: Ajems Date: Fri, 20 Dec 2024 02:14:23 +0300 Subject: [PATCH] add orders page and take order usecase --- frontend/src/api/endpoint.ts | 1 + frontend/src/api/request.ts | 17 +++- .../src/components/admin/AdminOrdersPage.vue | 2 +- .../src/components/worker/WorkerMainPage.vue | 33 +++++++ .../src/components/worker/WorkerOrderItem.vue | 95 +++++++++++++++++++ .../components/worker/WorkerOrdersPage.vue | 69 ++++++++++++++ frontend/src/routing/router.ts | 14 +++ 7 files changed, 228 insertions(+), 3 deletions(-) create mode 100644 frontend/src/components/worker/WorkerMainPage.vue create mode 100644 frontend/src/components/worker/WorkerOrderItem.vue create mode 100644 frontend/src/components/worker/WorkerOrdersPage.vue diff --git a/frontend/src/api/endpoint.ts b/frontend/src/api/endpoint.ts index f79f316..adbc0e4 100644 --- a/frontend/src/api/endpoint.ts +++ b/frontend/src/api/endpoint.ts @@ -14,4 +14,5 @@ export const deleteClientAddressPath = (id: string, address_id: string) => `/v1/ export const uploadDumpsPath = '/v1/dumps' export const exportDumpsPath = '/v1/dumps' export const getAllOrdersPath = '/v1/orders' +export const updateOrdersPath = (id: string) => `/v1/orders/${id}` export const getAllServicesPath = '/v1/services' diff --git a/frontend/src/api/request.ts b/frontend/src/api/request.ts index 1b5afcc..6848eda 100644 --- a/frontend/src/api/request.ts +++ b/frontend/src/api/request.ts @@ -21,7 +21,8 @@ import { uploadDumpsPath, exportDumpsPath, getAllOrdersPath, - getAllServicesPath + getAllServicesPath, + updateOrdersPath } from './endpoint' import Order from './models/order' import Service from './models/service' @@ -233,7 +234,7 @@ export async function filterWorkers(name: string, surname: string): Promise { +export async function getAllOrders(id: string | null): Promise { const url = `${baseURL}${getAllOrdersPath}?user_id=${id}`; return axios.get(url) .then((response) => { @@ -244,6 +245,18 @@ export async function getAllOrders(id: string): Promise { }) } +export async function updateOrder(newOrder: Order): Promise { + return axios.put(baseURL + updateOrdersPath(newOrder.id), newOrder) + .then((response) => { + return response.data + }) + .catch((error) => { + console.error('Error update order:', error); + throw error; + }) + +} + export async function getAllServices(): Promise { return axios.get(baseURL + getAllServicesPath) .then((response) => { diff --git a/frontend/src/components/admin/AdminOrdersPage.vue b/frontend/src/components/admin/AdminOrdersPage.vue index 1d97cd7..cc05b77 100644 --- a/frontend/src/components/admin/AdminOrdersPage.vue +++ b/frontend/src/components/admin/AdminOrdersPage.vue @@ -96,7 +96,7 @@ function submitSearch(): void { } onMounted(() => { - getAllOrders() + getAllOrders(null) .then((response) => { orders.value = response }) diff --git a/frontend/src/components/worker/WorkerMainPage.vue b/frontend/src/components/worker/WorkerMainPage.vue new file mode 100644 index 0000000..88c3eca --- /dev/null +++ b/frontend/src/components/worker/WorkerMainPage.vue @@ -0,0 +1,33 @@ + + + \ No newline at end of file diff --git a/frontend/src/components/worker/WorkerOrderItem.vue b/frontend/src/components/worker/WorkerOrderItem.vue new file mode 100644 index 0000000..7357f09 --- /dev/null +++ b/frontend/src/components/worker/WorkerOrderItem.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/frontend/src/components/worker/WorkerOrdersPage.vue b/frontend/src/components/worker/WorkerOrdersPage.vue new file mode 100644 index 0000000..dd2810e --- /dev/null +++ b/frontend/src/components/worker/WorkerOrdersPage.vue @@ -0,0 +1,69 @@ + + + \ No newline at end of file diff --git a/frontend/src/routing/router.ts b/frontend/src/routing/router.ts index c98cf47..ecd1e2f 100644 --- a/frontend/src/routing/router.ts +++ b/frontend/src/routing/router.ts @@ -10,6 +10,8 @@ import AdminOrdersPage from '../components/admin/AdminOrdersPage.vue' import AdminWorkersSettingsPage from '../components/admin/AdminWorkersSettingsPage.vue' import AdminServicesSettingsPage from '../components/admin/AdminServicesSettingsPage.vue' import AdminStatisticSettingsPage from '../components/admin/AdminStatisticSettingsPage.vue' +import WorkerMainPage from '../components/worker/WorkerMainPage.vue' +import WorkerOrdersPage from '../components/worker/WorkerOrdersPage.vue' const routes = [ { @@ -70,6 +72,18 @@ const routes = [ component: AdminStatisticSettingsPage } ] + }, + { + name: 'worker', + path: 'worker:id([a-fA-F0-9]+)', + component: WorkerMainPage, + children: [ + { + name: 'worker-orders', + path: 'orders', + component: WorkerOrdersPage + } + ] } ] },