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; return;
} }
fetchAffiliate(); fetchAffiliate();
setHasExecuted(currentUser.is_affiliate_partner);
}, [currentUser]); }, [currentUser]);
useEffect(() => { useEffect(() => {
@ -87,9 +88,7 @@ const JKAffiliateAgreement = () => {
const affiliate = await response.json(); const affiliate = await response.json();
if (affiliate) { if (affiliate) {
setAgreementData(affiliate.agreement); setAgreementData(affiliate.agreement);
if (affiliate.agreement && affiliate.agreement.signed_at) {
setHasExecuted(true);
}
} }
}catch(error){ }catch(error){
console.log(error); console.log(error);
@ -149,8 +148,11 @@ const JKAffiliateAgreement = () => {
<FalconCardHeader title={t('agreement.page_title')} titleClass="font-weight-semi-bold" /> <FalconCardHeader title={t('agreement.page_title')} titleClass="font-weight-semi-bold" />
<CardBody className="pt-3 pb-5"> <CardBody className="pt-3 pb-5">
{hasExecuted && ( {hasExecuted && (
<div className="alert alert-info execution-date"> <div className="execution-date mb-1">
({t('agreement.executed_on')} {formatDate(agreementData.signed_at)}) ({t('agreement.executed_on')}:&nbsp;
{
agreementData && agreementData.signed_at ? formatDate(agreementData.signed_at) : 'N/A'
})
</div> </div>
)} )}
<Scrollbar ref={scrollbar} style={{ width: '100%', height: 400 }} mobileNative={true}> <Scrollbar ref={scrollbar} style={{ width: '100%', height: 400 }} mobileNative={true}>

View File

@ -56,6 +56,7 @@ class ApiUsersController < ApiController
email: current_user.email, email: current_user.email,
photo_url: current_user.photo_url, photo_url: current_user.photo_url,
show_free_jamtrack: current_user.show_free_jamtrack?, show_free_jamtrack: current_user.show_free_jamtrack?,
is_affiliate_partner: current_user.affiliate_partner.present?,
}, status: 200 }, status: 200
end end