diff --git a/.env.local b/.env.local index dcbc7cd..fe88f28 100644 --- a/.env.local +++ b/.env.local @@ -1,6 +1,6 @@ -API_BASE_URL=http://192.168.2.200 -VERIFIER_HOST=http://192.168.2.200:5001/grassroot-verifier/us-central1 +API_BASE_URL=http://evergreen +VERIFIER_HOST=http://evergreen:5001/grassroot-verifier/us-central1 HITCOUNT_HOST=http://localhost:8080 -REGISTRATION_HOST=http://192.168.2.200:5001/grassroot-verifier/us-central1 +REGISTRATION_HOST=http://evergreen:5001/grassroot-verifier/us-central1 FUNCTION_SUFFIX=v2 GPAY_BASE_URL=http://localhost:5002/grassroots-gpay/us-central1/googlesign diff --git a/.gitignore b/.gitignore index 4dffb78..bfc46a4 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ yarn-error.log* # Idea files .idea *.local +*.local diff --git a/public/displayLocallyStoredPDF.html b/public/displayLocallyStoredPDF.html index 76d4f8d..dcaea52 100644 --- a/public/displayLocallyStoredPDF.html +++ b/public/displayLocallyStoredPDF.html @@ -12,38 +12,15 @@ } .big-text { - font-size: 40; + font-size: 64; } + - Open locally stored PDF - - - + View Receipt + \ No newline at end of file diff --git a/public/displayLocallyStoredPDF.js b/public/displayLocallyStoredPDF.js new file mode 100644 index 0000000..7a28c76 --- /dev/null +++ b/public/displayLocallyStoredPDF.js @@ -0,0 +1,23 @@ +function updatePage() { + + let dataUrl = localStorage.getItem('pdfDataUrl'); + const myLinkElement = document.getElementById('mylink'); + + if (dataUrl != undefined) { + + let script = `function showData(base64URL){ + var win = window.open(); + win.document.write(''); + } showData('${dataUrl}');`; + + let hrefValue = `javascript:${script};`; + myLinkElement.setAttribute('href', hrefValue); + + } else { + if (navigator.userAgent.indexOf('Safari') != -1) { + myLinkElement.textContent = 'Sorry. This feature requires the use of Safari as default browser. You can change it in Settings - Chrome/Firefox'; + } else { + myLinkElement.textContent = 'Original receipt not available locally. Please re-create your wallet pass. Thanks.'; + } + } +} \ No newline at end of file diff --git a/src/payload.ts b/src/payload.ts index d2aa2f8..cc97f25 100644 --- a/src/payload.ts +++ b/src/payload.ts @@ -83,61 +83,54 @@ export class Payload { this.img1x = Constants.img1xBlack; this.img2x = Constants.img2xBlack; - const displayLocallyStoredPDFUrl = window.location.href + "/displayLocallyStoredPDF.html"; - const attributedValue = `Display locally stored PDF`; + let displayLocallyStoredPDFUrl = window.location.href + "displayLocallyStoredPDF.html"; + console.log(displayLocallyStoredPDFUrl) + const attributedValue = `View`; console.log('*** attributedValue ***'); console.log(attributedValue); this.generic.backFields.push({ key: "original", - label: "Label", + label: "Original receipt (saved locally in Safari)", attributedValue: attributedValue - }); } } } -function createHref(dataUrl) { - // https://stackoverflow.com/a/56738510/2789065 - - let script = `function debugBase64(base64URL){ - var win = window.open(); - win.document.write(''); - } - debugBase64('${dataUrl}'); - `; - - let hrefValue = `javascript:${script};` - return hrefValue; -} - function processSHCReceipt(receipt: SHCReceipt, generic: PassDictionary) { console.log(`processing receipt for origin ${receipt.cardOrigin}`); if (generic.primaryFields.length == 0) { + const lastReceiptIndex = receipt.vaccinations.length - 1 + const mostRecentReceipt = receipt.vaccinations[lastReceiptIndex]; + const vaccineName = mostRecentReceipt.vaccineName.substring(0,1).toUpperCase() + mostRecentReceipt.vaccineName.substring(1).toLowerCase(); + const value = `#${lastReceiptIndex + 1} - ${vaccineName}`; generic.primaryFields.push( { key: "name", - label: "", - value: `${receipt.name}` + label: `${receipt.name} (Last vaccinated: ${mostRecentReceipt.vaccinationDate})`, + value: value } ); } - let fieldToPush; + generic.secondaryFields.push({ + key: "details", + label: "For details", + value: "Touch the circle with ... on the top right" + }); + + generic.backFields.push({ + key: "date-of-birth", + label: "Date of Birth", + value: receipt.dateOfBirth + }); for (let i = 0; i < receipt.vaccinations.length; i++) { - if (i <= 1) - fieldToPush = generic.secondaryFields; - else if (i <= 3) - fieldToPush = generic.auxiliaryFields; - else if (i <= 5) - fieldToPush = generic.backFields; - - fieldToPush.push( + generic.backFields.push( { key: 'vaccine' + i, label: receipt.vaccinations[i].vaccineName,