Merge pull request #152 from EETagent/version_2_zeroday_fixes

(frontend) (backend) zero day fixes for v2, study & register ui
This commit is contained in:
Sebastian Pravda 2023-01-16 15:16:17 +01:00 committed by GitHub
commit c2f2710990
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 62 additions and 79 deletions

View file

@ -12,6 +12,7 @@ pub struct ApplicationCandidateJoin {
pub surname: Option<String>,
pub email: Option<String>,
pub telephone: Option<String>,
pub field_of_study: Option<String>,
}
use crate::{Query};

View file

@ -14,6 +14,7 @@ pub struct ApplicationResponse {
pub surname: String,
pub email: String,
pub telephone: String,
pub field_of_study: Option<String>,
}
impl ApplicationResponse {
@ -25,7 +26,6 @@ impl ApplicationResponse {
let surname = EncryptedString::decrypt_option(&EncryptedString::try_from(&c.surname).ok(), private_key).await?;
let email = EncryptedString::decrypt_option(&EncryptedString::try_from(&c.email).ok(), private_key).await?;
let telephone = EncryptedString::decrypt_option(&EncryptedString::try_from(&c.telephone).ok(), private_key).await?;
Ok(
Self {
application_id: c.application_id,
@ -34,6 +34,7 @@ impl ApplicationResponse {
email: email.unwrap_or_default(),
telephone: telephone.unwrap_or_default(),
candidate_id: c.candidate_id,
field_of_study: c.field_of_study,
}
)
}

View file

@ -1,5 +1,10 @@
import axios, { type AxiosProgressEvent } from 'axios';
import type { BaseCandidate, CandidateData, CandidateLogin, CreateCandidate } from '$lib/stores/candidate';
import type {
BaseCandidate,
CandidateData,
CandidateLogin,
CreateCandidate
} from '$lib/stores/candidate';
import type { SubmissionProgress } from '$lib/stores/portfolio';
import { API_URL, errorHandler, type Fetch } from '.';
import DOMPurify from 'isomorphic-dompurify';

View file

@ -62,10 +62,6 @@
<td class="px-2 py-2 font-semibold text-gray-500">E-mail</td>
<td class="px-2 py-2">{candidate.email}</td>
</tr>
<tr>
<td class="px-2 py-2 font-semibold text-gray-500">Obor</td>
<td class="px-2 py-2">{candidate.study}</td>
</tr>
<tr>
<td class="px-2 py-2 font-semibold text-gray-500">Rodné číslo</td>
<td class="px-2 py-2">{candidate.personalIdNumber}</td>

View file

@ -36,7 +36,7 @@
{candidate.surname}
</td>
<td class="text-gray-900">
{candidate.study}
{candidate.fieldOfStudy}
</td>
<td class="text-sm">
<Delete id={candidate.applicationId} on:delete value="Odstranit" />

View file

@ -1,9 +1,8 @@
<script lang="ts">
export let linkOk: boolean = false;
export let linkError: boolean = false;
export let applications: Array<number>;
let title1 = `Ano, podával/a jsem dvě přihlášky na dva obory SSPŠaG (${applications[0]} a ${applications[1]})`;
let title2 = `Ne, přihlášku na SSPŠaG jsem podával/a jen jednu (${applications[0]})`;
@ -12,19 +11,18 @@
title2 = `Ne, přihlášku na SSPŠaG jsem podával více přihlášek`;
}
$: console.log(linkOk, linkError);
export let error: string = '';
const switchSelection = (id: number) => {
if (id === 0) {
linkOk = true;
linkError = false;
} else {
linkOk = false;
linkError = true;
}
linkOk = true;
linkError = false;
} else {
linkOk = false;
linkError = true;
}
};
</script>
@ -41,9 +39,9 @@
<label for="linkOk" class="peer-checked:border-sspsBlue peer-checked:text-gray-600" class:error>
<div class="block">
<span class="text-2xl">📜</span>
<div class="w-full text-lg font-semibold">
{title1}
{title1}
</div>
<div class="w-full text-sm">Vše je v pořádku</div>
</div>
@ -58,10 +56,7 @@
checked={linkError}
class="peer hidden"
/>
<label
for="linkError"
class="peer-checked:border-sspsBlue peer-checked:text-gray-600"
>
<label for="linkError" class="peer-checked:border-sspsBlue peer-checked:text-gray-600">
<div class="block">
<span class="text-2xl">📜</span>

View file

@ -66,13 +66,13 @@
};
const getField = (id: number) => {
if (id.toString().startsWith("101")) {
if (id.toString().startsWith('101')) {
return 'G';
} else if (id.toString().startsWith("102")) {
} else if (id.toString().startsWith('102')) {
return 'IT';
} else {
} else {
return 'KB';
}
}
};
const editDetails = async () => {
@ -155,11 +155,10 @@
>
{#if $baseCandidateData.applications.length > 1}
<span
>Ev. č. přihlášky ({getField($baseCandidateData.applications[1])}):
>Ev. č. přihlášky ({getField($baseCandidateData.applications[1])}):
<span class="font-bold">{$baseCandidateData.applications[1]}</span></span
>
{/if}
<span>Obor: <span class="font-bold">{$candidateData.candidate.study}</span></span>
<span>Adresa: <span class="font-bold">{$candidateData.candidate.address}</span></span>
<span
>Datum narození: <span class="font-bold">{$candidateData.candidate.birthdate}</span
@ -174,9 +173,17 @@
>{$candidateData.candidate.personalIdNumber}</span
></span
>
<span>IČO/Název školy: <span class="font-bold">{$candidateData.candidate.schoolName}</span></span>
<span>Číslo zdravotní pojišťovny: <span class="font-bold">{$candidateData.candidate.healthInsurance}</span></span>
<span>Telefon: <span class="font-bold">{$candidateData.candidate.telephone}</span></span>
<span
>IČO/Název školy: <span class="font-bold">{$candidateData.candidate.schoolName}</span
></span
>
<span
>Číslo zdravotní pojišťovny: <span class="font-bold"
>{$candidateData.candidate.healthInsurance}</span
></span
>
<span>Telefon: <span class="font-bold">{$candidateData.candidate.telephone}</span></span
>
</div>
<div
use:tippy={{

View file

@ -29,12 +29,12 @@
}
.bgImage {
@apply -z-20;
@apply min-w-screen absolute min-h-screen min-w-full;
@apply min-w-screen fixed min-h-screen min-w-full;
@apply bg-cover bg-no-repeat;
background-position: 55%;
}
.bgOverlay {
@apply min-w-screen absolute -z-10 min-h-screen;
@apply min-w-screen fixed -z-10 min-h-screen;
background: linear-gradient(45deg, rgba(18, 48, 75, 1), rgba(119, 173, 224, 0.443));
@apply bg-cover;
}
@ -50,7 +50,7 @@
@apply p-7;
}
.view {
@apply z-10 overflow-scroll;
@apply z-10;
@apply top-0 right-0 bottom-0 left-0 m-auto h-screen w-screen;
}
.content {

View file

@ -28,11 +28,11 @@
<style lang="postcss">
.bgImage {
@apply -z-20;
@apply min-w-screen absolute min-h-full md:min-w-[50vw];
@apply min-w-screen fixed min-h-full md:min-w-[50vw];
@apply bg-cover bg-no-repeat;
}
.bgOverlay {
@apply min-w-screen absolute -z-10 min-h-full md:min-w-[50vw];
@apply min-w-screen fixed -z-10 min-h-full md:min-w-[50vw];
background: linear-gradient(45deg, rgba(18, 48, 75, 1), rgba(119, 173, 224, 0.443));
@apply bg-cover;
}
@ -48,7 +48,7 @@
@apply p-7;
}
.view {
@apply z-10 overflow-scroll;
@apply z-10;
@apply absolute top-0 right-0 bottom-0 left-0 m-auto md:top-auto md:bottom-auto md:left-auto md:m-0;
@apply md:h-screen md:w-[50vw];
@apply md:my-auto;

View file

@ -11,7 +11,6 @@ export interface CandidateData {
citizenship: string;
email: string;
sex: string;
study: string;
personalIdNumber: string;
schoolName: string;
healthInsurance: string;
@ -28,7 +27,7 @@ export interface CandidatePreview {
applicationId?: number;
name?: string;
surname?: string;
study?: string;
fieldOfStudy?: string;
}
export interface CandidateLogin {
@ -71,7 +70,6 @@ export const candidateData = writable<CandidateData>({
citizenship: '',
email: '',
sex: '',
study: '',
personalIdNumber: '',
schoolName: '',
healthInsurance: ''

View file

@ -17,7 +17,6 @@ export const load: PageServerLoad = async ({ fetch, params }) => {
citizenship: '',
email: '',
sex: '',
study: '',
personalIdNumber: '',
schoolName: '',
healthInsurance: ''

View file

@ -38,9 +38,6 @@
let details = data.candidate;
let baseCandidateDetails = data.whoami;
let detailsFilledByAnotherAccount = baseCandidateDetails.encryptedBy !== null &&
baseCandidateDetails.currentApplication !== baseCandidateDetails.encryptedBy;
const formInitialValues = {
gdpr: false,
linkOk: false,
@ -61,8 +58,7 @@
citizenship: '',
personalIdNumber: '',
schoolName: '',
healthInsurance: '',
study: ''
healthInsurance: ''
},
parents: [
{
@ -109,8 +105,7 @@
citizenship: yup.string().required(),
personalIdNumber: yup.string().required(),
schoolName: yup.string().required(),
healthInsurance: yup.number().required(),
study: yup.string().required()
healthInsurance: yup.number().required()
}),
parents: yup.array().of(
yup.object().shape({
@ -253,7 +248,7 @@
let addressArray: Array<string> = [values.candidate.street + ' ' + values.candidate.houseNumber, values.candidate.city, values.candidate.zip];
values.candidate.address = addressArray.map((x) => x.replaceAll(',', '').trim()).join(',');
// @ts-ignore
delete values.candidate.street;delete values.candidate.houseNumber;delete values.candidate.city;delete values.candidate.zip;
delete values.candidate.street; delete values.candidate.houseNumber; delete values.candidate.city; delete values.candidate.zip;
await apiFillDetails(values);
goto('/dashboard');
@ -332,8 +327,7 @@
$typedErrors['candidate']['citizenship'] ||
$typedErrors['candidate']['personalIdNumber'] ||
$typedErrors['candidate']['schoolName'] ||
$typedErrors['candidate']['healthInsurance'] ||
$typedErrors['candidate']['study']
$typedErrors['candidate']['healthInsurance']
) {
return true;
}
@ -389,16 +383,19 @@
<SvelteToast />
<div class="form relative">
<div class="bottom-3/12 absolute flex w-full flex-col md:h-auto">
<div class="<md:h-24 <md:w-24 mb-4 h-32 w-32 self-center">
<SchoolBadge />
</div>
<!-- TODO: Find different way how to display SchoolBadge -->
{#if pageIndex > 0}
<div class="<md:h-24 <md:w-24 mb-4 h-32 w-32 self-center">
<SchoolBadge />
</div>
{/if}
<form on:submit={handleSubmit} id="triggerForm" class="invisible hidden" />
{#if pageIndex === 0}
<form on:submit={handleSubmit}>
<h1 class="title mt-8">Propojení účtů</h1>
<p class="description mt-8 block text-center">
Elektronickou přihlášky stačí vyplnit jen jednou i v případě, že jste podali dvě přihlášky.
Potvrďte, že jste jste k nám skutečně podali dvě přihlášky.
Elektronickou přihlášky stačí vyplnit jen jednou i v případě, že jste podali dvě
přihlášky. Potvrďte, že jste jste k nám skutečně podali dvě přihlášky.
</p>
<div class="field">
<AccountLinkCheckBox
@ -468,16 +465,16 @@
Pro registraci je potřeba vyplnit několik údajů o Vás. Tyto údaje budou použity pro
přijímací řízení. Všechny údaje jsou důležité.
</p>
<div class="flex field">
<div class="field flex">
<span class="w-[66%]">
<NameField
error={$typedErrors['candidate']['street'] || $typedErrors['candidate']['houseNumber']}
error={$typedErrors['candidate']['street'] ||
$typedErrors['candidate']['houseNumber']}
on:change={handleChange}
bind:valueName={$form.candidate.street}
bind:valueSurname={$form.candidate.houseNumber}
placeholder="Ulice a č. p."
helperText="Uveďte ulici a číslo popisné (např. Preslova 72)."
/>
</span>
<span class="ml-2 w-[33%]">
@ -491,7 +488,7 @@
/>
</span>
</div>
<div class="flex field">
<div class="field flex">
<span>
<TextField
error={$typedErrors['candidate']['city']}
@ -619,7 +616,6 @@
/>
</span>
<div class="field flex flex-row">
<span>
{#if $form.candidate.citizenship === 'Česká republika' || !$form.candidate.citizenship}
<TextField
@ -639,8 +635,8 @@
/>
{/if}
</span>
<span>
<span class="ml-2">
<TextField
error={$typedErrors['candidate']['healthInsurance']}
on:change={handleChange}
@ -649,7 +645,6 @@
placeholder="Číslo zdravotní pojišťovny"
/>
</span>
</div>
</div>
<div class="field flex items-center justify-center">
@ -668,15 +663,6 @@
placeholder="Rodné číslo"
/>
{/if}
<span class="ml-2">
<SelectField
error={$typedErrors['candidate']['study']}
on:change={handleChange}
bind:value={$form.candidate.study}
placeholder="Obor"
options={['KB', 'IT', 'G']}
/>
</span>
</div>
{/if}
</div>
@ -729,11 +715,6 @@
@apply mx-auto h-full w-[90%];
@apply items-center justify-center;
}
.form > form {
@apply flex flex-col;
@apply w-full;
@apply items-center justify-center;
}
.dot {
@apply @apply hover:bg-sspsBlue @apply
bg-sspsGray ml-2 h-4

View file

@ -152,7 +152,7 @@
input {
@apply text-sspsBlue text-center font-semibold;
@apply transition-colors duration-300;
@apply focus:border-sspsBlue hover:border-sspsBlue rounded-xl border border-2 bg-[#f8fafb] p-3 shadow-lg outline-none caret-sspsBlueDark
@apply focus:border-sspsBlue hover:border-sspsBlue caret-sspsBlueDark rounded-xl border border-2 bg-[#f8fafb] p-3 shadow-lg outline-none;
}
.separater {
@apply bg-sspsBlue mr-2 hidden h-2 w-8 md:block;