Skip to content

Commit

Permalink
Fix #12: Able to View all available DA's but there is mismatch in Opt…
Browse files Browse the repository at this point in the history
…-in and Opt-Out DA

Signed-off-by: George J Padayatti <[email protected]>
  • Loading branch information
georgepadayatti committed Nov 23, 2023
1 parent 8de8141 commit 1cc6752
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions src/Provider/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,18 +399,39 @@ class Store {

// If lawful basis is not consent or legitimate interest
// And if consent record is empty then, create a consent record
if (isNotConsentOrLegitimateInterest && associatedConsentRecords.length === 0) {
try {
const createConsentRecordRes = await services.createConsentRecord(dataAgreement.id);
if (createConsentRecordRes.status === 200) {
console.log("Consent record created for data agreement: ", dataAgreement.id);
associatedConsentRecords.push(createConsentRecordRes.data.consentRecord);
if (isNotConsentOrLegitimateInterest) {
if (associatedConsentRecords.length === 0) {
try {
const createConsentRecordRes = await services.createConsentRecord(dataAgreement.id);
if (createConsentRecordRes.status === 200) {
console.log("Consent record created for data agreement: ", dataAgreement.id);
associatedConsentRecords.push(createConsentRecordRes.data.consentRecord);
}
} catch (error) {
console.error(error);
}
} catch (error) {
console.error(error);
} else {
// And if consent record is not empty then, not already opted-in then update consent record
if (!associatedConsentRecords[0]["optIn"]) {
try {
const updateConsentRecordRes = await services.updateConsentRecord(
associatedConsentRecords[0]["id"],
associatedConsentRecords[0]["dataAgreementId"],
associatedConsentRecords[0]["individualId"],
true
);
if (updateConsentRecordRes.status === 200) {
console.log("Consent record updated for data agreement: ", dataAgreement.id);
}
} catch (error) {
console.error(error);
}
}

}
}


// Set ui loader state for each data agreement
loadingUiStore[dataAgreement.id] = false;

Expand Down

0 comments on commit 1cc6752

Please sign in to comment.