From 90ff02e18c9625cfe46a873dc330de3a8bea0668 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Wed, 29 May 2024 17:40:28 -0400 Subject: [PATCH 1/5] check credit check verification response --- components/org/urbanscape/urbanscape-success.jsx | 15 +++++++++++++++ scripts/setup-certs.mjs | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/components/org/urbanscape/urbanscape-success.jsx b/components/org/urbanscape/urbanscape-success.jsx index 1502456..f0ad3e7 100644 --- a/components/org/urbanscape/urbanscape-success.jsx +++ b/components/org/urbanscape/urbanscape-success.jsx @@ -7,6 +7,7 @@ import { PROOFT_TEMPLATES_IDS } from 'utils/constants'; import QrCodeAuthentication from 'components/qrcode/qr-auth'; import qrCodeVerificationData from 'data/qrcode-text-data'; import useQrCode from 'hooks/useQrCode'; +import qrCodeStore from 'store/qrCodeStore'; import { Separator } from '../../ui/separator'; /** @@ -17,6 +18,8 @@ import { Separator } from '../../ui/separator'; const UrbanscapeSuccess = () => { const proofTemplateId = PROOFT_TEMPLATES_IDS.URBANSCAPE_CREDITSCORE; const { refetch } = useQrCode({ proofTemplateId }); + const retrievedData = qrCodeStore((state) => state.retrievedData); + const verified = qrCodeStore((state) => state.verified); useEffect(() => { setTimeout(() => { @@ -26,6 +29,18 @@ const UrbanscapeSuccess = () => { // eslint-disable-next-line }, []); + useEffect(() => { + if (verified === true && retrievedData !== null) { + setTimeout(() => { + const credential = retrievedData.credentials[0]; + if (credential) { + console.log('CREDIT SCORE CREDENTIAL: ', credential); + } + }, 1000); + } + // eslint-disable-next-line + }, [verified, retrievedData]); + return (
diff --git a/scripts/setup-certs.mjs b/scripts/setup-certs.mjs index b836c41..0abddfb 100644 --- a/scripts/setup-certs.mjs +++ b/scripts/setup-certs.mjs @@ -47,7 +47,7 @@ async function createProfiles() { let convenerDID; console.log('--- Creating profiles ---'); - const requests = await profiles.map(async (profile) => { + const requests = profiles.map(async (profile) => { console.log(`\t ${profile.name}`); try { From 5f0cb03582e4862797f331e55d7f18d5740d68a8 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Fri, 31 May 2024 16:18:12 -0400 Subject: [PATCH 2/5] Update deposit info if it's waived --- .../org/urbanscape/urbanscape-success.jsx | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/components/org/urbanscape/urbanscape-success.jsx b/components/org/urbanscape/urbanscape-success.jsx index f0ad3e7..9d0bac0 100644 --- a/components/org/urbanscape/urbanscape-success.jsx +++ b/components/org/urbanscape/urbanscape-success.jsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; import Image from 'next/image'; import Link from 'next/link'; import { CheckCircle2 } from 'lucide-react'; @@ -20,6 +20,7 @@ const UrbanscapeSuccess = () => { const { refetch } = useQrCode({ proofTemplateId }); const retrievedData = qrCodeStore((state) => state.retrievedData); const verified = qrCodeStore((state) => state.verified); + const [isWaived, setIsWaived] = useState(false); useEffect(() => { setTimeout(() => { @@ -33,8 +34,8 @@ const UrbanscapeSuccess = () => { if (verified === true && retrievedData !== null) { setTimeout(() => { const credential = retrievedData.credentials[0]; - if (credential) { - console.log('CREDIT SCORE CREDENTIAL: ', credential); + if (credential && credential.type.includes('EquiNetCreditScore')) { + setIsWaived(true); } }, 1000); } @@ -69,17 +70,26 @@ const UrbanscapeSuccess = () => {
-

$1,440

+

{isWaived ? '$0' : '$1,440' }

one time

-

We have a special offer for our applicants that have good credit. Provide to us a verified credential with a credit score over 700 and get your deposit waived!

-

This is a $1,440.00 value.

-

Scan the QR code on the right with your mobile app to see if you qualify.

+ { isWaived ? + ( +

Congratulations! You have qualified to have the deposit waived!

+ ) + : ( +
+

We have a special offer for our applicants that have good credit. Provide to us a verified credential with a credit score over 700 and get your deposit waived!

+

This is a $1,440.00 value.

+

Scan the QR code on the right with your mobile app to see if you qualify.

+
+ ) + }

TOTAL DUE NOW:

-

$3,990

+

{isWaived ? ('$2,550') : ('$3,990')}

@@ -94,16 +104,20 @@ const UrbanscapeSuccess = () => { -
- -
+ { !isWaived ? + ( +
+ +
+ ) : '' + } ); From 7ef1d72567bde83165ea07497a92b8a2ca50cae2 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Mon, 3 Jun 2024 15:14:00 -0400 Subject: [PATCH 3/5] remove timeout in credit check for urbanscape --- components/org/urbanscape/urbanscape-success.jsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/components/org/urbanscape/urbanscape-success.jsx b/components/org/urbanscape/urbanscape-success.jsx index 9d0bac0..b3ba3f1 100644 --- a/components/org/urbanscape/urbanscape-success.jsx +++ b/components/org/urbanscape/urbanscape-success.jsx @@ -32,12 +32,10 @@ const UrbanscapeSuccess = () => { useEffect(() => { if (verified === true && retrievedData !== null) { - setTimeout(() => { - const credential = retrievedData.credentials[0]; - if (credential && credential.type.includes('EquiNetCreditScore')) { - setIsWaived(true); - } - }, 1000); + const credential = retrievedData?.credentials[0]; + if (verified === true && credential?.type.includes('EquiNetCreditScore')) { + setIsWaived(true); + } } // eslint-disable-next-line }, [verified, retrievedData]); From 1d2314b68c6567766af1ded8c0ccebf6d54ea207 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Wed, 5 Jun 2024 14:53:00 -0400 Subject: [PATCH 4/5] clean up garbage properties in profile creation --- scripts/setup-certs.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/setup-certs.mjs b/scripts/setup-certs.mjs index 0abddfb..e708d16 100644 --- a/scripts/setup-certs.mjs +++ b/scripts/setup-certs.mjs @@ -55,7 +55,13 @@ async function createProfiles() { await waitForJob(didResponse.data.id, axiosHeaders); profile.did = didResponse.data.did; - const profileResponse = await axios.post(profilesUrl, profile, axiosHeaders); + const profileBody = { + name: profile.name, + did: didResponse.data.did, + logo: profile.logo, + description: profile.description + }; + const profileResponse = await axios.post(profilesUrl, profileBody, axiosHeaders); if (profile.isParticipant) { participantProfiles[scrubForFilename(profile.name)] = profileResponse.data; } From 81474ac2b1954c792440ee903242bc2ecedacdf0 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Wed, 5 Jun 2024 15:44:04 -0400 Subject: [PATCH 5/5] add credit score filter to Quotient loan template --- .../QUOTIENT_LOAN_PROOF_TEMPLATE_ID.json | 10 ++++++++++ scripts/download-ecosystem.mjs | 7 ++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/data/ecosystem-requests/clarity_partners/proof-requests/QUOTIENT_LOAN_PROOF_TEMPLATE_ID.json b/data/ecosystem-requests/clarity_partners/proof-requests/QUOTIENT_LOAN_PROOF_TEMPLATE_ID.json index 1bd2a9a..6206897 100644 --- a/data/ecosystem-requests/clarity_partners/proof-requests/QUOTIENT_LOAN_PROOF_TEMPLATE_ID.json +++ b/data/ecosystem-requests/clarity_partners/proof-requests/QUOTIENT_LOAN_PROOF_TEMPLATE_ID.json @@ -106,6 +106,16 @@ "const": "EquiNetCreditScore" }, "predicate": "required" + }, + { + "path": [ + "$.credentialSubject.credit_score" + ], + "filter": { + "type": "number", + "exclusiveMinimum": 700 + }, + "predicate": "required" } ] } diff --git a/scripts/download-ecosystem.mjs b/scripts/download-ecosystem.mjs index 67bd4e3..f98d26e 100644 --- a/scripts/download-ecosystem.mjs +++ b/scripts/download-ecosystem.mjs @@ -117,7 +117,8 @@ async function downloadProofRequestTemplates(ecosystemId, folder) { }); } -export function downloadProofRequests() { +export async function downloadProofRequests() { + await fs.mkdir('data/proof-requests'); console.log('--- Downloading proof request templates from Certs ---'); const proofTemplateUrl = `${process.env.DOCK_API_URL}/proof-templates/`; @@ -138,5 +139,5 @@ if (!process.env.DOCK_API_TOKEN) { throw new Error("Please configure the DOCK_API_TOKEN setting in the project's .env file."); } -downloadEcosystems(); -// downloadProofRequests(); +await downloadEcosystems(); +await downloadProofRequests();