From 2f4daea253120ab40b6d036b9f20935aadb7fb5f Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Tue, 21 Oct 2025 15:07:51 +0700 Subject: [PATCH] feat(FE-113): create API Service for Transfer to Laying --- .../api/production/transfer-to-laying.ts | 182 ++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 src/services/api/production/transfer-to-laying.ts diff --git a/src/services/api/production/transfer-to-laying.ts b/src/services/api/production/transfer-to-laying.ts new file mode 100644 index 00000000..94af7ae8 --- /dev/null +++ b/src/services/api/production/transfer-to-laying.ts @@ -0,0 +1,182 @@ +import { sleep } from '@/lib/helper'; +import { BaseApiService } from '@/services/api/base'; +import { BaseApiResponse } from '@/types/api/api-general'; + +import { FlockWithKandangs } from '@/types/api/master-data/flock'; + +// TODO: delete this dummy data +const FLOCK_SOURCE_DUMMY_DATA: BaseApiResponse = { + code: 200, + status: 'success', + message: 'Get all projectflocks successfully', + meta: { + page: 1, + limit: 10, + total_pages: 1, + total_results: 2, + }, + data: [ + { + id: 2, + name: 'Flock Banten', + totalQuantity: 300, + kandangs: [ + { + kandang: { + id: 3, + name: 'Cikaum 1', + location: { + id: 1, + name: 'Singaparna', + address: 'Tasik', + area: { + id: 1, + name: 'test area', + }, + }, + pic: { + id: 1, + id_user: 1, + email: 'admin@mbugroup.id', + name: 'Super Admin', + }, + }, + quantity: 100, + }, + { + kandang: { + id: 4, + name: 'Cikaum 2', + location: { + id: 1, + name: 'Singaparna', + address: 'Tasik', + area: { + id: 1, + name: 'test area', + }, + }, + pic: { + id: 1, + id_user: 1, + email: 'admin@mbugroup.id', + name: 'Super Admin', + }, + }, + quantity: 150, + }, + { + kandang: { + id: 5, + name: 'Cikaum 3', + location: { + id: 1, + name: 'Singaparna', + address: 'Tasik', + area: { + id: 1, + name: 'test area', + }, + }, + pic: { + id: 1, + id_user: 1, + email: 'admin@mbugroup.id', + name: 'Super Admin', + }, + }, + quantity: 50, + }, + ], + }, + + { + id: 3, + name: 'Flock Priangan', + totalQuantity: 200, + kandangs: [ + { + kandang: { + id: 3, + name: 'Cikaum 1', + location: { + id: 1, + name: 'Singaparna', + address: 'Tasik', + area: { + id: 1, + name: 'Priangan', + }, + }, + pic: { + id: 1, + id_user: 1, + email: 'admin@mbugroup.id', + name: 'Super Admin', + }, + }, + quantity: 100, + }, + { + kandang: { + id: 4, + name: 'Cikaum 2', + location: { + id: 1, + name: 'Singaparna', + address: 'Tasik', + area: { + id: 1, + name: 'test area', + }, + }, + pic: { + id: 1, + id_user: 1, + email: 'admin@mbugroup.id', + name: 'Super Admin', + }, + }, + quantity: 100, + }, + ], + }, + ], +}; + +export class TransferToLayingService< + T, + CreatePayloadGeneric, + UpdatePayloadGeneric +> extends BaseApiService { + constructor(basePath: string = '') { + super(basePath); + } + + // TODO: remove dummy data and integrate to real API + async getFlockSource(): Promise< + BaseApiResponse | undefined + > { + try { + // const getFlockSourcePath = `${this.basePath}/${flockSourcePath}`; + // const getSingleRes = await httpClient(getFlockSourcePath); + // return getSingleRes; + + await sleep(500); + + return FLOCK_SOURCE_DUMMY_DATA; + } catch (error) { + // if (axios.isAxiosError>(error)) { + // return error.response?.data; + // } + + return undefined; + } + } +} + +export const TransferToLayingApi = new TransferToLayingService< + unknown, + unknown, + unknown +>('');