Skip to content

Commit 9630a9c

Browse files
authored
add recovered/vaccinated option to checkin (#355)
* add new option for recovered * update locales
1 parent e013102 commit 9630a9c

11 files changed

+65
-22
lines changed

lib/api/companies.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ export const CompanyTypeOptions = {
2323
}
2424

2525
export const CoronaTestOptions = {
26-
0: 'kein Test notwendig',
27-
24: 'maximal 24 Stunden alter Test notwendig',
28-
48: 'maximal 48 Stunden alter Test notwendig',
29-
}
26+
0: 'NO_TEST',
27+
1: 'RECOVERED_OR_VACCINATED',
28+
24: '24_HOUR_TEST_NEEDED',
29+
48: '48_HOUR_TEST_NEEDED',
30+
} as const
31+
32+
export type CoronaTestOptionsValues =
33+
typeof CoronaTestOptions[keyof typeof CoronaTestOptions]
3034

3135
export interface CompanyRes {
3236
id: string

lib/models/area.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { AreaRes, CoronaTestOptions, CoronaTestOptionsValues } from '~lib/api'
2+
3+
export const getAreaCoronaTestOption = (
4+
area: Partial<AreaRes> = {}
5+
): CoronaTestOptionsValues | null => {
6+
const { companyNeedToShowCoronaTest: value } = area
7+
8+
switch (value) {
9+
case 0:
10+
case 1:
11+
case 24:
12+
case 48: {
13+
return CoronaTestOptions[value]
14+
}
15+
default: {
16+
return null
17+
}
18+
}
19+
}
20+
21+
export const getAreaShouldAskForTest = (area: Partial<AreaRes>): boolean => {
22+
const option = getAreaCoronaTestOption(area)
23+
24+
return option === '24_HOUR_TEST_NEEDED' || option === '48_HOUR_TEST_NEEDED'
25+
}

locales/useLocaleObject.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const useLocaleObject = <K extends string, V extends unknown>(
3333
const placeholder = `[${key}]` as Result[K]
3434

3535
const value = currentLocale[key]
36-
const valueEnv = currentLocale[`${key}_${BUILD_VARIANT}`]
36+
const valueEnv = currentLocale[`${key}_${BUILD_VARIANT}` as K]
3737
const localeResult = options.useEnv && valueEnv != null ? valueEnv : value
3838

3939
if (localeResult == null) {

pages/checkin.de.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isFormal, isRcvrEnv, isCareEnv, isHealthEnv } from '~lib/config'
1+
import { isFormal, isCareEnv, isHealthEnv } from '~lib/config'
22

33
const de = {
44
pageTitle: 'Checkin...',

pages/checkin.en.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isFormal, isRcvrEnv, isCareEnv, isHealthEnv } from '~lib/config'
1+
import { isFormal, isCareEnv, isHealthEnv } from '~lib/config'
22
import de from './checkin.de'
33

44
const en: typeof de = {

pages/checkin.pl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isFormal, isRcvrEnv, isCareEnv, isHealthEnv } from '~lib/config'
1+
import { isFormal, isCareEnv, isHealthEnv } from '~lib/config'
22
import de from './checkin.de'
33

44
const pl: typeof de = {

pages/checkin.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ export default function CheckinPage() {
217217
<p>{t('address')}</p>
218218
<p>
219219
{t('dataProtection1')}
220+
{isRcvrEnv ? ' ' : null}
220221
{isRcvrEnv ? <b>recover</b> : null}
221222
{isRcvrEnv ? ' ' : null}
222223
{isRcvrEnv ? t('dataProtection2_rcvr') : t('dataProtection2')}

ui/blocks/LanguageSwitcher.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const LanguageSwitcher: React.FC = () => {
3232

3333
setTimeout(() => router.reload(), 300)
3434
},
35-
[]
35+
[router, persistLocale]
3636
)
3737

3838
return (

ui/blocks/Onboarding/Onboarding.tsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Box, Button, Checkbox, Radio, Input, Text } from '~ui/core'
1010

1111
import useLocaleObject from '~locales/useLocaleObject'
1212
import OnboardingLocales from '~ui/blocks/Onboarding/Onboarding.locales'
13+
import { getAreaShouldAskForTest } from '~lib/models/area'
1314

1415
type OnboardingProps = {
1516
area: AreaRes
@@ -67,6 +68,8 @@ export const Onboarding: React.FC<OnboardingProps> = ({
6768
area.companyNeedToShowCoronaTest
6869
} ${t('provideTestLabel2')}.`
6970

71+
const shouldShowProvideTest = getAreaShouldAskForTest(area)
72+
7073
return (
7174
<div>
7275
<Formik
@@ -112,12 +115,14 @@ export const Onboarding: React.FC<OnboardingProps> = ({
112115
{area.companyNeedToShowCoronaTest > 0 && !area.testExemption && (
113116
<>
114117
<Box height={3} />
115-
<Radio
116-
name="providedHealthDocument"
117-
label={provide_test_label}
118-
value={GuestHealthDocumentEnum.tested}
119-
hideError={true}
120-
/>
118+
{shouldShowProvideTest && (
119+
<Radio
120+
name="providedHealthDocument"
121+
label={provide_test_label}
122+
value={GuestHealthDocumentEnum.tested}
123+
hideError={true}
124+
/>
125+
)}
121126
<Radio
122127
name="providedHealthDocument"
123128
label={t('hadCoronaLabel')}

ui/modals/BusinessDataModal.locales.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ export const de = {
77
...validatorsLocalesDE,
88
...CompanyTypeOptions,
99

10-
coronaTestSelectOptions0: 'kein Test notwendig',
11-
coronaTestSelectOptions24: 'maximal 24 Stunden alter Test notwendig',
12-
coronaTestSelectOptions48: 'maximal 48 Stunden alter Test notwendig',
10+
coronaTestSelectOptions0: 'Kein Nachweis notwendig',
11+
coronaTestSelectOptions24: 'Genesen, Geimpt oder Getested (24 Stunden)',
12+
coronaTestSelectOptions48: 'Genesen, Geimpt oder Getested (48 Stunden)',
13+
coronaTestSelectOptionsRecovered: 'Genesen oder Geimpt',
1314

1415
or: 'oder',
1516

@@ -95,9 +96,12 @@ export const en: typeof de = {
9596
public_building: 'public building',
9697
educational_institution: 'educational institution',
9798

98-
coronaTestSelectOptions0: 'no test necessary',
99-
coronaTestSelectOptions24: 'maximum 24 hours old test necessary',
100-
coronaTestSelectOptions48: 'maximum 48 hours old test necessary',
99+
coronaTestSelectOptions0: 'No proof required',
100+
coronaTestSelectOptions24:
101+
'Proof of recovery, Vaccination or test (24 hours)',
102+
coronaTestSelectOptions48:
103+
'Proof of recovery, Vaccination or test (48 hours)',
104+
coronaTestSelectOptionsRecovered: 'Proof of recovery or vaccination',
101105
}
102106

103107
export default { de, en }

ui/modals/BusinessDataModal.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ export const BusinessDataModal: React.FC<BusinessDataModalProps> = ({
5151
educational_institution: t('educational_institution'),
5252
}
5353

54-
const coronaTestSelectOptions: typeof CoronaTestOptions = {
54+
const coronaTestSelectOptions: Record<
55+
keyof typeof CoronaTestOptions,
56+
string
57+
> = {
5558
'0': t('coronaTestSelectOptions0'),
5659
'24': t('coronaTestSelectOptions24'),
5760
'48': t('coronaTestSelectOptions48'),
61+
'1': t('coronaTestSelectOptionsRecovered'),
5862
}
5963

6064
const BusinessSchema = Yup.object().shape({

0 commit comments

Comments
 (0)