Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Implementation: reference ICAO conversion, with addition of cyrillic and arabic #290

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/components/modules/person-data-inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ const PersonInputs = (props: any) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [givenName, familyName, standardisedGivenName, standardisedFamilyName, dateOfBirth, sex, props.dccConsent])

const handleNameChanged = (changedValue: string, setName: (value: string) => void, setStandardisedName: (value: string) => void) => {
// forward the input to the normal setter
setName(changedValue);

// convert to ICAO and set the std field
setStandardisedName(utils.convertToICAO(changedValue));
}

const handleStandardisedNameChanged = (changedValue: string, setStandardisedName: (value: string) => void) => {
const upperCaseChangedValue = changedValue.toUpperCase();
Expand Down Expand Up @@ -104,15 +111,15 @@ const PersonInputs = (props: any) => {
{/* first name input */}
< FormGroupInput controlId='formGivenNameInput' title={t('translation:first-name')}
value={givenName}
onChange={(evt: any) => setGivenName(evt.target.value)}
onChange={(evt: any) => handleNameChanged(evt.target.value, setGivenName, setStandardisedGivenName)}
required
maxLength={50}
/>

{/* name input */}
< FormGroupInput controlId='formNameInput' title={t('translation:name')}
value={familyName}
onChange={(evt: any) => setFamilyName(evt.target.value)}
onChange={(evt: any) => handleNameChanged(evt.target.value, setFamilyName, setStandardisedFamilyName)}
required
maxLength={50}
/>
Expand Down
5 changes: 3 additions & 2 deletions src/misc/qr-code-value.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import IQuickTest from './quick-test';
import CryptoJS from 'crypto-js';
import vCardParser from './vCard-parser';
import utils from "./utils";
import { TestType } from './enum';

export interface IQRCodeValue {
Expand Down Expand Up @@ -143,8 +144,8 @@ export const getPersonDataFromScan = (data: string | null) => {
personData: {
familyName: s.name.surname.trim(),
givenName: s.name.name.trim(),
standardisedGivenName: '',
standardisedFamilyName: '',
standardisedGivenName: utils.convertToICAO(s.name.name.trim()),
standardisedFamilyName: utils.convertToICAO(s.name.surname.trim()),
dateOfBirth: s.birthday ? new Date(s.birthday) : undefined,
sex: undefined
},
Expand Down
Loading