From d5dcc71e35aa5a796a3d5abfd9661493d809a34c Mon Sep 17 00:00:00 2001 From: Nuwan Date: Mon, 2 Dec 2024 09:46:01 +0530 Subject: [PATCH] fix error showing user affiliate agreement status and date --- .../src/components/affiliate/JKAffiliateAgreement.js | 12 +++++++----- web/app/controllers/api_users_controller.rb | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/jam-ui/src/components/affiliate/JKAffiliateAgreement.js b/jam-ui/src/components/affiliate/JKAffiliateAgreement.js index 25628b694..8d17add95 100644 --- a/jam-ui/src/components/affiliate/JKAffiliateAgreement.js +++ b/jam-ui/src/components/affiliate/JKAffiliateAgreement.js @@ -67,6 +67,7 @@ const JKAffiliateAgreement = () => { return; } fetchAffiliate(); + setHasExecuted(currentUser.is_affiliate_partner); }, [currentUser]); useEffect(() => { @@ -87,9 +88,7 @@ const JKAffiliateAgreement = () => { const affiliate = await response.json(); if (affiliate) { setAgreementData(affiliate.agreement); - if (affiliate.agreement && affiliate.agreement.signed_at) { - setHasExecuted(true); - } + } }catch(error){ console.log(error); @@ -149,8 +148,11 @@ const JKAffiliateAgreement = () => { {hasExecuted && ( -
- ({t('agreement.executed_on')} {formatDate(agreementData.signed_at)}) +
+ ({t('agreement.executed_on')}:  + { + agreementData && agreementData.signed_at ? formatDate(agreementData.signed_at) : 'N/A' + })
)} diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 51bec94a8..18fdd64cf 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -56,6 +56,7 @@ class ApiUsersController < ApiController email: current_user.email, photo_url: current_user.photo_url, show_free_jamtrack: current_user.show_free_jamtrack?, + is_affiliate_partner: current_user.affiliate_partner.present?, }, status: 200 end