feat(admin dashboard): show createdAt

This commit is contained in:
Sebastian Pravda 2023-02-15 15:51:26 +01:00
parent d2cabea219
commit 6d1b3a86c0
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57

View file

@ -101,15 +101,18 @@ export const apiLogout = async (fetchSsr?: Fetch) => {
// List all candidates /admin/list/candidates // List all candidates /admin/list/candidates
export const apiListCandidates = async ( export const apiListCandidates = async (
fetchSsr?: Fetch, fetchSsr?: Fetch,
field?: string params: { field?: string; column?: 'createdAt' | 'application', order?: 'asc' | 'desc' } = {column: 'createdAt', order: 'desc'}
): Promise<Array<CandidatePreview>> => { ): Promise<Array<CandidatePreview>> => {
const apiFetch = fetchSsr || fetch; const apiFetch = fetchSsr || fetch;
const params = new URLSearchParams(); const searchParams = new URLSearchParams();
if (field) { if (params.field) {
params.append('field', field); searchParams.append('field', params.field);
}
if (params.column) {
searchParams.append('sort', `${params.column}_${params.order}`);
} }
try { try {
const res = await apiFetch(API_URL + '/admin/list/candidates?' + params.toString(), { const res = await apiFetch(API_URL + '/admin/list/candidates?' + searchParams.toString(), {
method: 'GET', method: 'GET',
credentials: 'include' credentials: 'include'
}); });