-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: Deverification logic mess on badges and admin actions #4792
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ const ProjectGIVbackToast = () => { | |
const isGivbackEligible = projectData?.isGivbackEligible; | ||
const { givbackFactor } = projectData || {}; | ||
const isOwnerGivbackEligible = isGivbackEligible && isAdmin; | ||
const isOwnerNotVerified = !isVerified && isAdmin; | ||
const isOwnerNotVerified = !isGivbackEligible && isAdmin; | ||
const isPublicGivbackEligible = isGivbackEligible && !isAdmin; | ||
const isPublicVerifiedNotEligible = | ||
isVerified && !isAdmin && !isGivbackEligible; | ||
|
@@ -92,7 +92,35 @@ const ProjectGIVbackToast = () => { | |
|
||
const givbackFactorPercent = ((givbackFactor || 0) * 100).toFixed(); | ||
|
||
if (isOwnerGivbackEligible) { | ||
if (isPublicGivbackEligible) { | ||
if (givbackFactor !== 0) { | ||
title = formatMessage( | ||
{ | ||
id: `${useIntlTitle}verified_public_3`, | ||
}, | ||
{ | ||
percent: givbackFactorPercent, | ||
// value: GIVBACKS_DONATION_QUALIFICATION_VALUE_USD, | ||
}, | ||
); | ||
} | ||
description = formatMessage( | ||
{ | ||
id: `${useIntlDescription}verified_public`, | ||
}, | ||
{ | ||
value: GIVBACKS_DONATION_QUALIFICATION_VALUE_USD, | ||
}, | ||
); | ||
link = links.GIVPOWER_DOC; | ||
Button = ( | ||
<OutlineButton | ||
onClick={handleBoostClick} | ||
label='Boost' | ||
icon={<IconRocketInSpace16 />} | ||
/> | ||
); | ||
} else if (isOwnerGivbackEligible) { | ||
Comment on lines
+95
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Refactor nested conditionals to improve readability. The block of code from lines 95 to 123 contains nested conditionals that handle various eligibility states. Consider refactoring to simplify the logic and enhance readability. One approach is to use a mapping of conditions to their corresponding title, description, link, and Button components. |
||
if (givbackFactor !== 0) { | ||
title = formatMessage( | ||
{ | ||
|
@@ -253,33 +281,6 @@ const ProjectGIVbackToast = () => { | |
icon={<IconRocketInSpace16 />} | ||
/> | ||
); | ||
} else if (isPublicGivbackEligible) { | ||
if (givbackFactor !== 0) { | ||
title = | ||
formatMessage({ | ||
id: `${useIntlTitle}verified_public_1`, | ||
}) + | ||
Math.round(+(givbackFactor || 0) * 100) + | ||
'%' + | ||
formatMessage({ | ||
id: `${useIntlTitle}verified_public_2`, | ||
}); | ||
} | ||
description = formatMessage( | ||
{ | ||
id: `${useIntlDescription}verified_public`, | ||
}, | ||
{ | ||
value: GIVBACKS_DONATION_QUALIFICATION_VALUE_USD, | ||
}, | ||
); | ||
Button = ( | ||
<OutlineButton | ||
onClick={handleBoostClick} | ||
label='Boost' | ||
icon={<IconRocketInSpace16 />} | ||
/> | ||
); | ||
} else { | ||
title = formatMessage({ | ||
id: `${useIntlTitle}non_verified_public`, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,7 @@ const ProjectItem: FC<IProjectItem> = props => { | |
</P> | ||
<div> | ||
<VerificationBadge | ||
isVerified={project?.isGivbackEligible} | ||
isGivbackEligible={project?.isGivbackEligible} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Verification of The
🔗 Analysis chainVerify the impact of changing The prop passed to To ensure this change is implemented correctly and consistently:
Run the following script to verify the changes: Re-running Verification Scripts with Adjusted Commands The previous verification attempt failed because the [/run_scripts] Re-running Verification Scripts with Updated File Patterns The previous verification did not find any usages of [/run_scripts] 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the VerificationBadge component and its usage
# Test 1: Check if VerificationBadge component has been updated
echo "Checking VerificationBadge component:"
ast-grep --lang typescript --pattern $'const VerificationBadge = ({ isGivbackEligible, $_* }) => {
$$$
}'
# Test 2: Verify project object includes isGivbackEligible property
echo "Checking project object for isGivbackEligible property:"
rg --type typescript 'interface IProject' -A 20 | rg 'isGivbackEligible'
# Test 3: Check other usages of VerificationBadge
echo "Checking other usages of VerificationBadge:"
rg --type typescript 'VerificationBadge' -A 3 -B 1
Length of output: 605 Script: #!/bin/bash
# Description: Verify the VerificationBadge component and its usage without specifying file types
# Test 1: Check if VerificationBadge component has been updated
echo "Checking VerificationBadge component:"
ast-grep --lang typescript --pattern $'const VerificationBadge = ({ isGivbackEligible, $_* }) => {
$$$
}'
# Test 2: Verify project object includes isGivbackEligible property
echo "Checking project object for isGivbackEligible property:"
rg 'interface IProject' -A 20 | rg 'isGivbackEligible'
# Test 3: Check other usages of VerificationBadge
echo "Checking other usages of VerificationBadge:"
rg 'VerificationBadge' --glob '*.ts' -A 3 -B 1
Length of output: 628 Script: #!/bin/bash
# Description: Verify the VerificationBadge component and its usage, including .tsx files
# Test 1: Check if VerificationBadge component has been updated
echo "Checking VerificationBadge component:"
ast-grep --lang typescript --pattern $'const VerificationBadge = ({ isGivbackEligible, $_* }) => {
$$$
}'
# Test 2: Verify project object includes isGivbackEligible property
echo "Checking project object for isGivbackEligible property:"
rg 'interface IProject' | rg 'isGivbackEligible'
# Test 3: Check other usages of VerificationBadge
echo "Checking other usages of VerificationBadge:"
rg 'VerificationBadge' --glob '*.{ts,tsx}' -A 3 -B 1
Length of output: 2888 |
||
verificationStatus={ | ||
project.projectVerificationForm?.status | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider renaming
isOwnerNotVerified
for clarity.The variable
isOwnerNotVerified
is defined as!isGivbackEligible && isAdmin;
. Since it reflects the GIVback eligibility status rather than the verification status, consider renaming it toisOwnerNotGivbackEligible
orisOwnerGivbackNotEligible
for better clarity and to prevent confusion withisVerified
.