diff --git a/frontend/src/lib/@api/candidate.ts b/frontend/src/lib/@api/candidate.ts index 277deee..fc7b58b 100644 --- a/frontend/src/lib/@api/candidate.ts +++ b/frontend/src/lib/@api/candidate.ts @@ -3,7 +3,7 @@ import type { CandidateData, CandidateLogin } from '$lib/stores/candidate'; import type { SubmissionProgress } from '$lib/stores/portfolio'; import { API_URL, errorHandler } from '.'; -export async function apiWhoami(): Promise { +export const apiWhoami = async (): Promise => { try { const res = await axios.get(`${API_URL}/whoami`); return res.data; @@ -12,7 +12,7 @@ export async function apiWhoami(): Promise { } } -export async function apiLogin(data: CandidateLogin): Promise { +export const apiLogin = async (data: CandidateLogin): Promise => { try { const res = await axios.post(API_URL + '/candidate/login', data, { withCredentials: true }); return data.applicationId; @@ -22,15 +22,15 @@ export async function apiLogin(data: CandidateLogin): Promise { } // TODO -export async function apiLogout() { +export const apiLogout = async (fetchSsr?: any) => { try { - await axios.post(API_URL + '/candidate/logout', { withCredentials: true }); + fetchSsr ? await fetchSsr(API_URL + '/candidate/logout', { method: 'POST', credentials: 'include' }) : await axios.post(API_URL + '/candidate/logout', { withCredentials: true }); } catch (e: any) { throw errorHandler(e, 'Logout failed'); } } -export async function apiFillDetails(data: CandidateData): Promise { +export const apiFillDetails = async (data: CandidateData): Promise => { console.log(data); try { const res = await axios.post(API_URL + '/candidate/details', data, { withCredentials: true }); @@ -40,7 +40,7 @@ export async function apiFillDetails(data: CandidateData): Promise { +export const apiFetchDetails = async (): Promise => { try { const res = await axios.get(API_URL + '/candidate/details', { withCredentials: true }); return res.data; @@ -49,7 +49,7 @@ export async function apiFetchDetails(): Promise { } } -export async function apiFetchSubmissionProgress(): Promise { +export const apiFetchSubmissionProgress = async (): Promise => { try { const res = await axios.get(API_URL + '/candidate/portfolio/submission_progress', { withCredentials: true }); return res.data; @@ -58,10 +58,10 @@ export async function apiFetchSubmissionProgress(): Promise } } -export async function apiUploadCoverLetter( +export const apiUploadCoverLetter = async ( letter: File, progressReporter: (progress: AxiosProgressEvent) => void -): Promise { +): Promise => { try { const res = await axios.post(API_URL + '/candidate/add/cover_letter', letter, { withCredentials: true, @@ -77,10 +77,10 @@ export async function apiUploadCoverLetter( } } -export async function apiUploadPortfolioLetter( +export const apiUploadPortfolioLetter = async ( letter: File, progressReporter: (progress: AxiosProgressEvent) => void -): Promise { +): Promise => { try { const res = await axios.post(API_URL + '/candidate/add/portfolio_letter', letter, { withCredentials: true, @@ -96,10 +96,10 @@ export async function apiUploadPortfolioLetter( } } -export async function apiUploadPortfolioZip( +export const apiUploadPortfolioZip = async ( portfolio: File, progressReporter: (progress: AxiosProgressEvent) => void -): Promise { +): Promise => { try { const res = await axios.post(API_URL + '/candidate/add/portfolio_zip', portfolio, { withCredentials: true,