mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
116 lines
2.9 KiB
TypeScript
116 lines
2.9 KiB
TypeScript
import { BaseApiService } from '@/services/api/base';
|
|
import { BaseApiResponse } from '@/types/api/api-general';
|
|
import {
|
|
CreateProjectFlockPayload,
|
|
ProjectFlock,
|
|
UpdateProjectFlockPayload,
|
|
} from '@/types/api/production/project-flock';
|
|
import {
|
|
CreateRecordingPayload,
|
|
Recording,
|
|
UpdateRecordingPayload,
|
|
CreateGradingPayload,
|
|
UpdateGradingPayload,
|
|
NextDayRecording,
|
|
} from '@/types/api/production/recording';
|
|
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
|
|
|
|
export const ProjectFlockKandangApi = new BaseApiService<
|
|
ProjectFlockKandang,
|
|
unknown,
|
|
unknown
|
|
>('/production/project-flock-kandangs');
|
|
export const ProjectFlockApi = new BaseApiService<
|
|
ProjectFlock,
|
|
CreateProjectFlockPayload,
|
|
UpdateProjectFlockPayload
|
|
>('/production/project-flocks');
|
|
export class RecordingService extends BaseApiService<
|
|
Recording,
|
|
CreateRecordingPayload,
|
|
UpdateRecordingPayload
|
|
> {
|
|
constructor(basePath: string = '') {
|
|
super(basePath);
|
|
}
|
|
|
|
async approve(
|
|
idOrIds: number | number[],
|
|
notes?: string
|
|
): Promise<BaseApiResponse<Recording[]> | undefined> {
|
|
const approvable_ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
return await this.customRequest<BaseApiResponse<Recording[]>>('approvals', {
|
|
method: 'POST',
|
|
payload: {
|
|
action: 'APPROVED',
|
|
approvable_ids,
|
|
notes,
|
|
},
|
|
});
|
|
}
|
|
|
|
async reject(
|
|
idOrIds: number | number[],
|
|
notes: string = ''
|
|
): Promise<BaseApiResponse<Recording[]> | undefined> {
|
|
const approvable_ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
return await this.customRequest<BaseApiResponse<Recording[]>>('approvals', {
|
|
method: 'POST',
|
|
payload: {
|
|
action: 'REJECTED',
|
|
approvable_ids,
|
|
notes,
|
|
},
|
|
});
|
|
}
|
|
|
|
async createGrading(
|
|
payload: CreateGradingPayload
|
|
): Promise<BaseApiResponse<unknown> | undefined> {
|
|
return await this.customRequest<BaseApiResponse<unknown>>('gradings', {
|
|
method: 'POST',
|
|
payload,
|
|
});
|
|
}
|
|
|
|
async updateGrading(
|
|
gradingId: number,
|
|
payload: UpdateGradingPayload
|
|
): Promise<BaseApiResponse<unknown> | undefined> {
|
|
return await this.customRequest<BaseApiResponse<unknown>>(
|
|
`gradings/${gradingId}`,
|
|
{
|
|
method: 'PUT',
|
|
payload,
|
|
}
|
|
);
|
|
}
|
|
|
|
async deleteGrading(
|
|
gradingId: number
|
|
): Promise<BaseApiResponse<unknown> | undefined> {
|
|
return await this.customRequest<BaseApiResponse<unknown>>(
|
|
`gradings/${gradingId}`,
|
|
{
|
|
method: 'DELETE',
|
|
}
|
|
);
|
|
}
|
|
|
|
async nextDayRecording(
|
|
projectFlockId: number
|
|
): Promise<BaseApiResponse<NextDayRecording> | undefined> {
|
|
return await this.customRequest<BaseApiResponse<NextDayRecording>>(
|
|
`next-day`,
|
|
{
|
|
method: 'GET',
|
|
params: {
|
|
project_flock_kandang_id: projectFlockId,
|
|
},
|
|
}
|
|
);
|
|
}
|
|
}
|
|
|
|
export const RecordingApi = new RecordingService('/production/recordings');
|