import { request } from '/@/utils/service';
import { UserPageQuery, AddReq, DelReq, EditReq, InfoReq } from '@fast-crud/fast-crud';
import { Session } from '/@/utils/storage';
export const apiPrefix = '/api/system/talent_pool/';
export function GetList(query: UserPageQuery) {
	return request({
		url: apiPrefix,
		method: 'get',
		params: {...query,tenant_id:Session.get('tenant_id')},
	});
}
export function GetObj(id: InfoReq) {
	return request({
		url: apiPrefix + id,
		method: 'get',
	});
}

export function AddObj(obj: AddReq) {
	return request({
		url: apiPrefix,
		method: 'post',
		data: obj,
	});
}

export function UpdateObj(obj: EditReq) {
	return request({
		url: apiPrefix + obj.id + '/',
		method: 'put',
		data: obj,
	});
}

export function DelObj(id: DelReq) {
	return request({
		url:`/api/system/job_applications/${id}/?tenant_id=${Session.get('tenant_id')}`,
		method: 'delete',
		data: { id },
	});
}
export function GetPermission(query: UserPageQuery) {
    return request({
        url: apiPrefix,
        method: 'get',
		params: {...query,tenant_id:Session.get('tenant_id')}
    });
}

export function BulkUpdateStatus(data: {
	application_ids: number[];
	new_status: number;
	note?: string;
	tenant_id: string;
}) {
	return request({
		url: '/api/system/job_applications/bulk_update_status/',
		method: 'post',
		data
	});
}

export function updateBatchStatus(data: any) {
	return request({
		url: '/api/system/job_applications/bulk_update_status/',
		method: 'post',
		data
	});
}

export function updateBatchTags(data: {
	ids: number[];
	tag_ids: number[];
	tenant_id: number;
}) {
	return request({
		url: '/api/system/talent_pool/batch_update_tags/',
		method: 'post',
		data
	});
}

export function getApplicationStatusSummary() {
	return request({
		url: '/api/system/talent_pool/status_summary/?tenant_id='+Session.get('tenant_id'),
		method: 'get',
	});
}
	
export function exportData(query:any) {
	return request({
		url: `/api/system/talent_pool/export_data_minio_sync/?status=${query.status}&tenant_id=${Session.get('tenant_id')}`,
		method: 'get',
	
	});
}