Skip to content

Commit

Permalink
Feat/jsonschema1.3 (#95)
Browse files Browse the repository at this point in the history
* change recovery expiration behaviour

* change test name behaviour

Co-authored-by: Gordon Grund <[email protected]>
  • Loading branch information
ggrund-tsi and ggrund-tsi authored Jun 14, 2021
1 parent fe8bffa commit 93f07e3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/components/modules/form-group.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'>
Expand Down Expand Up @@ -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'>
Expand Down
28 changes: 23 additions & 5 deletions src/components/record-recovery-cert-data.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {

Expand All @@ -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]) {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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
/>
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/components/record-test-cert-data.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -215,13 +215,15 @@ 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}
/>

{/* combobox testManufacturers */}
<FormGroupValueSetSelect controlId='formTestManufactorersInput' title={t('translation:testManufacturers')}
value={testManufacturers}
onChange={(evt: any) => setTestManufacturers(evt.target.value)}
hidden={testType !== 'LP217198-3'}
valueSet={useGetTestManufacturers}
/>

Expand Down

0 comments on commit 93f07e3

Please sign in to comment.