Skip to content
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

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lang/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -1661,20 +1661,22 @@
"project.givback_toast.description.non_verified_owner_rejected_2": " o al suport de Discord per a més instruccions.",
"project.givback_toast.description.non_verified_owner_submitted": "Notícies emocionants! La teva sol·licitud ha estat enviada i està a la cua per ser revisada pel nostre equip de revisió d'elegibilitat per a GIVbacks. Et respondrem en un termini d'1-2 setmanes.",
"project.givback_toast.description.non_verified_public": "Actualment, els GIVbacks només s'atorguen per donacions fetes a projectes elegibles per a GIVbacks a Ethereum. La teva contribució segueix sent important, fins i tot si no genera GIVbacks!",
"project.givback_toast.description.verified_owner": "Potencia el teu projecte per augmentar el seu percentatge de GIVbacks i ajudar-lo a aparèixer més amunt a la pàgina de projectes!",
"project.givback_toast.description.verified_public": "Les donacions a Ethereum a projectes elegibles per a GIVbacks són recompensades amb GIV. Impulsa aquest projecte per augmentar el seu percentatge de recompenses i fer-lo més visible a la pàgina de projectes!", "project.givback_toast.title.non_verified_owner": "El teu projecte està creant o donant suport a béns públics?",
"project.givback_toast.description.verified_owner_not_eligible": "El teu projecte ha estat avalat pels Verificadors de Giveth i ara pot beneficiar-se de GIVpower. Fes stake i bloqueja els teus tokens GIV per impulsar aquest projecte i fer-lo més visible a la pàgina de projectes. No obstant això, donar a aquest projecte no generarà GIVbacks per als donants.",
"project.givback_toast.title.non_verified_owner_cancelled": "Estat Cancel·lat",
"project.givback_toast.description.verified_owner": "Potencia el teu projecte per augmentar el seu percentatge de GIVbacks i ajudar-lo a aparèixer més amunt a la pàgina de projectes!",
"project.givback_toast.description.verified_public": "Les donacions a Ethereum a projectes elegibles per a GIVbacks són recompensades amb GIV. Impulsa aquest projecte per augmentar el seu percentatge de recompenses i fer-lo més visible a la pàgina de projectes!",
"project.givback_toast.title.non_verified_owner": "El teu projecte està creant o donant suport a béns públics?",
"project.givback_toast.description.verified_owner_not_eligible": "El teu projecte ha estat avalat pels Verificadors de Giveth i ara pot beneficiar-se de GIVpower. Fes stake i bloqueja els teus tokens GIV per impulsar aquest projecte i fer-lo més visible a la pàgina de projectes. No obstant això, donar a aquest projecte no generarà GIVbacks per als donants.",
"project.givback_toast.title.non_verified_owner_cancelled": "Estat Cancel·lat",
"project.givback_toast.title.non_verified_owner_deactive": "Mode Desactivat",
"project.givback_toast.title.non_verified_owner_draft": "Publica el teu projecte avui!",
"project.givback_toast.title.non_verified_owner_incomplete": "Sol·licitud Incompleta",
"project.givback_toast.title.non_verified_owner_rejected": "No vam poder aprovar el teu projecte com a elegible per a GIVbacks",
"project.givback_toast.title.non_verified_owner_submitted": "Sol·licitud enviada",
"project.givback_toast.title.non_verified_public": "Per què no hi ha GIVbacks?",
"project.givback_toast.title.verified_public_1": "Rep recompenses de fins a ",
"project.givback_toast.title.verified_public_3": "Rep recompenses de fins a {percent}%",
"project.givback_toast.title.verified_owner": "Les donacions de {value}$ o més són elegibles per a reemborsaments de fins a un {percent}%!",
"project.givback_toast.title.verified_owner_not_eligible": "El teu projecte ha estat avalat",
"project.givback_toast.title.verified_public_2": " del valor de la teva donació!",
"project.givback_toast.title.verified_owner_not_eligible": "El teu projecte ha estat avalat",
"project.givback_toast.title.verified_public_2": " del valor de la teva donació!",
"project.givback_toast.title.verified_public_not_eligible": "Impulsa aquest projecte amb GIVpower!",
"projects_all": "Tots els Projectes",
"projects_all_desc": "SUPORT A PROJECTES GLOBALS DE BÉS PÚBLICS, SOSTENIBILITAT I REGENERACIÓ AMB CRYPTODONACIONS",
Expand Down
17 changes: 9 additions & 8 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1661,21 +1661,22 @@
"project.givback_toast.description.non_verified_owner_rejected_2": " or Discord support for more instructions.",
"project.givback_toast.description.non_verified_owner_submitted": "Exciting news! Your application has been submitted and is in the queue for review by our GIVbacks Eligibility review team. We will get back to you with a response within 1-2 weeks.",
"project.givback_toast.description.non_verified_public": "GIVbacks are currently only awarded for donations made to GIVbacks Eligible projects on Ethereum. Your contribution still matters, even if it doesn't generate GIVbacks!",
"project.givback_toast.description.verified_owner": "Boost your project to increase its GIVbacks percentage and help it appear higher on the projects page!",
"project.givback_toast.description.verified_public": "Donations of ${value} or more are eligible for GIVbacks. Boost this project to increase its rewards percentage and visibility on the projects page!",
"project.givback_toast.description.verified_owner_not_eligible": "Your project has been vouched for by Giveth Verifiers and can now benefit from GIVpower! Stake and lock your GIV tokens to boost this project and make it more visible on the projects page. However, donating to this project won't yield GIVbacks to donors.",
"project.givback_toast.title.non_verified_owner": "Is your project creating or supporting public goods?",
"project.givback_toast.description.verified_public_not_eligible": "{stakeLock} your GIV tokens to get GIVpower. Boost this project make it more visible on the projects page! Note that while this project is eligible to be boosted with GIVpower, it will not yield GIVbacks to it's donors.",
"project.givback_toast.title.non_verified_owner_cancelled": "Project Cancelled",
"project.givback_toast.description.verified_owner": "Boost your project to increase its GIVbacks percentage and help it appear higher on the projects page!",
"project.givback_toast.description.verified_public": "Donations of ${value} or more are eligible for GIVbacks. Boost this project to increase its rewards percentage and visibility on the projects page!",
"project.givback_toast.description.verified_owner_not_eligible": "Your project has been vouched for by Giveth Verifiers and can now benefit from GIVpower! Stake and lock your GIV tokens to boost this project and make it more visible on the projects page. However, donating to this project won't yield GIVbacks to donors.",
"project.givback_toast.title.non_verified_owner": "Is your project creating or supporting public goods?",
"project.givback_toast.description.verified_public_not_eligible": "{stakeLock} your GIV tokens to get GIVpower. Boost this project make it more visible on the projects page! Note that while this project is eligible to be boosted with GIVpower, it will not yield GIVbacks to it's donors.",
"project.givback_toast.title.non_verified_owner_cancelled": "Project Cancelled",
"project.givback_toast.title.non_verified_owner_deactive": "Project Deactivated",
"project.givback_toast.title.non_verified_owner_draft": "Publish your project today!",
"project.givback_toast.title.non_verified_owner_incomplete": "Application incomplete",
"project.givback_toast.title.non_verified_owner_rejected": "We couldn't approve your project as GIVbacks eligible",
"project.givback_toast.title.non_verified_owner_submitted": "Application submitted",
"project.givback_toast.title.non_verified_public": "Why no GIVbacks?",
"project.givback_toast.title.verified_public_1": "Get rewarded with up to ",
"project.givback_toast.title.verified_owner_not_eligible": "Your project has been Vouched for",
"project.givback_toast.title.verified_owner": "Donations of ${value} or more qualify for GIVbacks with up to {percent}%!",
"project.givback_toast.title.verified_public_3": "Get rewarded with up to {percent}%",
"project.givback_toast.title.verified_owner_not_eligible": "Your project has been Vouched for",
"project.givback_toast.title.verified_owner": "Donations of ${value} or more qualify for GIVbacks with up to {percent}%!",
"project.givback_toast.title.verified_public_2": " of your donation value!",
"project.givback_toast.title.verified_public_not_eligible": "Boost this project with GIVpower!",
"projects_all": "All Projects",
Expand Down
15 changes: 8 additions & 7 deletions lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1661,11 +1661,11 @@
"project.givback_toast.description.non_verified_owner_rejected_2": " o al soporte de Discord para más instrucciones.",
"project.givback_toast.description.non_verified_owner_submitted": "¡Noticias emocionantes! Tu solicitud ha sido enviada y está en la cola para ser revisada por nuestro equipo de revisión de elegibilidad para GIVbacks. Te responderemos en un plazo de 1-2 semanas.",
"project.givback_toast.description.non_verified_public": "Actualmente, los GIVbacks solo se otorgan por donaciones hechas a proyectos elegibles para GIVbacks en Ethereum. ¡Tu contribución sigue siendo importante, incluso si no genera GIVbacks!",
"project.givback_toast.description.verified_owner": "Impulsa tu proyecto para aumentar la cantidad de GIVbacks que reciben tus donantes en Ethereum y aumentar su visibilidad entre otros proyectos.",
"project.givback_toast.description.verified_owner_not_eligible": "Tu proyecto ha sido avalado por los Verificadores de Giveth y ahora puede beneficiarse de GIVpower. Haz stake y bloquea tus tokens GIV para impulsar este proyecto y hacerlo más visible en la página de proyectos. Sin embargo, donar a este proyecto no generará GIVbacks para los donantes.",
"project.givback_toast.description.verified_public": "Las donaciones de ${value} o más son elegibles para recibir GIVbacks. ¡Impulsa este proyecto para aumentar su porcentaje de recompensas y su visibilidad en la página de proyectos!",
"project.givback_toast.description.verified_public_not_eligible": "{stakeLock} tus GIV tokens para obtener GIVpower. ¡Impulsa este proyecto para hacerlo más visible en la página de proyectos! Ten en cuenta que aunque este proyecto es elegible para ser impulsado con GIVpower, no generará GIVbacks para sus donantes.",
"project.givback_toast.title.non_verified_owner": "¿Tu proyecto está creando o apoyando bienes públicos?",
"project.givback_toast.description.verified_owner": "Impulsa tu proyecto para aumentar la cantidad de GIVbacks que reciben tus donantes en Ethereum y aumentar su visibilidad entre otros proyectos.",
"project.givback_toast.description.verified_owner_not_eligible": "Tu proyecto ha sido avalado por los Verificadores de Giveth y ahora puede beneficiarse de GIVpower. Haz stake y bloquea tus tokens GIV para impulsar este proyecto y hacerlo más visible en la página de proyectos. Sin embargo, donar a este proyecto no generará GIVbacks para los donantes.",
"project.givback_toast.description.verified_public": "Las donaciones de ${value} o más son elegibles para recibir GIVbacks. ¡Impulsa este proyecto para aumentar su porcentaje de recompensas y su visibilidad en la página de proyectos!",
"project.givback_toast.description.verified_public_not_eligible": "{stakeLock} tus GIV tokens para obtener GIVpower. ¡Impulsa este proyecto para hacerlo más visible en la página de proyectos! Ten en cuenta que aunque este proyecto es elegible para ser impulsado con GIVpower, no generará GIVbacks para sus donantes.",
"project.givback_toast.title.non_verified_owner": "¿Tu proyecto está creando o apoyando bienes públicos?",
"project.givback_toast.title.non_verified_owner_cancelled": "Estado Cancelado",
"project.givback_toast.title.non_verified_owner_deactive": "Modo Desactivado",
"project.givback_toast.title.non_verified_owner_draft": "¡Publica tu proyecto hoy!",
Expand All @@ -1674,9 +1674,10 @@
"project.givback_toast.title.non_verified_owner_submitted": "Solicitud enviada",
"project.givback_toast.title.non_verified_public": "¿Por qué no GIVbacks?",
"project.givback_toast.title.verified_public_1": "¡Recibe recompensas de hasta ",
"project.givback_toast.title.verified_public_3": "Recibe recompensas de hasta {percent}%",
"project.givback_toast.title.verified_owner": "¡Las donaciones de ${value} o más califican para GIVbacks con hasta un {percent}%!",
"project.givback_toast.title.verified_owner_not_eligible": "Tu proyecto ha sido avalado",
"project.givback_toast.title.verified_public_2": " del valor de tu donación!",
"project.givback_toast.title.verified_owner_not_eligible": "Tu proyecto ha sido avalado",
"project.givback_toast.title.verified_public_2": " del valor de tu donación!",
"project.givback_toast.title.verified_public_not_eligible": "Boostea este proyecto con GIVpower!",
"projects_all": "Todos los proyectos",
"projects_all_desc": "APOYE PROYECTOS GLOBALES EN BIENES PÚBLICOS, SOSTENIBILIDAD Y REGENERACIÓN CON CRIPTODONACIONES",
Expand Down
9 changes: 6 additions & 3 deletions src/components/VerificationBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import { EVerificationStatus } from '@/apollo/types/types';
import { Badge, EBadgeStatus } from './Badge';

interface IProps {
isVerified?: boolean;
isGivbackEligible?: boolean;
verificationStatus?: EVerificationStatus;
}

const VerificationBadge: FC<IProps> = ({ isVerified, verificationStatus }) => {
const verStatus = isVerified
const VerificationBadge: FC<IProps> = ({
isGivbackEligible,
verificationStatus,
}) => {
const verStatus = isGivbackEligible
? EVerificationStatus.VERIFIED
: verificationStatus !== EVerificationStatus.VERIFIED
? verificationStatus
Expand Down
16 changes: 13 additions & 3 deletions src/components/views/project/ProjectBadges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@ import { IconWithTooltip } from '@/components/IconWithToolTip';
const ProjectBadges = () => {
const { projectData } = useProjectContext();

const { verified, isGivbackEligible, qfRounds, campaigns } =
projectData || {};
const {
verified: projectVerified,
isGivbackEligible,
qfRounds,
campaigns,
} = projectData || {};
const { formatMessage } = useIntl();
const isQF = hasActiveRound(qfRounds);
const verified = projectVerified || isGivbackEligible;

if (!verified && !isQF && (!campaigns || campaigns.length === 0)) {
if (
!verified &&
!isGivbackEligible &&
!isQF &&
(!campaigns || campaigns.length === 0)
) {
return null;
}

Expand Down
59 changes: 30 additions & 29 deletions src/components/views/project/ProjectGIVbackToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

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 to isOwnerNotGivbackEligible or isOwnerGivbackNotEligible for better clarity and to prevent confusion with isVerified.

const isPublicGivbackEligible = isGivbackEligible && !isAdmin;
const isPublicVerifiedNotEligible =
isVerified && !isAdmin && !isGivbackEligible;
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The 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(
{
Expand Down Expand Up @@ -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`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const ProjectStats = () => {
</IconWithTooltip>
</Flex>
<VerificationBadge
isVerified={projectData?.isGivbackEligible}
isGivbackEligible={projectData?.isGivbackEligible}
verificationStatus={projectData?.verificationFormStatus}
/>
</StatRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const ProjectItem: FC<IProjectItem> = props => {
</P>
<div>
<VerificationBadge
isVerified={project?.isGivbackEligible}
isGivbackEligible={project?.isGivbackEligible}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Verification of VerificationBadge Prop Update Reveals Issues

The VerificationBadge component does not appear to have been updated to handle the new isGivbackEligible prop. While other components are passing this prop, the VerificationBadge itself may not be correctly receiving or utilizing it.

  • VerificationBadge Component:
    • Ensure that VerificationBadge accepts and appropriately uses the isGivbackEligible prop.
🔗 Analysis chain

Verify the impact of changing isVerified to isGivbackEligible

The prop passed to VerificationBadge has been updated from isVerified to isGivbackEligible, which aligns with the PR objective of fixing the deverification logic. This change shifts the focus from general verification to specific GIVback eligibility.

To ensure this change is implemented correctly and consistently:

  1. Confirm that the VerificationBadge component has been updated to handle the new isGivbackEligible prop correctly.
  2. Verify that the project object includes the isGivbackEligible property and that it's being set correctly.
  3. Check other components using VerificationBadge to ensure consistent prop usage across the codebase.

Run the following script to verify the changes:


Re-running Verification Scripts with Adjusted Commands

The previous verification attempt failed because the ripgrep tool did not recognize the typescript file type. Adjusting the scripts to target TypeScript files using file extensions instead.

[/run_scripts]


Re-running Verification Scripts with Updated File Patterns

The previous verification did not find any usages of VerificationBadge because .tsx files were not included in the search. Updating the glob pattern to include both .ts and .tsx files to ensure all relevant files are checked.

[/run_scripts]

🏁 Scripts executed

The 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
}
Expand Down
Loading