Dealer_Onboard_Frontend/src/services/onboarding.service.ts

121 lines
4.0 KiB
TypeScript

import { API } from '../api/API';
export const onboardingService = {
submitApplication: async (data: any) => {
try {
const response: any = await API.submitApplication(data);
return response.data;
} catch (error) {
console.error('Submit application error:', error);
throw error;
}
},
getApplications: async () => {
try {
const response: any = await API.getApplications();
return response.data?.data || response.data;
} catch (error) {
console.error('Get applications error:', error);
throw error;
}
},
shortlistApplications: async (applicationIds: string[], assignedTo: string[], remarks?: string) => {
try {
const response: any = await API.shortlistApplications({ applicationIds, assignedTo, remarks });
return response.data;
} catch (error) {
console.error('Shortlist applications error:', error);
throw error;
}
},
getApplicationById: async (id: string) => {
try {
const response: any = await API.getApplicationById(id);
return response.data?.data || response.data;
} catch (error) {
console.error('Get application by id error:', error);
throw error;
}
},
getUsers: async () => {
try {
const response: any = await API.getUsers();
return response.data?.data || response.data;
} catch (error) {
console.error('Get users error:', error);
throw error;
}
},
addParticipant: async (data: any) => {
try {
const response: any = await API.addParticipant(data);
return response.data;
} catch (error) {
console.error('Add participant error:', error);
throw error;
}
},
scheduleInterview: async (data: any) => {
try {
const response: any = await API.scheduleInterview(data);
return response.data;
} catch (error) {
console.error('Schedule interview error:', error);
throw error;
}
},
getInterviews: async (applicationId: string) => {
try {
const response: any = await API.getInterviews(applicationId);
return response.data?.data || response.data;
} catch (error) {
console.error('Get interviews error:', error);
throw error;
}
},
getDocuments: async (id: string) => {
try {
const response: any = await API.getDocuments(id);
return response.data?.data || response.data;
} catch (error) {
console.error('Get documents error:', error);
throw error;
}
},
uploadDocument: async (id: string, data: any) => {
try {
const response: any = await API.uploadDocument(id, data);
return response.data;
} catch (error) {
console.error('Upload document error:', error);
throw error;
}
},
submitKTMatrix: async (data: any) => {
try {
const response: any = await API.submitKTMatrix(data);
if (response.ok) {
return response.data;
} else {
throw new Error(response.problem || 'Failed to submit KT Matrix');
}
} catch (error) {
console.error('Submit KT Matrix error:', error);
throw error;
}
},
submitLevel2Feedback: async (data: any) => {
try {
const response: any = await API.submitLevel2Feedback(data);
if (response.ok) {
return response.data;
} else {
throw new Error(response.problem || 'Failed to submit Level 2 Feedback');
}
} catch (error) {
console.error('Submit Level 2 Feedback error:', error);
throw error;
}
}
};