feat: formatting

This commit is contained in:
EETagent 2023-01-26 22:51:33 +01:00
parent e009b6ee80
commit ec4fe74490
15 changed files with 127 additions and 108 deletions

View file

@ -1,7 +1,7 @@
{ {
"baseLocale": "cs", "baseLocale": "cs",
"adapter": "svelte", "adapter": "svelte",
"esmImports": true, "esmImports": true,
"outputPath": "./src/translations", "outputPath": "./src/translations",
"$schema": "https://unpkg.com/typesafe-i18n@5.20.0/schema/typesafe-i18n.json" "$schema": "https://unpkg.com/typesafe-i18n@5.20.0/schema/typesafe-i18n.json"
} }

View file

@ -6,7 +6,7 @@
export let applications: Array<number>; export let applications: Array<number>;
let title1 = $LL.components.checkbox.accountLinkCheckBox.multiple.title({ let title1 = $LL.components.checkbox.accountLinkCheckBox.multiple.title({
first: applications[0], first: applications[0],
second: applications[1], second: applications[1]
}); });
let title2 = $LL.components.checkbox.accountLinkCheckBox.multiple.title2({ let title2 = $LL.components.checkbox.accountLinkCheckBox.multiple.title2({
first: applications[0] first: applications[0]
@ -14,7 +14,7 @@
if (applications.length === 1) { if (applications.length === 1) {
title1 = $LL.components.checkbox.accountLinkCheckBox.single.title({ title1 = $LL.components.checkbox.accountLinkCheckBox.single.title({
first: applications[0], first: applications[0]
}); });
title2 = $LL.components.checkbox.accountLinkCheckBox.single.title2(); title2 = $LL.components.checkbox.accountLinkCheckBox.single.title2();
} }

View file

@ -13,7 +13,9 @@
<div class="w-full text-lg font-semibold">{$LL.components.checkbox.gdprCheckBox.title()}</div> <div class="w-full text-lg font-semibold">{$LL.components.checkbox.gdprCheckBox.title()}</div>
<div class="w-full text-sm">{$LL.components.checkbox.gdprCheckBox.description()}</div> <div class="w-full text-sm">{$LL.components.checkbox.gdprCheckBox.description()}</div>
<div class="w-full text-sm"><a class="underline" href="/gdpr">{$LL.components.checkbox.gdprCheckBox.here()}</a></div> <div class="w-full text-sm">
<a class="underline" href="/gdpr">{$LL.components.checkbox.gdprCheckBox.here()}</a>
</div>
</div> </div>
</label> </label>

View file

@ -5,10 +5,10 @@
export let personalIdErr: boolean = false; export let personalIdErr: boolean = false;
export let personalIdNumber: string; export let personalIdNumber: string;
let titleOk = $LL.components.checkbox.personalIdConfirmCheckBox.titleOk({ let titleOk = $LL.components.checkbox.personalIdConfirmCheckBox.titleOk({
personalId: personalIdNumber, personalId: personalIdNumber
}); });
let titleErr = $LL.components.checkbox.personalIdConfirmCheckBox.titleErr({ let titleErr = $LL.components.checkbox.personalIdConfirmCheckBox.titleErr({
personalId: personalIdNumber, personalId: personalIdNumber
}); });
export let error: string = ''; export let error: string = '';
@ -61,7 +61,9 @@
<div class="w-full text-lg font-semibold"> <div class="w-full text-lg font-semibold">
{titleErr} {titleErr}
</div> </div>
<div class="w-full text-sm">{$LL.components.checkbox.personalIdConfirmCheckBox.whatHappened()}</div> <div class="w-full text-sm">
{$LL.components.checkbox.personalIdConfirmCheckBox.whatHappened()}
</div>
</div> </div>
</label> </label>
</div> </div>

View file

@ -160,30 +160,33 @@
<span class="font-bold">{$baseCandidateData.applications[1]}</span></span <span class="font-bold">{$baseCandidateData.applications[1]}</span></span
> >
{/if} {/if}
<span>{$LL.input.address()}: <span class="font-bold">{$candidateData.candidate.address}</span></span>
<span <span
>{$LL.input.birthDate()}: <span class="font-bold">{$candidateData.candidate.birthdate}</span >{$LL.input.address()}:
></span <span class="font-bold">{$candidateData.candidate.address}</span></span
> >
<span <span
>{$LL.input.birthPlace()}: <span class="font-bold">{$candidateData.candidate.birthplace}</span >{$LL.input.birthDate()}:
></span <span class="font-bold">{$candidateData.candidate.birthdate}</span></span
> >
<span <span
>{$LL.input.personalIdentificationNumber()}: <span class="font-bold" >{$LL.input.birthPlace()}:
>{$candidateData.candidate.personalIdNumber}</span <span class="font-bold">{$candidateData.candidate.birthplace}</span></span
></span
> >
<span <span
>{$LL.input.schoolIzo()}: <span class="font-bold">{$candidateData.candidate.schoolName}</span >{$LL.input.personalIdentificationNumber()}:
></span <span class="font-bold">{$candidateData.candidate.personalIdNumber}</span></span
> >
<span <span
>{$LL.input.insuranceNumber()}: <span class="font-bold" >{$LL.input.schoolIzo()}:
>{$candidateData.candidate.healthInsurance}</span <span class="font-bold">{$candidateData.candidate.schoolName}</span></span
></span
> >
<span>{$LL.input.telephone()}: <span class="font-bold">{$candidateData.candidate.telephone}</span></span <span
>{$LL.input.insuranceNumber()}:
<span class="font-bold">{$candidateData.candidate.healthInsurance}</span></span
>
<span
>{$LL.input.telephone()}:
<span class="font-bold">{$candidateData.candidate.telephone}</span></span
> >
</div> </div>
<div <div
@ -202,7 +205,9 @@
>{parent.name + ' ' + parent.surname}</span >{parent.name + ' ' + parent.surname}</span
> >
<span>{$LL.input.email()}: <span class="font-bold">{parent.email}</span></span> <span>{$LL.input.email()}: <span class="font-bold">{parent.email}</span></span>
<span>{$LL.input.telephone()}: <span class="font-bold">{parent.telephone}</span></span> <span
>{$LL.input.telephone()}: <span class="font-bold">{parent.telephone}</span></span
>
</div> </div>
{/each} {/each}
</div> </div>

View file

@ -105,7 +105,8 @@
{#if status === 'uploaded'} {#if status === 'uploaded'}
<button <button
class="mr-3 rounded-xl bg-[#ef8b46] py-0.5 px-2 text-white shadow-md transition-all duration-300 hover:bg-orange-400" class="mr-3 rounded-xl bg-[#ef8b46] py-0.5 px-2 text-white shadow-md transition-all duration-300 hover:bg-orange-400"
on:click={debounce(() => dispatch('delete'), 150)}>{$LL.components.dashboard.dashboardUploadCard.delete()}</button on:click={debounce(() => dispatch('delete'), 150)}
>{$LL.components.dashboard.dashboardUploadCard.delete()}</button
> >
{/if} {/if}
<StatusNotificationDot {status} /> <StatusNotificationDot {status} />
@ -133,9 +134,16 @@
> >
<div class="hidden items-center xl:block"> <div class="hidden items-center xl:block">
{#if bytesTotal === 0 || Math.round(progress * 100) === 100} {#if bytesTotal === 0 || Math.round(progress * 100) === 100}
<h2 class="text-xl font-bold">{status === 'submitted' ? $LL.components.dashboard.dashboardUploadCard.sent() : $LL.components.dashboard.dashboardUploadCard.uploaded()}</h2> <h2 class="text-xl font-bold">
{status === 'submitted'
? $LL.components.dashboard.dashboardUploadCard.sent()
: $LL.components.dashboard.dashboardUploadCard.uploaded()}
</h2>
{:else} {:else}
<h2 class="text-xl">{$LL.components.dashboard.dashboardUploadCard.uploaded()} {((bytesTotal / 1_000_000) * progress).toFixed(1)} MB</h2> <h2 class="text-xl">
{$LL.components.dashboard.dashboardUploadCard.uploaded()}
{((bytesTotal / 1_000_000) * progress).toFixed(1)} MB
</h2>
<h2 class="self-center text-xl">z {(bytesTotal / 1_000_000).toFixed(1)} MB</h2> <h2 class="self-center text-xl">z {(bytesTotal / 1_000_000).toFixed(1)} MB</h2>
{/if} {/if}
</div> </div>

View file

@ -1,7 +1,6 @@
import type { GradeBackend } from '$lib/components/grades/GradesTable.svelte'; import type { GradeBackend } from '$lib/components/grades/GradesTable.svelte';
import { writable } from 'svelte/store'; import { writable } from 'svelte/store';
export interface School { export interface School {
name: string; name: string;
field: string; field: string;
@ -88,8 +87,8 @@ export const candidateData = writable<CandidateData>({
schoolName: '', schoolName: '',
healthInsurance: '', healthInsurance: '',
grades: [], grades: [],
firstSchool: {name: '', field: ''}, firstSchool: { name: '', field: '' },
secondSchool: {name: '', field: ''}, secondSchool: { name: '', field: '' },
testLanguage: '' testLanguage: ''
}, },
parents: [] parents: []

View file

@ -1,74 +1,75 @@
// TODO: nefunguje pro lidi nar. pred 1.1.1954 :D // TODO: nefunguje pro lidi nar. pred 1.1.1954 :D
export const isPersonalIdNumberValid = (personalIdNumber: string): boolean => { export const isPersonalIdNumberValid = (personalIdNumber: string): boolean => {
const idFmt = personalIdNumber.split('/').join(''); const idFmt = personalIdNumber.split('/').join('');
const lastDigitCheck = const lastDigitCheck =
Number(idFmt.slice(0, 9)) % 11 === Number(idFmt.at(-1)) || Number(idFmt.slice(0, 9)) % 11 === Number(idFmt.at(-1)) ||
Number(idFmt.slice(0, 9)) % 11 === 10; // an edge case that could occur Number(idFmt.slice(0, 9)) % 11 === 10; // an edge case that could occur
const divisibleBy11 = Number(idFmt) % 11 === 0; const divisibleBy11 = Number(idFmt) % 11 === 0;
if (lastDigitCheck && divisibleBy11) { if (lastDigitCheck && divisibleBy11) {
return true; return true;
} else { } else {
return false; return false;
} }
}; };
export const isPersonalIdNumberWithBirthdateValid = ( export const isPersonalIdNumberWithBirthdateValid = (
personalIdNumber: string, personalIdNumber: string,
birthdate: string birthdate: string
): boolean => { ): boolean => {
const dateFmt = birthdate const dateFmt = birthdate
.split('.') .split('.')
.map((x) => x.padStart(2, '0')) .map((x) => x.padStart(2, '0'))
.reverse() .reverse()
.join('') .join('')
.slice(2); .slice(2);
const idFmt = personalIdNumber.split('/').join(''); const idFmt = personalIdNumber.split('/').join('');
const divisionValid = isPersonalIdNumberValid(personalIdNumber); const divisionValid = isPersonalIdNumberValid(personalIdNumber);
const idMonth = Number(idFmt.slice(2, 4)); const idMonth = Number(idFmt.slice(2, 4));
const dateMonth = Number(dateFmt.slice(2, 4)); const dateMonth = Number(dateFmt.slice(2, 4));
const monthValid = const monthValid =
idMonth === dateMonth || idMonth === dateMonth ||
idMonth === dateMonth + 50 || idMonth === dateMonth + 50 ||
idMonth === dateMonth + 20 || idMonth === dateMonth + 20 ||
idMonth === dateMonth + 70; idMonth === dateMonth + 70;
if ( if (
idFmt.slice(0, 2) === dateFmt.slice(0, 2) && idFmt.slice(0, 2) === dateFmt.slice(0, 2) &&
monthValid && monthValid &&
idFmt.slice(4, 6) === dateFmt.slice(4, 6) && idFmt.slice(4, 6) === dateFmt.slice(4, 6) &&
divisionValid divisionValid
) { ) {
return true; return true;
} else { } else {
return false; return false;
} }
}; };
export const deriveBirthdateFromPersonalId = (personalIdNumber: string): export const deriveBirthdateFromPersonalId = (
[birthdate: string, sex: 'MUŽ' | 'ŽENA'] => { personalIdNumber: string
const year = Number(personalIdNumber.slice(0, 2)); ): [birthdate: string, sex: 'MUŽ' | 'ŽENA'] => {
const idMonth = Number(personalIdNumber.slice(2, 4)); const year = Number(personalIdNumber.slice(0, 2));
let month; const idMonth = Number(personalIdNumber.slice(2, 4));
let sex: 'MUŽ' | 'ŽENA'; let month;
if (idMonth > 12 && idMonth <= 32) { let sex: 'MUŽ' | 'ŽENA';
month = idMonth - 20; if (idMonth > 12 && idMonth <= 32) {
sex = 'MUŽ'; month = idMonth - 20;
} else if (idMonth > 50 && idMonth <= 52) { sex = 'MUŽ';
month = idMonth - 50; } else if (idMonth > 50 && idMonth <= 52) {
sex = 'ŽENA'; month = idMonth - 50;
} else if (idMonth > 70 && idMonth <= 82) { sex = 'ŽENA';
month = idMonth - 70; } else if (idMonth > 70 && idMonth <= 82) {
sex = 'ŽENA'; month = idMonth - 70;
} else { sex = 'ŽENA';
month = idMonth; } else {
sex = 'MUŽ'; month = idMonth;
}; sex = 'MUŽ';
const day = Number(personalIdNumber.slice(4, 6)); }
const day = Number(personalIdNumber.slice(4, 6));
const birthdate = `${day}.${month}.${year}`; const birthdate = `${day}.${month}.${year}`;
return [birthdate, sex]; return [birthdate, sex];
} };

View file

@ -23,8 +23,8 @@ export const load: PageServerLoad = async ({ fetch, params }) => {
schoolName: '', schoolName: '',
healthInsurance: '', healthInsurance: '',
grades: [], grades: [],
firstSchool: {name: '', field: ''}, firstSchool: { name: '', field: '' },
secondSchool: {name: '', field: ''}, secondSchool: { name: '', field: '' },
testLanguage: '' testLanguage: ''
}, },
parents: [] parents: []

View file

@ -25,7 +25,11 @@
{$LL.candidate.auth.login.description()} {$LL.candidate.auth.login.description()}
</p> </p>
<div class="w-4/5 lg:w-3/5"> <div class="w-4/5 lg:w-3/5">
<TextField bind:value={applicationValue} placeholder={$LL.input.evidenceNumber()} type="number" /> <TextField
bind:value={applicationValue}
placeholder={$LL.input.evidenceNumber()}
type="number"
/>
</div> </div>
<div class="mt-8 w-4/5 lg:w-3/5"> <div class="mt-8 w-4/5 lg:w-3/5">
<Submit on:click={redirectToCode} value={$LL.input.submit()} /> <Submit on:click={redirectToCode} value={$LL.input.submit()} />

View file

@ -1,11 +1,10 @@
import type { FormattersInitializer } from 'typesafe-i18n' import type { FormattersInitializer } from 'typesafe-i18n';
import type { Locales, Formatters } from './i18n-types.js' import type { Locales, Formatters } from './i18n-types.js';
export const initFormatters: FormattersInitializer<Locales, Formatters> = (locale: Locales) => { export const initFormatters: FormattersInitializer<Locales, Formatters> = (locale: Locales) => {
const formatters: Formatters = { const formatters: Formatters = {
// add your formatter functions here // add your formatter functions here
} };
return formatters return formatters;
} };

View file

@ -1,6 +1,6 @@
import adapter from '@sveltejs/adapter-node'; import adapter from '@sveltejs/adapter-node';
import preprocess from 'svelte-preprocess'; import preprocess from 'svelte-preprocess';
import path from "path"; import path from 'path';
import { windi } from 'svelte-windicss-preprocess'; import { windi } from 'svelte-windicss-preprocess';
/** @type {import('@sveltejs/kit').Config} */ /** @type {import('@sveltejs/kit').Config} */
@ -11,9 +11,8 @@ const config = {
kit: { kit: {
adapter: adapter({ out: 'build' }), adapter: adapter({ out: 'build' }),
alias: { alias: {
$i18n: path.resolve('./src/translations'), $i18n: path.resolve('./src/translations')
} }
} }
}; };

View file

@ -9,6 +9,6 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"skipLibCheck": true, "skipLibCheck": true,
"sourceMap": true, "sourceMap": true,
"strict": true, "strict": true
} }
} }