import { AxiosRequestConfig } from 'axios'
import axios from '../../../config/axios'

export const fetchPrograms = () => {
  return axios.get('/square/branches').then((res) => res.data)
}
export const fetchFacultyUsers = async ({ ...rest }) => {
  const res = await axios.get(`/hrms/employees`, {
    params: { ...rest },
  })
  return res.data?.data?.map((item) => ({
    label: item?.fullName,
    value: item?._id,
  }))
}
export const FundingSources = {
  self_funding: 'Self Funding',
  government_grants: 'Government Grants',
  private_sponsors: 'Private Sponsors',
  no_funding: 'Not Funded',
}
export const PatentStatus = {
  patented: 'Patented',
  no_patent: 'No Patent',
}
export const createProject = async ({ _id, ...postBody }) => {
  const config: AxiosRequestConfig = {
    method: _id ? 'PUT' : 'POST',
    url: _id
      ? `/square/research-projects/${_id}/update`
      : '/square/research-projects',
    data: postBody,
  }
  const res = await axios(config)
  return res.data
}

export const uploadFiles = (postBody) => {
  return axios
    .post(`/square/research-projects/upload`, postBody)
    .then((res) => res.data)
}
