import { API } from '@/api/API';

export const terminationService = {
    getTerminationById: async (id: string) => {
        const response = await API.getTerminationById(id);
        const data = response.data as any;
        return data?.termination || data?.data || data;
    },

    updateTerminationStatus: async (id: string, action: string, remarks: string) => {
        const response = await API.updateTerminationStatus(id, { action, remarks });
        return response.data;
    },

    issueSCN: async (id: string, scnData: any) => {
        const response = await API.issueSCN(id, scnData);
        return response.data;
    },

    uploadSCNResponse: async (id: string, file: File, remarks?: string) => {
        const formData = new FormData();
        formData.append('file', file);
        if (remarks) formData.append('remarks', remarks);
        const response = await API.uploadSCNResponse(id, formData);
        return response.data;
    },
    uploadDocument: async (id: string, formData: FormData) => {
        const response = await API.uploadTerminationDocument(id, formData);
        return response.data;
    },

    finalizeTermination: async (id: string, decision: 'Approve' | 'Reject' | 'Reconsider', remarks: string) => {
        const response = await API.finalizeTermination(id, { decision, remarks });
        return response.data;
    }
};
