mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +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,
|
DailyChecklist,
|
||||||
DailyChecklistReport,
|
DailyChecklistReport,
|
||||||
DetailDailyChecklist,
|
DetailDailyChecklist,
|
||||||
|
UpdateDailyChecklistPayload,
|
||||||
} from '@/types/api/daily-checklist/daily-checklist';
|
} from '@/types/api/daily-checklist/daily-checklist';
|
||||||
import { isResponseError } from '@/lib/api-helper';
|
import { isResponseError } from '@/lib/api-helper';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
@@ -16,12 +17,39 @@ import { toast } from 'sonner';
|
|||||||
export class DailyChecklistApiService extends BaseApiService<
|
export class DailyChecklistApiService extends BaseApiService<
|
||||||
DailyChecklist,
|
DailyChecklist,
|
||||||
CreateDailyChecklistPayload,
|
CreateDailyChecklistPayload,
|
||||||
unknown
|
UpdateDailyChecklistPayload
|
||||||
> {
|
> {
|
||||||
constructor(basePath: string = '/daily-checklists') {
|
constructor(basePath: string = '/daily-checklists') {
|
||||||
super(basePath);
|
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) {
|
async getOneDailyChecklist(id: string) {
|
||||||
try {
|
try {
|
||||||
const getOneDailyChecklistPath = `${this.basePath}/relation/${id}`;
|
const getOneDailyChecklistPath = `${this.basePath}/relation/${id}`;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export type BaseDailyChecklist = {
|
|||||||
category: string;
|
category: string;
|
||||||
date: string;
|
date: string;
|
||||||
empty_kandang?: boolean;
|
empty_kandang?: boolean;
|
||||||
|
empty_kandang_end_date?: string | null;
|
||||||
kandang?: Pick<BaseKandang, 'id' | 'name' | 'status' | 'capacity'>;
|
kandang?: Pick<BaseKandang, 'id' | 'name' | 'status' | 'capacity'>;
|
||||||
total_phase: number;
|
total_phase: number;
|
||||||
total_activity: number;
|
total_activity: number;
|
||||||
@@ -59,8 +60,11 @@ export type CreateDailyChecklistPayload = {
|
|||||||
category: string;
|
category: string;
|
||||||
status: string;
|
status: string;
|
||||||
empty_kandang: boolean;
|
empty_kandang: boolean;
|
||||||
|
empty_kandang_end_date?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type UpdateDailyChecklistPayload = CreateDailyChecklistPayload;
|
||||||
|
|
||||||
export type PerformanceOverviewItem = {
|
export type PerformanceOverviewItem = {
|
||||||
employee_id: number;
|
employee_id: number;
|
||||||
employee_name: string;
|
employee_name: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user