import { AddReq, DelReq, EditReq, InfoReq, UserPageQuery } from '@fast-crud/fast-crud';
import { request } from '/@/utils/service';

export const apiPrefix = '/api/system/borrow/application/?status=1';

export function GetList(query: UserPageQuery) {
	return request({
		url: apiPrefix,
		method: 'get',
		params: query,
	});
}

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,
		// headers:{
		// 	"Authorization":"JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzgzMjIyOTM2LCJpYXQiOjE3NTE2ODY5MzYsImp0aSI6ImMxNmQ4N2Y0NzdhMTQwN2FiN2Q3MmY3OTA2YzdhNmYwIiwidXNlcl9pZCI6MX0.NGSukWjyl_WlpMBAQ3VyGtc5O5ZRgdTlAjp0cEtgoLw"
		// }
	});
}

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

export function DelObj(id: DelReq) {
	return request({
		url: apiPrefix + id + '/',
		method: 'delete',
		data: { id },
	});
}



export function Switchspost(tenant_id:number) {
	return request({
		url: '/api/system/tenant/switch/',
		method: 'post',
		data: {tenant_id},
	});
}


export function BorrowingReview(id:number,action:string,remark:string,warehouse?:number) {
	return request({
		url: `/api/system/borrow/application/${id}/review/`,
		method: 'post',
		data: {action,remark,warehouse},
	});
}

export function GetWarehouseList(query: {page: number, limit: number}) {
	return request({
		url: '/api/system/warehouse/',
		method: 'get',
		params: query,
	});
}

// export function getUserInfo(id: number) {
// 	request({
// 		url: `/api/system/app_user/${id}/`,
// 		method: 'get',
// 	});
//   }
  