mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
fix: hit API when user click Simpan Draft/Submit and and empty kandang end date
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@ import {
|
||||
DailyChecklist,
|
||||
DailyChecklistReport,
|
||||
DetailDailyChecklist,
|
||||
UpdateDailyChecklistPayload,
|
||||
} from '@/types/api/daily-checklist/daily-checklist';
|
||||
import { isResponseError } from '@/lib/api-helper';
|
||||
import { toast } from 'sonner';
|
||||
@@ -16,12 +17,39 @@ import { toast } from 'sonner';
|
||||
export class DailyChecklistApiService extends BaseApiService<
|
||||
DailyChecklist,
|
||||
CreateDailyChecklistPayload,
|
||||
unknown
|
||||
UpdateDailyChecklistPayload
|
||||
> {
|
||||
constructor(basePath: string = '/daily-checklists') {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
async update(id: number, payload: UpdateDailyChecklistPayload) {
|
||||
const isFormData =
|
||||
typeof FormData !== 'undefined' && payload instanceof FormData;
|
||||
try {
|
||||
const updatePath = `${this.basePath}/${id}`;
|
||||
|
||||
const headers = isFormData
|
||||
? { ...(this.header ?? {}) }
|
||||
: { 'Content-Type': 'application/json', ...(this.header ?? {}) };
|
||||
|
||||
const updateRes = await httpClient<BaseApiResponse<DailyChecklist>>(
|
||||
updatePath,
|
||||
{
|
||||
method: 'PUT',
|
||||
body: payload,
|
||||
headers,
|
||||
}
|
||||
);
|
||||
return updateRes;
|
||||
} catch (error: unknown) {
|
||||
if (axios.isAxiosError<BaseApiResponse<DailyChecklist>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async getOneDailyChecklist(id: string) {
|
||||
try {
|
||||
const getOneDailyChecklistPath = `${this.basePath}/relation/${id}`;
|
||||
|
||||
@@ -13,6 +13,7 @@ export type BaseDailyChecklist = {
|
||||
category: string;
|
||||
date: string;
|
||||
empty_kandang?: boolean;
|
||||
empty_kandang_end_date?: string | null;
|
||||
kandang?: Pick<BaseKandang, 'id' | 'name' | 'status' | 'capacity'>;
|
||||
total_phase: number;
|
||||
total_activity: number;
|
||||
@@ -59,8 +60,11 @@ export type CreateDailyChecklistPayload = {
|
||||
category: string;
|
||||
status: string;
|
||||
empty_kandang: boolean;
|
||||
empty_kandang_end_date?: string | null;
|
||||
};
|
||||
|
||||
export type UpdateDailyChecklistPayload = CreateDailyChecklistPayload;
|
||||
|
||||
export type PerformanceOverviewItem = {
|
||||
employee_id: number;
|
||||
employee_name: string;
|
||||
|
||||
Reference in New Issue
Block a user