Skip to content

Commit

Permalink
Fix #229: Consent status is shown as disabled in some scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
mumthasir-muhammed authored and georgepadayatti committed Apr 22, 2024
1 parent 2997f4b commit 835de3f
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class BBConsentOrganisationViewController: BBConsentBaseViewController {
func CheckAndCreateRecordForContractType() {
let dataAgreementIDs = dataAgreementsObj?.dataAgreements.filter({ $0.lawfulBasis != "consent" && $0.lawfulBasis != "legitimate_interest" }).map({ $0.id }) ?? []
let idsWithAttributeRecords = consentRecordsObj?.consentRecords.map({ $0.dataAgreementID }) ?? []
let recordIds = consentRecordsObj?.consentRecords.map({ $0.id }) ?? []

for item in dataAgreementIDs {
// If item doesnt have record already
if !idsWithAttributeRecords.contains(item) {
Expand All @@ -151,6 +153,15 @@ class BBConsentOrganisationViewController: BBConsentBaseViewController {
self.orgTableView.reloadData()
}
}
} else {
// Update record api call
let indexOfItem = idsWithAttributeRecords.firstIndex(of: item) ?? 0
callUpdatePurposeApi(dataAgreementRecordId: recordIds[indexOfItem], dataAgreementId: item, status: true) { success in
if success {
self.consentRecordsObj?.consentRecords[indexOfItem].optIn = true
self.orgTableView.reloadData()
}
}
}
}
}
Expand Down

0 comments on commit 835de3f

Please sign in to comment.