mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-18 22:11:14 +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> => {
|
||||
const apiFetch = fetchSsr || fetch;
|
||||
try {
|
||||
console.log(API_URL + '/candidate/whoami');
|
||||
const res = await apiFetch(API_URL + '/candidate/whoami', {
|
||||
method: 'GET',
|
||||
credentials: 'include'
|
||||
|
|
@ -100,7 +99,6 @@ export const apiFillDetails = async (data: CandidateData): Promise<CandidateData
|
|||
});
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
try {
|
||||
const res = await axios.post(API_URL + '/candidate/details', data, { withCredentials: true });
|
||||
return res.data;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { apiGetCandidatePortfolio, apiResetCandidatePassword } from '$lib/@api/admin';
|
||||
import type { CandidateData } from '$lib/stores/candidate';
|
||||
import { SvelteToast, toast } from '@zerodevx/svelte-toast';
|
||||
|
||||
export let id: number;
|
||||
export let candidateData: CandidateData;
|
||||
|
|
@ -13,7 +14,13 @@
|
|||
const res = await apiResetCandidatePassword(id);
|
||||
alert('Nove heslo: ' + res.password);
|
||||
} 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);
|
||||
link.click();
|
||||
} 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>
|
||||
|
||||
<SvelteToast />
|
||||
<div class="flex h-screen w-full items-center justify-center">
|
||||
<div class="mr-8 max-w-sm">
|
||||
<div class="rounded-lg bg-white p-10 shadow-xl">
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
import { baseCandidateData, candidateData } from '$lib/stores/candidate';
|
||||
import tippy, { sticky } from 'tippy.js';
|
||||
import { goto } from '$app/navigation';
|
||||
import { pushErrorText } from '$lib/utils/toast';
|
||||
|
||||
export let title: string;
|
||||
export let status: Status;
|
||||
|
|
@ -62,7 +63,7 @@
|
|||
document.body.appendChild(link);
|
||||
link.click();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
pushErrorText("Chyba při stahování portfolia");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -31,12 +31,10 @@
|
|||
|
||||
$: if ($submissionProgress) {
|
||||
status = getStatus();
|
||||
// console.log('type' + fileType + ' status: ' + status);
|
||||
fileDropped = status === 'uploaded' || status === 'submitted';
|
||||
}
|
||||
|
||||
const getStatus = (): Status => {
|
||||
console.log($submissionProgress);
|
||||
switch ($submissionProgress.status) {
|
||||
case UploadStatus.None:
|
||||
return 'missing';
|
||||
|
|
@ -71,7 +69,6 @@
|
|||
};
|
||||
|
||||
const onFileDrop = (dropped: Files) => {
|
||||
console.log(dropped);
|
||||
if (dropped.accepted.length > 0) {
|
||||
fileDropped = true;
|
||||
const file = dropped.accepted[0];
|
||||
|
|
@ -79,7 +76,6 @@
|
|||
dispatch('filedrop', {
|
||||
file: file,
|
||||
callback: (progressEvent: AxiosProgressEvent) => {
|
||||
console.log(progressEvent.bytes);
|
||||
progress = progressEvent.progress!;
|
||||
bytesTotal = progressEvent.total ?? 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
if (number !== null && number !== undefined) {
|
||||
country = number.country!;
|
||||
}
|
||||
// console.log(country);
|
||||
}
|
||||
|
||||
// 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 Logout from '$lib/components/icons/Logout.svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { pushErrorText } from '$lib/utils/toast';
|
||||
import { SvelteToast } from '@zerodevx/svelte-toast';
|
||||
|
||||
export let data: PageServerData;
|
||||
|
||||
|
|
@ -20,7 +22,7 @@
|
|||
try {
|
||||
candidates = await apiListCandidates(undefined, activeFilter.filter);
|
||||
} catch {
|
||||
console.log('error');
|
||||
pushErrorText('Nepodařilo se načíst uchazeče');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -93,7 +95,7 @@
|
|||
link.setAttribute('download', 'UCHAZECI' + '.csv');
|
||||
link.click();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
pushErrorText('Nepodařilo se stáhnout CSV');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -110,6 +112,7 @@
|
|||
{/if}
|
||||
|
||||
<div>
|
||||
<SvelteToast />
|
||||
<header class="absolute h-14 w-full">
|
||||
<img class="h-12 w-full object-cover blur-sm filter" src={bacgkround} alt="Background" />
|
||||
</header>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
import { goto } from '$app/navigation';
|
||||
import Submit from '$lib/components/button/Submit.svelte';
|
||||
import PasswordField from '$lib/components/textfield/PasswordField.svelte';
|
||||
import { SvelteToast } from '@zerodevx/svelte-toast';
|
||||
import { pushErrorText } from '$lib/utils/toast';
|
||||
|
||||
let adminIdValue = '';
|
||||
let adminPasswordValue = '';
|
||||
|
|
@ -19,11 +21,12 @@
|
|||
await apiLogin({ adminId: Number(adminIdValue), password: adminPasswordValue });
|
||||
goto('/admin/dashboard');
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
pushErrorText('Neplatné heslo nebo ID!');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<SvelteToast />
|
||||
<SplitLayout backgroundImage={background} backgroundPosition="30%">
|
||||
<div class="form">
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
import LinkErrorModal from '$lib/components/modal/LinkErrorModal.svelte';
|
||||
import type { Writable } from 'svelte/store';
|
||||
import schoollistString from '$lib/assets/schoollist.txt?raw';
|
||||
import { countries } from '$lib/utils/countries';
|
||||
|
||||
let pageIndex = 0;
|
||||
let pagesFilled = [false, false, false, false, false, false, false, false];
|
||||
|
|
@ -251,11 +252,7 @@
|
|||
};
|
||||
|
||||
const onSubmit = async (values: CandidateData) => {
|
||||
console.log('submit button clicked');
|
||||
console.log(pagesFilled.map((_, i) => !isPageInvalid(i)));
|
||||
|
||||
if (pageIndex === pageCount) {
|
||||
console.log('submitting');
|
||||
// clone values to oldValues
|
||||
let oldValues = JSON.parse(JSON.stringify(values));
|
||||
try {
|
||||
|
|
@ -793,11 +790,9 @@
|
|||
<Submit
|
||||
on:click={async (e) => {
|
||||
if (pageIndex === 4) {
|
||||
console.log('validating personal id');
|
||||
validatePersonalId();
|
||||
}
|
||||
await handleSubmit(e);
|
||||
console.log(pagesFilled.map((_, i) => !isPageInvalid(i)));
|
||||
if (isPageInvalid(pageIndex)) return;
|
||||
if (pageIndex !== pageCount) {
|
||||
pagesFilled[pageIndex] = true;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@
|
|||
}
|
||||
|
||||
const submit = async () => {
|
||||
console.log('submitting: ', codeValueArray);
|
||||
try {
|
||||
await apiLogin({ applicationId, password: codeValueMobile });
|
||||
goto('/dashboard');
|
||||
|
|
|
|||
Loading…
Reference in a new issue