Skip to content

Commit

Permalink
VKT(Frontend): Examiner details create and update view
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoivisto committed Oct 28, 2024
1 parent 7049a1d commit 107e721
Show file tree
Hide file tree
Showing 19 changed files with 730 additions and 162 deletions.
33 changes: 33 additions & 0 deletions frontend/packages/vkt/public/i18n/fi-FI/examiner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"vkt": {
"component": {
"examinerDetails": {
"buttons": {
"saveAndClose": "Tallenna ja sulje"
},
"examinationDetails": {
"heading": "Tutkinnon perustiedot",
"information": "Nämä tiedot näkyvät julkisessa listauksessa."
},
"incorrectDetailsDialog": {
"description": "Korjaa puuttuvat tai virheelliset tiedot:",
"title": "Tiedoissa on korjattavaa!"
},
"heading": "Omat tiedot",
"labels": {
"email": "Sähköpostiosoite",
"examLanguages": "Tutkinnon kieli",
"firstName": "Etunimi:",
"lastName": "Sukunimi:",
"isPublic": "Julkaise",
"municipalities": "Tutkintopaikka/Tutkintopaikat",
"phoneNumber": "Puhelinnumero"
},
"personalDetails": {
"heading": "Henkilötiedot",
"information": "Tiedoista vain nimet näkyvät julkisessa listauksessa."
}
}
}
}
}
1 change: 1 addition & 0 deletions frontend/packages/vkt/public/i18n/sv-SE/examiner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
16 changes: 15 additions & 1 deletion frontend/packages/vkt/src/configs/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import { DateUtils } from 'shared/utils';
import accessibilityFI from 'public/i18n/fi-FI/accessibility.json';
import clerkFI from 'public/i18n/fi-FI/clerk.json';
import commonFI from 'public/i18n/fi-FI/common.json';
import examinerFI from 'public/i18n/fi-FI/examiner.json';
import koodistoMunicipalitiesFI from 'public/i18n/fi-FI/koodisto_municipalities.json';
import publicFI from 'public/i18n/fi-FI/public.json';
import accessibilitySV from 'public/i18n/sv-SE/accessibility.json';
import clerkSV from 'public/i18n/sv-SE/clerk.json';
import commonSV from 'public/i18n/sv-SE/common.json';
import examinerSV from 'public/i18n/sv-SE/examiner.json';
import koodistoMunicipalitiesSV from 'public/i18n/sv-SE/koodisto_municipalities.json';
import publicSV from 'public/i18n/sv-SE/public.json';

Expand All @@ -25,20 +27,26 @@ const langSV = AppLanguage.Swedish;

const supportedLangs = [langFI, langSV];

enum VktI18nNamespace {
Examiner = 'examiner',
}

const resources = {
[langFI]: {
[I18nNamespace.Accessibility]: accessibilityFI,
[I18nNamespace.Clerk]: clerkFI,
[I18nNamespace.Common]: commonFI,
[I18nNamespace.Public]: publicFI,
[I18nNamespace.KoodistoMunicipalities]: koodistoMunicipalitiesFI,
[VktI18nNamespace.Examiner]: examinerFI,
},
[langSV]: {
[I18nNamespace.Accessibility]: accessibilitySV,
[I18nNamespace.Clerk]: clerkSV,
[I18nNamespace.Common]: commonSV,
[I18nNamespace.Public]: publicSV,
[I18nNamespace.KoodistoMunicipalities]: koodistoMunicipalitiesSV,
[VktI18nNamespace.Examiner]: examinerSV,
},
};

Expand Down Expand Up @@ -76,7 +84,7 @@ export const initI18n = () => {

const useAppTranslation = (
options: UseTranslationOptions<string>,
ns: I18nNamespace,
ns: I18nNamespace | VktI18nNamespace,
) => {
return useTranslation(ns, options);
};
Expand Down Expand Up @@ -122,6 +130,12 @@ export const useKoodistoMunicipalitiesTranslation = () => {
return t;
};

export const useExaminerTranslation = (
options: UseTranslationOptions<string>,
) => {
return useAppTranslation(options, VktI18nNamespace.Examiner);
};

export const translateOutsideComponent = () => {
return t;
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/vkt/src/interfaces/clerkUser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIResponseStatus } from "shared/enums";
import { APIResponseStatus } from 'shared/enums';

export interface ClerkUser {
oid: string;
Expand Down
11 changes: 9 additions & 2 deletions frontend/packages/vkt/src/interfaces/examinerDetails.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { APIResponseStatus } from 'shared/enums';
import { WithId } from 'shared/interfaces';
import { Municipality } from 'interfaces/municipality';

import { MunicipalityCode } from 'interfaces/municipality';

export interface ExaminerDetailsState {
status: APIResponseStatus;
Expand All @@ -17,7 +18,7 @@ export interface ExaminerDetails extends WithId {
phoneNumber: string;
examLanguageFinnish: boolean;
examLanguageSwedish: boolean;
municipalities: Array<Municipality>;
municipalities: Array<MunicipalityCode>;
isPublic: boolean;
}

Expand All @@ -30,3 +31,9 @@ export interface ExaminerDetailsInitState {
status: APIResponseStatus;
initData?: ExaminerDetailsInit;
}

export function isExaminerDetails(
details: ExaminerDetailsInit,
): details is ExaminerDetails {
return details.hasOwnProperty('id');
}
19 changes: 19 additions & 0 deletions frontend/packages/vkt/src/interfaces/examinerDetailsUpsert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { APIResponseStatus } from 'shared/enums';

import { MunicipalityCode } from 'interfaces/municipality';

export interface ExaminerDetailsUpsert {
id?: number;
oid: string;
email: string;
phoneNumber: string;
examLanguageFinnish: boolean;
examLanguageSwedish: boolean;
isPublic: boolean;
municipalities: Array<MunicipalityCode>;
}

export interface ExaminerDetailsUpsertState {
status: APIResponseStatus;
examinerDetails: Partial<ExaminerDetailsUpsert>;
}
10 changes: 8 additions & 2 deletions frontend/packages/vkt/src/interfaces/municipality.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// TODO Consider removing Municipality interface
// At the moment, the localised name information per code is found in localisation files.
export interface Municipality {
fi: string;
sv: string;
fi: string;
sv: string;
}

export interface MunicipalityCode {
code: string;
}
4 changes: 2 additions & 2 deletions frontend/packages/vkt/src/interfaces/publicExaminer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { WithId } from 'shared/interfaces';
import { ExamLanguage } from 'enums/app';
import { Municipality } from 'interfaces/municipality';


interface PublicExaminerExamDate {
examDate: Dayjs;
isFull: boolean;
}

interface PublicExaminerExamDateResponse extends Omit<PublicExaminerExamDate, 'examDate'> {
interface PublicExaminerExamDateResponse
extends Omit<PublicExaminerExamDate, 'examDate'> {
examDate: string;
}

Expand Down
Loading

0 comments on commit 107e721

Please sign in to comment.