mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-21 13:55:45 +00:00
Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
import axios from 'axios';
|
||||
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import { httpClient } from '@/services/http/client';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import {
|
||||
CreateDailyChecklistPayload,
|
||||
DailyChecklist,
|
||||
DetailDailyChecklist,
|
||||
} from '@/types/api/daily-checklist/daily-checklist';
|
||||
|
||||
export class DailyChecklistApiService extends BaseApiService<
|
||||
DailyChecklist,
|
||||
CreateDailyChecklistPayload,
|
||||
unknown
|
||||
> {
|
||||
constructor(basePath: string = '/daily-checklists') {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
async getOneDailyChecklist(id: string) {
|
||||
try {
|
||||
const getOneDailyChecklistPath = `${this.basePath}/relation/${id}`;
|
||||
const getOneDailyChecklistRes = await httpClient<
|
||||
BaseApiResponse<DetailDailyChecklist>
|
||||
>(getOneDailyChecklistPath);
|
||||
|
||||
return getOneDailyChecklistRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse<DetailDailyChecklist>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async setDailyChecklistPhase(id: string, phaseIds: string[]) {
|
||||
try {
|
||||
const setDailyChecklistPhasePath = `${this.basePath}/phase/${id}`;
|
||||
const setDailyChecklistPhaseRes = await httpClient<BaseApiResponse>(
|
||||
setDailyChecklistPhasePath,
|
||||
{
|
||||
method: 'POST',
|
||||
body: { phase_ids: phaseIds.join(',') },
|
||||
}
|
||||
);
|
||||
|
||||
return setDailyChecklistPhaseRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async removeEmployeeAssignment(id: string, employeeId: string) {
|
||||
try {
|
||||
const removeEmployeeAssignmentPath = `${this.basePath}/${id}/assignments/${employeeId}`;
|
||||
const removeEmployeeAssignmentRes = await httpClient<BaseApiResponse>(
|
||||
removeEmployeeAssignmentPath,
|
||||
{
|
||||
method: 'DELETE',
|
||||
}
|
||||
);
|
||||
|
||||
return removeEmployeeAssignmentRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async setDailyChecklistEmployees(checklistId: string, employeeIds: string[]) {
|
||||
try {
|
||||
const setDailyChecklistPhasePath = `${this.basePath}/assignment/${checklistId}`;
|
||||
const setDailyChecklistPhaseRes = await httpClient<BaseApiResponse>(
|
||||
setDailyChecklistPhasePath,
|
||||
{
|
||||
method: 'POST',
|
||||
body: { employee_ids: employeeIds.join(',') },
|
||||
}
|
||||
);
|
||||
|
||||
return setDailyChecklistPhaseRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async getTasksByChecklistId(id: string) {
|
||||
try {
|
||||
const getTasksByChecklistIdPath = `${this.basePath}/tasks?checklist_id=${id}&page=1&limit=100`;
|
||||
const getTasksByChecklistIdRes = await httpClient<BaseApiResponse>(
|
||||
getTasksByChecklistIdPath
|
||||
);
|
||||
|
||||
return getTasksByChecklistIdRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async checkOrUncheckAssignment(payload: {
|
||||
task_id: number;
|
||||
employee_id: number;
|
||||
checked: boolean;
|
||||
note: string | null;
|
||||
}) {
|
||||
try {
|
||||
const checkOrUncheckAssignmentPath = `${this.basePath}/assignment`;
|
||||
const checkOrUncheckAssignmentRes = await httpClient<BaseApiResponse>(
|
||||
checkOrUncheckAssignmentPath,
|
||||
{
|
||||
method: 'POST',
|
||||
body: payload,
|
||||
}
|
||||
);
|
||||
|
||||
return checkOrUncheckAssignmentRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async submit(id: string) {
|
||||
try {
|
||||
const submitPath = `${this.basePath}/${id}`;
|
||||
const submitRes = await httpClient<BaseApiResponse>(submitPath, {
|
||||
method: 'PATCH',
|
||||
body: {
|
||||
status: 'SUBMITTED',
|
||||
reject_reason: '',
|
||||
},
|
||||
});
|
||||
|
||||
return submitRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async approve(id: string) {
|
||||
try {
|
||||
const approvePath = `${this.basePath}/${id}`;
|
||||
const approveRes = await httpClient<BaseApiResponse>(approvePath, {
|
||||
method: 'PATCH',
|
||||
body: {
|
||||
status: 'APPROVED',
|
||||
reject_reason: '',
|
||||
},
|
||||
});
|
||||
|
||||
return approveRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async reject(id: string, rejectReason: string) {
|
||||
try {
|
||||
const rejectPath = `${this.basePath}/${id}`;
|
||||
const rejectRes = await httpClient<BaseApiResponse>(rejectPath, {
|
||||
method: 'PATCH',
|
||||
body: {
|
||||
status: 'REJECTED',
|
||||
reject_reason: rejectReason,
|
||||
},
|
||||
});
|
||||
|
||||
return rejectRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const DailyChecklistApi = new DailyChecklistApiService(
|
||||
'/daily-checklists'
|
||||
);
|
||||
@@ -0,0 +1,18 @@
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import {
|
||||
CreateEmployeePayload,
|
||||
Employee,
|
||||
UpdateEmployeePayload,
|
||||
} from '@/types/api/daily-checklist/employee';
|
||||
|
||||
export class EmployeeApiService extends BaseApiService<
|
||||
Employee,
|
||||
CreateEmployeePayload,
|
||||
UpdateEmployeePayload
|
||||
> {
|
||||
constructor(basePath: string = '/master-data/employees') {
|
||||
super(basePath);
|
||||
}
|
||||
}
|
||||
|
||||
export const EmployeeApi = new EmployeeApiService('/master-data/employees');
|
||||
@@ -0,0 +1,20 @@
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import {
|
||||
PhaseActivity,
|
||||
CreatePhaseActivityPayload,
|
||||
UpdatePhaseActivityPayload,
|
||||
} from '@/types/api/daily-checklist/phase-activity';
|
||||
|
||||
export class PhaseActivityApiService extends BaseApiService<
|
||||
PhaseActivity,
|
||||
CreatePhaseActivityPayload,
|
||||
UpdatePhaseActivityPayload
|
||||
> {
|
||||
constructor(basePath: string = '/master-data/phase-activities') {
|
||||
super(basePath);
|
||||
}
|
||||
}
|
||||
|
||||
export const PhaseActivityApi = new PhaseActivityApiService(
|
||||
'/master-data/phase-activities'
|
||||
);
|
||||
@@ -0,0 +1,18 @@
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import {
|
||||
Phase,
|
||||
CreatePhasePayload,
|
||||
UpdatePhasePayload,
|
||||
} from '@/types/api/daily-checklist/phase';
|
||||
|
||||
export class PhaseApiService extends BaseApiService<
|
||||
Phase,
|
||||
CreatePhasePayload,
|
||||
UpdatePhasePayload
|
||||
> {
|
||||
constructor(basePath: string = '/master-data/phases') {
|
||||
super(basePath);
|
||||
}
|
||||
}
|
||||
|
||||
export const PhaseApi = new PhaseApiService('/master-data/phases');
|
||||
@@ -0,0 +1,45 @@
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import { CustomerPaymentReport } from '@/types/api/report/customer-payment';
|
||||
|
||||
export class FinanceApiService extends BaseApiService<
|
||||
CustomerPaymentReport,
|
||||
unknown,
|
||||
unknown
|
||||
> {
|
||||
constructor(basePath: string) {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
async getCustomerPaymentReport(
|
||||
customer_id?: string,
|
||||
sales?: string,
|
||||
filter_by?: 'do_date',
|
||||
start_date?: string,
|
||||
end_date?: string,
|
||||
page?: number,
|
||||
limit?: number
|
||||
): Promise<BaseApiResponse<CustomerPaymentReport> | undefined> {
|
||||
return await this.customRequest<BaseApiResponse<CustomerPaymentReport>>(
|
||||
`customer-payment`,
|
||||
{
|
||||
method: 'GET',
|
||||
params: {
|
||||
customer_id: customer_id,
|
||||
sales: sales,
|
||||
filter_by: filter_by,
|
||||
start_date: start_date,
|
||||
end_date: end_date,
|
||||
page: page,
|
||||
limit: limit,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const FinanceApi = new FinanceApiService('reports');
|
||||
|
||||
// export const FinanceApi = new FinanceApiService(
|
||||
// 'http://localhost:4010/api/reports/finance'
|
||||
// );
|
||||
Reference in New Issue
Block a user