mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-05 19:11:06 +00:00
feat(admin dashboard): show createdAt
This commit is contained in:
parent
d2cabea219
commit
6d1b3a86c0
1 changed files with 8 additions and 5 deletions
|
|
@ -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'
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue