mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat(FE-113): create API Service for Transfer to Laying
This commit is contained in:
@@ -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<FlockWithKandangs[]> = {
|
||||
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<T, CreatePayloadGeneric, UpdatePayloadGeneric> {
|
||||
constructor(basePath: string = '') {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
// TODO: remove dummy data and integrate to real API
|
||||
async getFlockSource(): Promise<
|
||||
BaseApiResponse<FlockWithKandangs[]> | undefined
|
||||
> {
|
||||
try {
|
||||
// const getFlockSourcePath = `${this.basePath}/${flockSourcePath}`;
|
||||
// const getSingleRes = await httpClient<FlockSourceType>(getFlockSourcePath);
|
||||
// return getSingleRes;
|
||||
|
||||
await sleep(500);
|
||||
|
||||
return FLOCK_SOURCE_DUMMY_DATA;
|
||||
} catch (error) {
|
||||
// if (axios.isAxiosError<BaseApiResponse<T>>(error)) {
|
||||
// return error.response?.data;
|
||||
// }
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const TransferToLayingApi = new TransferToLayingService<
|
||||
unknown,
|
||||
unknown,
|
||||
unknown
|
||||
>('');
|
||||
Reference in New Issue
Block a user