mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-09 09:41:37 +00:00
feat: refactor modal location, add error, remove any
This commit is contained in:
parent
af80faaa12
commit
c1b065ef7d
3 changed files with 19 additions and 10 deletions
|
|
@ -13,7 +13,7 @@ export const apiLogin = async (data: AdminLogin): Promise<number> => {
|
||||||
try {
|
try {
|
||||||
await axios.post(API_URL + '/admin/login', data, { withCredentials: true });
|
await axios.post(API_URL + '/admin/login', data, { withCredentials: true });
|
||||||
return data.adminId;
|
return data.adminId;
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
throw errorHandler(e, 'Login failed');
|
throw errorHandler(e, 'Login failed');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -24,7 +24,7 @@ export const apiCreateCandidate = async (data: CreateCandidate): Promise<CreateC
|
||||||
try {
|
try {
|
||||||
const res = await axios.post(API_URL + '/admin/create', data, { withCredentials: true });
|
const res = await axios.post(API_URL + '/admin/create', data, { withCredentials: true });
|
||||||
return res.data;
|
return res.data;
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
throw errorHandler(e, 'Candidate creation failed');
|
throw errorHandler(e, 'Candidate creation failed');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -48,7 +48,7 @@ export const apiResetCandidatePassword = async (id: number): Promise<CreateCandi
|
||||||
{ withCredentials: true }
|
{ withCredentials: true }
|
||||||
);
|
);
|
||||||
return res.data;
|
return res.data;
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
throw errorHandler(e, 'Candidate creation failed');
|
throw errorHandler(e, 'Candidate creation failed');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -60,7 +60,7 @@ export const apiGetCandidatePortfolio = async (id: number): Promise<Blob> => {
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
});
|
});
|
||||||
return await res.blob();
|
return await res.blob();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
throw errorHandler(e, 'Candidate portfolio failed');
|
throw errorHandler(e, 'Candidate portfolio failed');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { ApiError } from '$lib/@api';
|
||||||
import { apiCreateCandidate } from '$lib/@api/admin';
|
import { apiCreateCandidate } from '$lib/@api/admin';
|
||||||
import type { CreateCandidate, CreateCandidateLogin } from '$lib/stores/candidate';
|
import type { CreateCandidate, CreateCandidateLogin } from '$lib/stores/candidate';
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
import Modal from '../Modal.svelte';
|
import Modal from '../../Modal.svelte';
|
||||||
import IdField from '../textfield/IdField.svelte';
|
import IdField from '../../textfield/IdField.svelte';
|
||||||
import NumberField from '../textfield/NumberField.svelte';
|
import NumberField from '../../textfield/NumberField.svelte';
|
||||||
|
|
||||||
let isOpened = true;
|
let isOpened = true;
|
||||||
|
|
||||||
|
|
@ -13,6 +14,8 @@
|
||||||
|
|
||||||
let login: CreateCandidateLogin;
|
let login: CreateCandidateLogin;
|
||||||
|
|
||||||
|
let error: string = '';
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
const createCandidate = async () => {
|
const createCandidate = async () => {
|
||||||
|
|
@ -23,8 +26,9 @@
|
||||||
try {
|
try {
|
||||||
login = await apiCreateCandidate(data);
|
login = await apiCreateCandidate(data);
|
||||||
dispatch('created');
|
dispatch('created');
|
||||||
} catch (e) {
|
} catch (e: unknown) {
|
||||||
console.log(e);
|
console.error(e);
|
||||||
|
error = (e as ApiError).msg;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -42,6 +46,11 @@
|
||||||
<h1 class="text-sspsBlue text-3xl font-semibold">{login.password}</h1>
|
<h1 class="text-sspsBlue text-3xl font-semibold">{login.password}</h1>
|
||||||
{:else}
|
{:else}
|
||||||
<h1 class="text-sspsBlue text-3xl font-semibold">Registrace nového uchazeče</h1>
|
<h1 class="text-sspsBlue text-3xl font-semibold">Registrace nového uchazeče</h1>
|
||||||
|
{#if error}
|
||||||
|
<div class="my-2 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
|
||||||
|
<span class="block sm:inline">{error}</span>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<h3 class="my-4">Evidenčni číslo přihlášky</h3>
|
<h3 class="my-4">Evidenčni číslo přihlášky</h3>
|
||||||
<NumberField bind:value={applicationId} />
|
<NumberField bind:value={applicationId} />
|
||||||
<h3 class="my-4">Rodné číslo</h3>
|
<h3 class="my-4">Rodné číslo</h3>
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import Home from '$lib/components/icons/Home.svelte';
|
import Home from '$lib/components/icons/Home.svelte';
|
||||||
import TextField from '$lib/components/textfield/TextField.svelte';
|
import TextField from '$lib/components/textfield/TextField.svelte';
|
||||||
import type { CandidatePreview } from '$lib/stores/candidate';
|
import type { CandidatePreview } from '$lib/stores/candidate';
|
||||||
import CreateCandidateModal from '$lib/components/admin/CreateCandidateModal.svelte';
|
import CreateCandidateModal from '$lib/components/admin/modal/CreateCandidateModal.svelte';
|
||||||
import Fuse from 'fuse.js';
|
import Fuse from 'fuse.js';
|
||||||
import type { PageServerData } from './$types';
|
import type { PageServerData } from './$types';
|
||||||
import Delete from '$lib/components/button/Delete.svelte';
|
import Delete from '$lib/components/button/Delete.svelte';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue