mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE-dashboard-modal): Refactor dashboard production data
fetching logic
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import { Dashboard } from '@/types/api/dashboard/dashboard';
|
||||
import { httpClientFetcher } from '@/services/http/client';
|
||||
import { Dashboard, DashboardFilter } from '@/types/api/dashboard/dashboard';
|
||||
|
||||
class DashboardService extends BaseApiService<Dashboard, unknown, unknown> {
|
||||
constructor(basePath: string) {
|
||||
@@ -14,11 +13,26 @@ class DashboardService extends BaseApiService<Dashboard, unknown, unknown> {
|
||||
* @returns Promise with BaseApiResponse containing DashboardProduction
|
||||
*/
|
||||
async getDashboardProductionFetcher(
|
||||
endpoint: string
|
||||
params: DashboardFilter
|
||||
): Promise<BaseApiResponse<Dashboard> | undefined> {
|
||||
return await httpClientFetcher<BaseApiResponse<Dashboard>>(
|
||||
`${endpoint ? endpoint : this.basePath}`
|
||||
);
|
||||
return await this.customRequest<BaseApiResponse<Dashboard>>('', {
|
||||
method: 'GET',
|
||||
params: {
|
||||
start_date: params.start_date || undefined,
|
||||
end_date: params.end_date || undefined,
|
||||
analysis_mode: params.analysis_mode || undefined,
|
||||
location_ids: params.location_ids.length
|
||||
? params.location_ids.toString()
|
||||
: undefined,
|
||||
flock_ids: params.flock_ids.length
|
||||
? params.flock_ids.toString()
|
||||
: undefined,
|
||||
kandang_ids: params.kandang_ids.length
|
||||
? params.kandang_ids.toString()
|
||||
: undefined,
|
||||
comparison_type: params.comparison_type || undefined,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user