Unverified Commit 93f07e3c authored by ggrund-tsi's avatar ggrund-tsi Committed by GitHub
Browse files

Feat/jsonschema1.3 (#95)



* change recovery expiration behaviour

* change test name behaviour
Co-authored-by: default avatarGordon Grund <gordon.grund@outlook.de>
parent fe8bffa4
......@@ -25,7 +25,7 @@ export interface IPersonData {
export const FormGroupInput = (props: any) => {
return (!props ? <></> :
<Form.Group as={Row} controlId={props.controlId} className='pb-3 mb-0'>
<Form.Group as={Row} hidden={props.hidden} controlId={props.controlId} className='pb-3 mb-0'>
<Form.Label className='input-label' column xs='5' sm='3'>{props.title + (props.required ? '*' : '')}</Form.Label>
<Col xs='7' sm='9' className='d-flex'>
......@@ -70,7 +70,7 @@ export const FormGroupValueSetSelect = (props: any) => {
}
return (!(props && options) ? <></> :
<Form.Group as={Row} controlId={props.controlId} className='pb-3 mb-0'>
<Form.Group as={Row} hidden={props.hidden} controlId={props.controlId} className='pb-3 mb-0'>
<Form.Label className='input-label' column xs='5' sm='3'>{props.title + (props.required ? '*' : '')}</Form.Label>
<Col xs='7' sm='9' className='d-flex'>
......
......@@ -43,7 +43,10 @@ import CardFooter from './modules/card-footer.component';
import moment from 'moment';
const validator = new Validator();
// 180 days
const expirationMilSeconds = 60 * 60 * 24 * 180 * 1000;
// 11 days
const timeAfter = 60 * 60 * 24 * 11 * 1000;
const RecordRecoveryCertData = (props: any) => {
......@@ -61,6 +64,8 @@ const RecordRecoveryCertData = (props: any) => {
const [testCountryCode, setTestCountryCode] = useLocalStorage('testCountryCode', '');
const [dateValidFrom, setDateValidFrom] = React.useState<Date>();
const [dateValidTo, setDateValidTo] = React.useState<Date>();
const [firstPosMinDate] = React.useState<Date>(new Date(Date.now() - expirationMilSeconds));
const [firstPosMaxDate] = React.useState<Date>(new Date(Date.now() - timeAfter));
React.useEffect(() => {
if (!props.eudgc || !props.eudgc.r || !props.eudgc.r[0]) {
......@@ -97,6 +102,7 @@ const RecordRecoveryCertData = (props: any) => {
const handleFirstPositiveResultDate = (evt: Date | [Date, Date] | null) => {
const date = handleDateChange(evt);
setFirstPositiveResultDate(date);
}
const handleDateValidFrom = (evt: Date | [Date, Date] | null) => {
......@@ -225,9 +231,13 @@ const RecordRecoveryCertData = (props: any) => {
showMonthDropdown
showYearDropdown
dropdownMode="select"
maxDate={new Date()}
minDate={new Date(Date.now() - expirationMilSeconds)}
openToDate={dateValidFrom ? dateValidFrom : new Date()}
maxDate={dateValidFrom ? new Date(dateValidFrom.getTime() - timeAfter) : firstPosMaxDate}
minDate={dateValidTo ? new Date(dateValidTo.getTime() - expirationMilSeconds) : firstPosMinDate}
openToDate={firstPositiveResultDate
? firstPositiveResultDate
: dateValidFrom
? new Date(dateValidFrom.getTime() - timeAfter)
: new Date()}
required
/>
</Col>
......@@ -267,7 +277,11 @@ const RecordRecoveryCertData = (props: any) => {
showYearDropdown
dropdownMode="select"
maxDate={new Date()}
minDate={dateValidTo ? new Date(dateValidTo.getTime() - expirationMilSeconds) : new Date(Date.now() - expirationMilSeconds)}
minDate={firstPositiveResultDate
? new Date(firstPositiveResultDate.getTime() + timeAfter)
: dateValidTo
? new Date(dateValidTo.getTime() + timeAfter - expirationMilSeconds)
: new Date(Date.now() + timeAfter - expirationMilSeconds)}
openToDate={dateValidFrom ? dateValidFrom : new Date()}
required
/>
......@@ -283,7 +297,11 @@ const RecordRecoveryCertData = (props: any) => {
showMonthDropdown
showYearDropdown
dropdownMode="select"
maxDate={dateValidFrom ? new Date(dateValidFrom.getTime() + expirationMilSeconds) : new Date(Date.now() + expirationMilSeconds)}
maxDate={firstPositiveResultDate
? new Date(firstPositiveResultDate.getTime() + expirationMilSeconds)
: dateValidFrom
? new Date(dateValidFrom.getTime() - timeAfter + expirationMilSeconds)
: new Date(Date.now() - timeAfter + expirationMilSeconds)}
minDate={new Date()}
openToDate={dateValidTo ? dateValidTo : new Date()}
required
......
......@@ -137,8 +137,8 @@ const RecordTestCertData = (props: any) => {
const test: TestEntry = {
tg: disease,
tt: testType,
nm: testName ? testName : undefined,
ma: testManufacturers ? testManufacturers : undefined,
nm: testName && testType === 'LP6464-4' ? testName : undefined,
ma: testManufacturers && testType === 'LP217198-3' ? testManufacturers : undefined,
sc: sampleDateTime!.toISOString(),
tr: testResult,
tc: testCenter,
......@@ -215,6 +215,7 @@ const RecordTestCertData = (props: any) => {
<FormGroupInput controlId='formTestNameInput' title={t('translation:testName')}
value={testName}
onChange={(evt: any) => setTestName(evt.target.value)}
hidden={testType !== 'LP6464-4'}
maxLength={80}
/>
......@@ -222,6 +223,7 @@ const RecordTestCertData = (props: any) => {
<FormGroupValueSetSelect controlId='formTestManufactorersInput' title={t('translation:testManufacturers')}
value={testManufacturers}
onChange={(evt: any) => setTestManufacturers(evt.target.value)}
hidden={testType !== 'LP217198-3'}
valueSet={useGetTestManufacturers}
/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment