From 80454151132822e240b04100fffdba3900e2a8e1 Mon Sep 17 00:00:00 2001 From: ghost2023 Date: Thu, 4 Jun 2026 14:33:28 +0300 Subject: [PATCH] refactor: clean up --- .../portal/src/services/api.ts | 34 ----------- .../portal/src/services/customers.service.ts | 57 ------------------- 2 files changed, 91 deletions(-) delete mode 100644 apps/edr-freight-web/portal/src/services/customers.service.ts diff --git a/apps/edr-freight-web/portal/src/services/api.ts b/apps/edr-freight-web/portal/src/services/api.ts index bb5fcdcc7..115395f1a 100644 --- a/apps/edr-freight-web/portal/src/services/api.ts +++ b/apps/edr-freight-web/portal/src/services/api.ts @@ -89,40 +89,6 @@ export const api = { logout: endpoint("auth", "logout", authService.logout), }, - customers: { - list: endpoint( - "customers", - "list", - customersService.list, - ), - - get: endpoint<{ id: string }, Customer>("customers", "get", ({ id }) => - customersService.getById(id), - ), - - create: endpoint( - "customers", - "create", - customersService.create, - ), - - update: endpoint<{ id: string; dto: UpdateCustomerDto }, Customer>( - "customers", - "update", - ({ id, dto }) => customersService.update(id, dto), - ), - - remove: endpoint<{ id: string }, void>("customers", "remove", ({ id }) => - customersService.remove(id), - ), - - getByUserId: endpoint<{ id: string }, Customer | null>( - "customers", - "getByUserId", - ({ id }) => customersService.getByUserId(id), - ), - }, - companies: { getInfo: endpoint( "companies", diff --git a/apps/edr-freight-web/portal/src/services/customers.service.ts b/apps/edr-freight-web/portal/src/services/customers.service.ts deleted file mode 100644 index 3d809709d..000000000 --- a/apps/edr-freight-web/portal/src/services/customers.service.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { client } from "@/utils/api"; -import { unwrap } from "@/utils/endpoint"; -import { URL_CONSTANTS } from "@/constants/URLS"; -import type { ApiResponse } from "@/types/apiResponse"; -import type { - CreateCustomerDto, - Customer, - UpdateCustomerDto, -} from "@/types/customers"; -import { isAxiosError } from "axios"; - -const BASE = URL_CONSTANTS.CUSTOMERS_API.BASE; - -export const customersService = { - list: async (): Promise => { - const response = await client.get>(BASE); - return unwrap(response.data); - }, - - getById: async (id: string): Promise => { - const response = await client.get>( - URL_CONSTANTS.CUSTOMERS_API.BY_ID(id), - ); - return unwrap(response.data); - }, - - getByUserId: async (userId: string): Promise => { - try { - const response = await client.get>( - URL_CONSTANTS.CUSTOMERS_API.BY_USER_ID(userId), - ); - return unwrap(response.data); - } catch (e) { - if (isAxiosError(e) && e.response?.status === 404) { - return null; - } - throw e; - } - }, - - create: async (payload: CreateCustomerDto): Promise => { - const response = await client.post>(BASE, payload); - return unwrap(response.data); - }, - - update: async (id: string, payload: UpdateCustomerDto): Promise => { - const response = await client.patch>( - URL_CONSTANTS.CUSTOMERS_API.BY_ID(id), - payload, - ); - return unwrap(response.data); - }, - - remove: async (id: string): Promise => { - await client.delete(URL_CONSTANTS.CUSTOMERS_API.BY_ID(id)); - }, -};