Skip to content

Commit

Permalink
Fix/update localstorage (#84)
Browse files Browse the repository at this point in the history
* manually set value to undefined for not required fields/comboboxes

* handle optionals

Co-authored-by: fOppenheimer <[email protected]>
Co-authored-by: Gordon Grund <[email protected]>
  • Loading branch information
3 people authored May 31, 2021
1 parent 544f269 commit 648f870
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/components/modules/form-group.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const FormGroupValueSetSelect = (props: any) => {
placeholder={props.placeholder ? props.placeholder : props.title}
required={props.required}
>
<option disabled={props.required} key={0} value={props.required ? '' : undefined} >{props.placeholder ? props.placeholder : props.title}</option>
<option disabled={props.required} key={0} value=''>{props.placeholder ? props.placeholder : props.title}</option>
{options}
</Form.Control>
</Col>
Expand Down
20 changes: 12 additions & 8 deletions src/components/pdf-generater.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudgcProp: EUDGC | undefi
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [qrCodeCanvasElement, ci, isInit, eudgc]);

React.useEffect(() => {
if (co && isInit && eudgc) {
prepareFirstPage();
Expand Down Expand Up @@ -733,7 +733,7 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudgcProp: EUDGC | undefi
y = printVerticalBlock(x, y,
t('translation:pdfTestName'),
french.translation.pdfTestName,
testSet.nm ? testSet.nm : ' ',
testSet.nm,
lineHeight, true);

y = printVerticalBlock(x, y,
Expand All @@ -751,7 +751,7 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudgcProp: EUDGC | undefi
y = printVerticalBlock(x, y,
t('translation:pdfDateTestResult'),
french.translation.pdfDateTestResult,
convertDateToOutputFormat(testSet.dr ? testSet.dr : ' '),
testSet.dr ? convertDateToOutputFormat(testSet.dr) : '',
lineHeight, true);

y = printVerticalBlock(x, y,
Expand Down Expand Up @@ -997,7 +997,7 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudgcProp: EUDGC | undefi
let result = y;
lineHeight = lineHeight ? lineHeight : params.lineHeight;

if (value && pdf) {
if (pdf) {
pdf.setFont('arial', 'bold');
lbl = pdf.splitTextToSize(lbl, lblLength);
pdf.text(lbl, x, y);
Expand All @@ -1010,11 +1010,15 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudgcProp: EUDGC | undefi
pdf.text(frenchText, x, y);
y += lineHeight * frenchText.length;

pdf.setFont('arial', 'normal');
const valueText = pdf.splitTextToSize(value, lblLength);
pdf.text(valueText, x, y);
if (value) {
pdf.setFont('arial', 'normal');
const valueText = pdf.splitTextToSize(value, lblLength);
pdf.text(valueText, x, y);

y += lineHeight * valueText.length;
}

result = y + lineHeight * valueText.length + mm2point(2);
result = y + mm2point(2);
}

return result;
Expand Down
5 changes: 2 additions & 3 deletions src/components/record-test-cert-data.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ const RecordTestCertData = (props: any) => {
setTestDateTime(date);
}


const handleDateTimeChange = (evt: Date | [Date, Date] | null) => {
let date: Date;

Expand Down Expand Up @@ -147,8 +146,8 @@ const RecordTestCertData = (props: any) => {
const test: TestEntry = {
tg: disease,
tt: testType,
nm: testName,
ma: testManufacturers,
nm: testName ? testName : undefined,
ma: testManufacturers ? testManufacturers : undefined,
sc: sampleDateTime!.toISOString(),
dr: testDateTime ? testDateTime.toISOString() : undefined,
tr: testResult,
Expand Down

0 comments on commit 648f870

Please sign in to comment.