This commit is contained in:
2026-04-09 15:17:07 +03:00
parent c5f6d2f596
commit 29cc9c6f4e
23 changed files with 420 additions and 190 deletions
+11 -11
View File
@@ -5,8 +5,8 @@ import type { ApiPath, ApiRequestBody } from "../infra/types"
export const PARTS_ROUTES = {
INDEX: "/api/parts",
BY_ID: "/api/parts/{id}",
IMPORT: "/api/import-parts",
EXPORT: "/api/export-parts",
IMPORT: "/api/parts/import",
EXPORT: "/api/parts/export",
TOGGLE_STATUS: "/api/toggle-part-status",
} as const satisfies Record<string, ApiPath>
@@ -15,15 +15,15 @@ export class PartsClient extends CrudClient<
typeof PARTS_ROUTES.BY_ID
> {
constructor(baseUrl?: string, defaultOptions?: ApiClientOptions) {
super(baseUrl, defaultOptions, PARTS_ROUTES.INDEX, PARTS_ROUTES.BY_ID)
}
async import(payload: ApiRequestBody<typeof PARTS_ROUTES.IMPORT, "post">) {
return this.post(PARTS_ROUTES.IMPORT, payload)
}
async export(payload: ApiRequestBody<typeof PARTS_ROUTES.EXPORT, "post">) {
return this.post(PARTS_ROUTES.EXPORT, payload)
super(
baseUrl,
defaultOptions,
PARTS_ROUTES.INDEX,
PARTS_ROUTES.BY_ID,
PARTS_ROUTES.IMPORT,
PARTS_ROUTES.EXPORT,
"POST",
)
}
async toggleStatus(payload: ApiRequestBody<typeof PARTS_ROUTES.TOGGLE_STATUS, "post">) {
+10 -10
View File
@@ -1,6 +1,6 @@
import { CrudClient } from "../infra/crud-client"
import type { ApiClientOptions } from "../infra/client"
import type { ApiPath, ApiRequestBody } from "../infra/types"
import type { ApiPath } from "../infra/types"
export const SERVICE_ROUTES = {
INDEX: "/api/services",
@@ -14,14 +14,14 @@ export class ServicesClient extends CrudClient<
typeof SERVICE_ROUTES.BY_ID
> {
constructor(baseUrl?: string, defaultOptions?: ApiClientOptions) {
super(baseUrl, defaultOptions, SERVICE_ROUTES.INDEX, SERVICE_ROUTES.BY_ID)
}
async import(payload: ApiRequestBody<typeof SERVICE_ROUTES.IMPORT, "post">) {
return this.post(SERVICE_ROUTES.IMPORT, payload)
}
async export(payload: ApiRequestBody<typeof SERVICE_ROUTES.EXPORT, "post">) {
return this.post(SERVICE_ROUTES.EXPORT, payload)
super(
baseUrl,
defaultOptions,
SERVICE_ROUTES.INDEX,
SERVICE_ROUTES.BY_ID,
SERVICE_ROUTES.IMPORT,
SERVICE_ROUTES.EXPORT,
"POST",
)
}
}