Unverified Commit 30b9d92d authored by Gordon Grund's avatar Gordon Grund Committed by GitHub
Browse files

adjust country-code in pdf to issuer country code (#111)

parent 45daa280
...@@ -54,8 +54,9 @@ const ShowCertificate = (props: any) => { ...@@ -54,8 +54,9 @@ const ShowCertificate = (props: any) => {
const [qrCodeForPDF, setQrCodeForPDF] = React.useState<any>(); const [qrCodeForPDF, setQrCodeForPDF] = React.useState<any>();
const [eudgcForPDF, setEudgcForPDF] = React.useState<EUDCC1>(); const [eudgcForPDF, setEudgcForPDF] = React.useState<EUDCC1>();
const [valueSetsForPDF, setValueSetsForPDF] = React.useState<IValueSetList>(); const [valueSetsForPDF, setValueSetsForPDF] = React.useState<IValueSetList>();
const [issuerCountryCodeForPDF, setIssuerCountryCodeForPDF] = React.useState('');
const pdf = usePdfGenerator(qrCodeForPDF, eudgcForPDF, valueSetsForPDF, (isInit) => setPdfIsInit(isInit), (isReady) => setPdfIsReady(isReady)); const pdf = usePdfGenerator(qrCodeForPDF, eudgcForPDF, valueSetsForPDF, issuerCountryCodeForPDF, (isInit) => setPdfIsInit(isInit), (isReady) => setPdfIsReady(isReady));
// set patient data on mount and set hash from uuid // set patient data on mount and set hash from uuid
React.useEffect(() => { React.useEffect(() => {
...@@ -78,6 +79,7 @@ const ShowCertificate = (props: any) => { ...@@ -78,6 +79,7 @@ const ShowCertificate = (props: any) => {
//console.log("qrcode: " + certResult.qrCode); //console.log("qrcode: " + certResult.qrCode);
setQrCodeValue(certResult.qrCode); setQrCodeValue(certResult.qrCode);
setTAN(certResult.tan); setTAN(certResult.tan);
setIssuerCountryCodeForPDF(certResult.issuerCountryCode);
}) })
.catch(error => { .catch(error => {
handleError(error); handleError(error);
......
...@@ -34,7 +34,8 @@ const api = axios.create({ ...@@ -34,7 +34,8 @@ const api = axios.create({
export interface CertResult { export interface CertResult {
qrCode: string, qrCode: string,
dgci: string, dgci: string,
tan: string tan: string,
issuerCountryCode: string
} }
enum CertType { enum CertType {
...@@ -114,7 +115,8 @@ const generateQRCode = (edgcPayload: EUDCC1): Promise<CertResult> => { ...@@ -114,7 +115,8 @@ const generateQRCode = (edgcPayload: EUDCC1): Promise<CertResult> => {
return { return {
qrCode: qrCode, qrCode: qrCode,
dgci: certMetaData.dgci, dgci: certMetaData.dgci,
tan: tan tan: tan,
issuerCountryCode: certMetaData.countryCode
} }
}); });
}); });
......
...@@ -93,6 +93,7 @@ const usePdfGenerator = ( ...@@ -93,6 +93,7 @@ const usePdfGenerator = (
qrCodeCanvasElementProp: any, qrCodeCanvasElementProp: any,
eudccProp: EUDCC1 | undefined, eudccProp: EUDCC1 | undefined,
valueSetListProp: IValueSetList | undefined, valueSetListProp: IValueSetList | undefined,
issuerCountryCodeProp: string,
onIsInit: (isInit: boolean) => void, onIsInit: (isInit: boolean) => void,
onIsReady: (isReady: boolean) => void) => { onIsReady: (isReady: boolean) => void) => {
...@@ -154,6 +155,7 @@ const usePdfGenerator = ( ...@@ -154,6 +155,7 @@ const usePdfGenerator = (
const [pdf, setPdf] = React.useState<jsPDF>(); const [pdf, setPdf] = React.useState<jsPDF>();
const [eudcc, setEudcc] = React.useState<EUDCC1>(); const [eudcc, setEudcc] = React.useState<EUDCC1>();
const [issuerCountryCode, setIssuerCountryCode] = React.useState('');
const [vaccinationSet, setVaccinationSet] = React.useState<VaccinationEntry>(); const [vaccinationSet, setVaccinationSet] = React.useState<VaccinationEntry>();
const [testSet, setTestSet] = React.useState<TestEntry>(); const [testSet, setTestSet] = React.useState<TestEntry>();
const [recoverySet, setRecoverySet] = React.useState<RecoveryEntry>(); const [recoverySet, setRecoverySet] = React.useState<RecoveryEntry>();
...@@ -251,6 +253,12 @@ const usePdfGenerator = ( ...@@ -251,6 +253,12 @@ const usePdfGenerator = (
} }
}, [qrCodeCanvasElementProp]) }, [qrCodeCanvasElementProp])
React.useEffect(() => {
if (issuerCountryCodeProp) {
setIssuerCountryCode(issuerCountryCodeProp);
}
}, [issuerCountryCodeProp])
// set fourth page for vaccination // set fourth page for vaccination
React.useEffect(() => { React.useEffect(() => {
if (vaccinationSet && isInit) { if (vaccinationSet && isInit) {
...@@ -336,7 +344,7 @@ const usePdfGenerator = ( ...@@ -336,7 +344,7 @@ const usePdfGenerator = (
} }
const prepareFirstPage = () => { const prepareFirstPage = () => {
if (pdf && french && eudcc && co) { if (pdf && french && eudcc && issuerCountryCode) {
for (let page = 1; page < 3; page++) { for (let page = 1; page < 3; page++) {
let x = 0; let x = 0;
let y = 0; let y = 0;
...@@ -398,7 +406,7 @@ const usePdfGenerator = ( ...@@ -398,7 +406,7 @@ const usePdfGenerator = (
// pdf.text(pdfParams.issuer_country_code, x, y, { align: 'center' }); // pdf.text(pdfParams.issuer_country_code, x, y, { align: 'center' });
// } // }
pdf.text(co, x, y, { align: 'center' }); pdf.text(issuerCountryCode, x, y, { align: 'center' });
setTextColorBlack(); setTextColorBlack();
pdf.setFont('arial', 'normal'); pdf.setFont('arial', 'normal');
} }
......
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