fix error showing user affiliate agreement status and date

This commit is contained in:
Nuwan 2024-12-02 09:46:01 +05:30
parent 5ab863bc33
commit d5dcc71e35
2 changed files with 8 additions and 5 deletions

View File

@ -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 = () => {
<FalconCardHeader title={t('agreement.page_title')} titleClass="font-weight-semi-bold" />
<CardBody className="pt-3 pb-5">
{hasExecuted && (
<div className="alert alert-info execution-date">
({t('agreement.executed_on')} {formatDate(agreementData.signed_at)})
<div className="execution-date mb-1">
({t('agreement.executed_on')}:&nbsp;
{
agreementData && agreementData.signed_at ? formatDate(agreementData.signed_at) : 'N/A'
})
</div>
)}
<Scrollbar ref={scrollbar} style={{ width: '100%', height: 400 }} mobileNative={true}>

View File

@ -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