mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-07 03:50:36 +00:00
feat: use SvelteToast instead of console, console.log() cleanup
This commit is contained in:
parent
3627b0079a
commit
cc5fa60c62
11 changed files with 40 additions and 20 deletions
|
|
@ -54,7 +54,6 @@ export const apiFetchSubmissionProgress = async (fetchSsr?: Fetch): Promise<Subm
|
||||||
export const apiWhoami = async (fetchSsr?: Fetch): Promise<BaseCandidate> => {
|
export const apiWhoami = async (fetchSsr?: Fetch): Promise<BaseCandidate> => {
|
||||||
const apiFetch = fetchSsr || fetch;
|
const apiFetch = fetchSsr || fetch;
|
||||||
try {
|
try {
|
||||||
console.log(API_URL + '/candidate/whoami');
|
|
||||||
const res = await apiFetch(API_URL + '/candidate/whoami', {
|
const res = await apiFetch(API_URL + '/candidate/whoami', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
|
|
@ -100,7 +99,6 @@ export const apiFillDetails = async (data: CandidateData): Promise<CandidateData
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(data);
|
|
||||||
try {
|
try {
|
||||||
const res = await axios.post(API_URL + '/candidate/details', data, { withCredentials: true });
|
const res = await axios.post(API_URL + '/candidate/details', data, { withCredentials: true });
|
||||||
return res.data;
|
return res.data;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { apiGetCandidatePortfolio, apiResetCandidatePassword } from '$lib/@api/admin';
|
import { apiGetCandidatePortfolio, apiResetCandidatePassword } from '$lib/@api/admin';
|
||||||
import type { CandidateData } from '$lib/stores/candidate';
|
import type { CandidateData } from '$lib/stores/candidate';
|
||||||
|
import { SvelteToast, toast } from '@zerodevx/svelte-toast';
|
||||||
|
|
||||||
export let id: number;
|
export let id: number;
|
||||||
export let candidateData: CandidateData;
|
export let candidateData: CandidateData;
|
||||||
|
|
@ -13,7 +14,13 @@
|
||||||
const res = await apiResetCandidatePassword(id);
|
const res = await apiResetCandidatePassword(id);
|
||||||
alert('Nove heslo: ' + res.password);
|
alert('Nove heslo: ' + res.password);
|
||||||
} catch {
|
} catch {
|
||||||
console.log('error');
|
toast.push('Rodné číslo neodpovídá oficiální specifikaci či datumu narození', {
|
||||||
|
theme: {
|
||||||
|
'--toastColor': 'mintcream',
|
||||||
|
'--toastBackground': '#b91c1c',
|
||||||
|
'--toastBarBackground': '#7f1d1d'
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -27,11 +34,18 @@
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
toast.push('Rodné číslo neodpovídá oficiální specifikaci či datumu narození', {
|
||||||
|
theme: {
|
||||||
|
'--toastColor': 'mintcream',
|
||||||
|
'--toastBackground': '#b91c1c',
|
||||||
|
'--toastBarBackground': '#7f1d1d'
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<SvelteToast />
|
||||||
<div class="flex h-screen w-full items-center justify-center">
|
<div class="flex h-screen w-full items-center justify-center">
|
||||||
<div class="mr-8 max-w-sm">
|
<div class="mr-8 max-w-sm">
|
||||||
<div class="rounded-lg bg-white p-10 shadow-xl">
|
<div class="rounded-lg bg-white p-10 shadow-xl">
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
import { baseCandidateData, candidateData } from '$lib/stores/candidate';
|
import { baseCandidateData, candidateData } from '$lib/stores/candidate';
|
||||||
import tippy, { sticky } from 'tippy.js';
|
import tippy, { sticky } from 'tippy.js';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
import { pushErrorText } from '$lib/utils/toast';
|
||||||
|
|
||||||
export let title: string;
|
export let title: string;
|
||||||
export let status: Status;
|
export let status: Status;
|
||||||
|
|
@ -62,7 +63,7 @@
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
pushErrorText("Chyba při stahování portfolia");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,10 @@
|
||||||
|
|
||||||
$: if ($submissionProgress) {
|
$: if ($submissionProgress) {
|
||||||
status = getStatus();
|
status = getStatus();
|
||||||
// console.log('type' + fileType + ' status: ' + status);
|
|
||||||
fileDropped = status === 'uploaded' || status === 'submitted';
|
fileDropped = status === 'uploaded' || status === 'submitted';
|
||||||
}
|
}
|
||||||
|
|
||||||
const getStatus = (): Status => {
|
const getStatus = (): Status => {
|
||||||
console.log($submissionProgress);
|
|
||||||
switch ($submissionProgress.status) {
|
switch ($submissionProgress.status) {
|
||||||
case UploadStatus.None:
|
case UploadStatus.None:
|
||||||
return 'missing';
|
return 'missing';
|
||||||
|
|
@ -71,7 +69,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFileDrop = (dropped: Files) => {
|
const onFileDrop = (dropped: Files) => {
|
||||||
console.log(dropped);
|
|
||||||
if (dropped.accepted.length > 0) {
|
if (dropped.accepted.length > 0) {
|
||||||
fileDropped = true;
|
fileDropped = true;
|
||||||
const file = dropped.accepted[0];
|
const file = dropped.accepted[0];
|
||||||
|
|
@ -79,7 +76,6 @@
|
||||||
dispatch('filedrop', {
|
dispatch('filedrop', {
|
||||||
file: file,
|
file: file,
|
||||||
callback: (progressEvent: AxiosProgressEvent) => {
|
callback: (progressEvent: AxiosProgressEvent) => {
|
||||||
console.log(progressEvent.bytes);
|
|
||||||
progress = progressEvent.progress!;
|
progress = progressEvent.progress!;
|
||||||
bytesTotal = progressEvent.total ?? 0;
|
bytesTotal = progressEvent.total ?? 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
if (number !== null && number !== undefined) {
|
if (number !== null && number !== undefined) {
|
||||||
country = number.country!;
|
country = number.country!;
|
||||||
}
|
}
|
||||||
// console.log(country);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validity
|
// Validity
|
||||||
|
|
|
||||||
1
frontend/src/lib/utils/countries.ts
Normal file
1
frontend/src/lib/utils/countries.ts
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export const countries = ["Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua & Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia & Herzegovina","Botswana","Brazil","British Virgin Islands","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Cape Verde","Cayman Islands","Chad","Chile","China","Colombia","Congo","Cook Islands","Costa Rica","Cote D Ivoire","Croatia","Cruise Ship","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Polynesia","French West Indies","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guam","Guatemala","Guernsey","Guinea","Guinea Bissau","Guyana","Haiti","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Isle of Man","Israel","Italy","Jamaica","Japan","Jersey","Jordan","Kazakhstan","Kenya","Kuwait","Kyrgyz Republic","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macau","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Mauritania","Mauritius","Mexico","Moldova","Monaco","Mongolia","Montenegro","Montserrat","Morocco","Mozambique","Namibia","Nepal","Netherlands","Netherlands Antilles","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","Norway","Oman","Pakistan","Palestine","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Puerto Rico","Qatar","Reunion","Romania","Russia","Rwanda","Saint Pierre & Miquelon","Samoa","San Marino","Satellite","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","South Africa","South Korea","Spain","Sri Lanka","St Kitts & Nevis","St Lucia","St Vincent","St. Lucia","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Timor L'Este","Togo","Tonga","Trinidad & Tobago","Tunisia","Turkey","Turkmenistan","Turks & Caicos","Uganda","Ukraine","United Arab Emirates","United Kingdom","Uruguay","Uzbekistan","Venezuela","Vietnam","Virgin Islands (US)","Yemen","Zambia","Zimbabwe"];
|
||||||
11
frontend/src/lib/utils/toast.ts
Normal file
11
frontend/src/lib/utils/toast.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { toast } from "@zerodevx/svelte-toast";
|
||||||
|
|
||||||
|
export const pushErrorText = (text: string) => {
|
||||||
|
toast.push(text, {
|
||||||
|
theme: {
|
||||||
|
'--toastColor': 'mintcream',
|
||||||
|
'--toastBackground': '#b91c1c',
|
||||||
|
'--toastBarBackground': '#7f1d1d'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
import bacgkround from '$lib/assets/background.jpg';
|
import bacgkround from '$lib/assets/background.jpg';
|
||||||
import Logout from '$lib/components/icons/Logout.svelte';
|
import Logout from '$lib/components/icons/Logout.svelte';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
import { pushErrorText } from '$lib/utils/toast';
|
||||||
|
import { SvelteToast } from '@zerodevx/svelte-toast';
|
||||||
|
|
||||||
export let data: PageServerData;
|
export let data: PageServerData;
|
||||||
|
|
||||||
|
|
@ -20,7 +22,7 @@
|
||||||
try {
|
try {
|
||||||
candidates = await apiListCandidates(undefined, activeFilter.filter);
|
candidates = await apiListCandidates(undefined, activeFilter.filter);
|
||||||
} catch {
|
} catch {
|
||||||
console.log('error');
|
pushErrorText('Nepodařilo se načíst uchazeče');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -93,7 +95,7 @@
|
||||||
link.setAttribute('download', 'UCHAZECI' + '.csv');
|
link.setAttribute('download', 'UCHAZECI' + '.csv');
|
||||||
link.click();
|
link.click();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
pushErrorText('Nepodařilo se stáhnout CSV');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -110,6 +112,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
<SvelteToast />
|
||||||
<header class="absolute h-14 w-full">
|
<header class="absolute h-14 w-full">
|
||||||
<img class="h-12 w-full object-cover blur-sm filter" src={bacgkround} alt="Background" />
|
<img class="h-12 w-full object-cover blur-sm filter" src={bacgkround} alt="Background" />
|
||||||
</header>
|
</header>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import Submit from '$lib/components/button/Submit.svelte';
|
import Submit from '$lib/components/button/Submit.svelte';
|
||||||
import PasswordField from '$lib/components/textfield/PasswordField.svelte';
|
import PasswordField from '$lib/components/textfield/PasswordField.svelte';
|
||||||
|
import { SvelteToast } from '@zerodevx/svelte-toast';
|
||||||
|
import { pushErrorText } from '$lib/utils/toast';
|
||||||
|
|
||||||
let adminIdValue = '';
|
let adminIdValue = '';
|
||||||
let adminPasswordValue = '';
|
let adminPasswordValue = '';
|
||||||
|
|
@ -19,11 +21,12 @@
|
||||||
await apiLogin({ adminId: Number(adminIdValue), password: adminPasswordValue });
|
await apiLogin({ adminId: Number(adminIdValue), password: adminPasswordValue });
|
||||||
goto('/admin/dashboard');
|
goto('/admin/dashboard');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
pushErrorText('Neplatné heslo nebo ID!');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<SvelteToast />
|
||||||
<SplitLayout backgroundImage={background} backgroundPosition="30%">
|
<SplitLayout backgroundImage={background} backgroundPosition="30%">
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
import LinkErrorModal from '$lib/components/modal/LinkErrorModal.svelte';
|
import LinkErrorModal from '$lib/components/modal/LinkErrorModal.svelte';
|
||||||
import type { Writable } from 'svelte/store';
|
import type { Writable } from 'svelte/store';
|
||||||
import schoollistString from '$lib/assets/schoollist.txt?raw';
|
import schoollistString from '$lib/assets/schoollist.txt?raw';
|
||||||
|
import { countries } from '$lib/utils/countries';
|
||||||
|
|
||||||
let pageIndex = 0;
|
let pageIndex = 0;
|
||||||
let pagesFilled = [false, false, false, false, false, false, false, false];
|
let pagesFilled = [false, false, false, false, false, false, false, false];
|
||||||
|
|
@ -251,11 +252,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async (values: CandidateData) => {
|
const onSubmit = async (values: CandidateData) => {
|
||||||
console.log('submit button clicked');
|
|
||||||
console.log(pagesFilled.map((_, i) => !isPageInvalid(i)));
|
|
||||||
|
|
||||||
if (pageIndex === pageCount) {
|
if (pageIndex === pageCount) {
|
||||||
console.log('submitting');
|
|
||||||
// clone values to oldValues
|
// clone values to oldValues
|
||||||
let oldValues = JSON.parse(JSON.stringify(values));
|
let oldValues = JSON.parse(JSON.stringify(values));
|
||||||
try {
|
try {
|
||||||
|
|
@ -793,11 +790,9 @@
|
||||||
<Submit
|
<Submit
|
||||||
on:click={async (e) => {
|
on:click={async (e) => {
|
||||||
if (pageIndex === 4) {
|
if (pageIndex === 4) {
|
||||||
console.log('validating personal id');
|
|
||||||
validatePersonalId();
|
validatePersonalId();
|
||||||
}
|
}
|
||||||
await handleSubmit(e);
|
await handleSubmit(e);
|
||||||
console.log(pagesFilled.map((_, i) => !isPageInvalid(i)));
|
|
||||||
if (isPageInvalid(pageIndex)) return;
|
if (isPageInvalid(pageIndex)) return;
|
||||||
if (pageIndex !== pageCount) {
|
if (pageIndex !== pageCount) {
|
||||||
pagesFilled[pageIndex] = true;
|
pagesFilled[pageIndex] = true;
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
console.log('submitting: ', codeValueArray);
|
|
||||||
try {
|
try {
|
||||||
await apiLogin({ applicationId, password: codeValueMobile });
|
await apiLogin({ applicationId, password: codeValueMobile });
|
||||||
goto('/dashboard');
|
goto('/dashboard');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue