65 lines
1.9 KiB
JavaScript
65 lines
1.9 KiB
JavaScript
import { request } from '../lib/apiClient'
|
|
|
|
/* ============================================================
|
|
requisitions.js — backend/candidate_forms/app.py requisition routes.
|
|
|
|
Standalone Annexure A table (app.requisitions), not candidate_forms.
|
|
created_by comes from the JWT on the server — do not send it in the body.
|
|
============================================================ */
|
|
|
|
export const EMPLOYMENT_TYPES = [
|
|
{ value: 'permanent', label: 'Permanent' },
|
|
{ value: 'contract', label: 'Contract' },
|
|
{ value: 'temporary', label: 'Temporary' },
|
|
{ value: 'internee', label: 'Internee' },
|
|
]
|
|
|
|
export const EMPLOYMENT_TYPE_LABEL = Object.fromEntries(
|
|
EMPLOYMENT_TYPES.map((t) => [t.value, t.label]),
|
|
)
|
|
|
|
export function list() {
|
|
return request('/forms/requisition/fetch')
|
|
}
|
|
|
|
export function getById(formId) {
|
|
return request('/forms/requisition/fetch', { params: { form_id: formId } })
|
|
}
|
|
|
|
/** Searchable picker — GET /forms/requisition/search. `q` matches title or department.
|
|
* `jobPostId` keeps the job's current requisition in the list while editing. */
|
|
export function search({ q, top, jobPostId } = {}) {
|
|
return request('/forms/requisition/search', {
|
|
params: {
|
|
q: q || undefined,
|
|
top,
|
|
job_post_id: jobPostId || undefined,
|
|
},
|
|
})
|
|
}
|
|
|
|
export function create(body) {
|
|
return request('/forms/requisition/create', { method: 'POST', body })
|
|
}
|
|
|
|
export function update(formId, body) {
|
|
return request('/forms/requisition/update', {
|
|
method: 'PATCH',
|
|
params: { form_id: formId },
|
|
body,
|
|
})
|
|
}
|
|
|
|
export function toRows(res) {
|
|
const data = res?.data
|
|
if (Array.isArray(data)) return data
|
|
if (data) return [data]
|
|
return []
|
|
}
|
|
|
|
export function approvalStatus(row) {
|
|
if (row?.approved_by_svp) return { key: 'approved', label: 'Approved' }
|
|
if (row?.approved_by_hr || row?.approved_by_vp) return { key: 'review', label: 'In review' }
|
|
return { key: 'open', label: 'Open' }
|
|
}
|