Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-281/TASK-316-317-slicing-ui-and-integrate-api-daily-recording-growing-uniformity-page

This commit is contained in:
rstubryan
2025-12-31 10:03:37 +07:00
14 changed files with 1308 additions and 577 deletions
+16
View File
@@ -15,6 +15,22 @@ export class BaseApiService<T, CreatePayloadGeneric, UpdatePayloadGeneric> {
return await httpClientFetcher<BaseApiResponse<T[]>>(endpoint);
}
async getAll(query?: Record<string, unknown>) {
try {
const getAllPath = this.basePath;
const getAllRes = await httpClient<BaseApiResponse<T[]>>(getAllPath, {
query,
});
return getAllRes;
} catch (error) {
if (axios.isAxiosError<BaseApiResponse<T[]>>(error)) {
return error.response?.data;
}
return undefined;
}
}
async getSingle(id: number) {
try {
const getSinglePath = `${this.basePath}/${id}`;
@@ -0,0 +1,166 @@
import { sleep } from '@/lib/helper';
import { BaseApiService } from '@/services/api/base';
import { httpClientFetcher } from '@/services/http/client';
import { BaseApiResponse } from '@/types/api/api-general';
import { ProductionResult } from '@/types/api/report/production-result';
// TODO: delete this dummy data
const PRODUCTION_RESULT_DUMMY_DATA: BaseApiResponse<ProductionResult[]> = {
code: 200,
status: 'success',
message: 'Get Laporan Hasil Produksi successfully',
meta: {
page: 1,
limit: 1,
total_pages: 2,
total_results: 2,
},
data: [
{
created_user: {
id: 1,
id_user: 1001,
email: 'user@example.com',
name: 'John Doe',
},
project_flock: {
id: 1,
name: 'PROJECT',
category: 'LAYING',
kandang: {
id: 1,
name: 'Cikaum',
},
},
created_at: '2025-01-01T08:00:00Z',
updated_at: '2025-01-02T10:30:00Z',
woa: 25,
bw: 62.5,
std_bw: 60,
uniformity: 88,
std_uniformity: '90% up',
dep_kum: 3.2,
dep_std: 2.5,
butiran_utuh: 850,
butiran_putih: 50,
butiran_retak: 70,
butiran_pecah: 30,
butiran_jumlah: 1000,
total_butir: 1000,
kg_utuh: 52.3,
kg_putih: 3.1,
kg_retak: 4.2,
kg_pecah: 1.9,
kg_jumlah: 61.5,
total_kg: 61.5,
persen_utuh: 85,
persen_putih: 5,
persen_retak: 7,
persen_pecah: 3,
hd: 92,
hd_std: 90,
fi: 115,
fi_std: 667,
em: 85,
em_std: 83,
ew: 62,
ew_std: 60,
fcr: 2.1,
fcr_std: 2.0,
hh: 96,
hh_std: 95,
},
{
created_user: {
id: 1,
id_user: 1001,
email: 'user@example.com',
name: 'John Doe',
},
project_flock: {
id: 1,
name: 'PROJECT',
category: 'LAYING',
kandang: {
id: 1,
name: 'Cikaum',
},
},
created_at: '2025-01-01T08:00:00Z',
updated_at: '2025-01-02T10:30:00Z',
woa: 25,
bw: 62.5,
std_bw: 60,
uniformity: 88,
std_uniformity: '90% up',
dep_kum: 3.2,
dep_std: 2.5,
butiran_utuh: 850,
butiran_putih: 50,
butiran_retak: 70,
butiran_pecah: 30,
butiran_jumlah: 1000,
total_butir: 1000,
kg_utuh: 52.3,
kg_putih: 3.1,
kg_retak: 4.2,
kg_pecah: 1.9,
kg_jumlah: 61.5,
total_kg: 61.5,
persen_utuh: 85,
persen_putih: 5,
persen_retak: 7,
persen_pecah: 3,
hd: 92,
hd_std: 90,
fi: 115,
fi_std: 110,
em: 85,
em_std: 83,
ew: 62,
ew_std: 60,
fcr: 2.1,
fcr_std: 2.0,
hh: 96,
hh_std: 95,
},
],
};
export class ProductionResultReportApiService extends BaseApiService<
ProductionResult,
unknown,
unknown
> {
constructor(basePath: string = '/reports/production-result') {
super(basePath);
}
async getAllProductionResultFetcher(
endpoint: string
): Promise<BaseApiResponse<ProductionResult[]>> {
// return await httpClientFetcher<BaseApiResponse<ProductionResult[]>>(
// endpoint
// );
await sleep(1000);
return PRODUCTION_RESULT_DUMMY_DATA;
}
}
export const ProductionResultReportApi = new ProductionResultReportApiService();