mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-21 05:45:46 +00:00
fix: hit API when user click Simpan Draft/Submit and and empty kandang end date
This commit is contained in:
@@ -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}`;
|
||||
|
||||
Reference in New Issue
Block a user