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

Feat/issue 4612 #4626

Merged
merged 4 commits into from
Sep 8, 2024
Merged

Feat/issue 4612 #4626

merged 4 commits into from
Sep 8, 2024

Conversation

HrithikSampson
Copy link
Collaborator

@HrithikSampson HrithikSampson commented Aug 27, 2024

relates to #4612

Summary of Changes:

  1. Add a Modal preventing users to donate to their own Page

  2. The Modal is shown when the project's AdminUser ID matches that of the current Users ID when Users accesses /donate/projectBySlugId.

Summary by CodeRabbit

  • New Features

    • Introduced enhanced localization support for project ownership and donation eligibility in Catalan, English, and Spanish.
    • Added a modal for project owners that informs them they cannot donate to their own project and encourages them to support others.
  • Bug Fixes

    • Improved user feedback regarding donation rules and project ownership visibility.

Copy link

vercel bot commented Aug 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
giveth-dapps-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 8, 2024 7:42am

Copy link
Contributor

coderabbitai bot commented Aug 27, 2024

Walkthrough

The changes introduce new localization strings to support project owner notifications regarding donation eligibility across multiple languages. A new React component is implemented to display a modal for project owners attempting to donate to their own projects. The DonateIndex component is modified to manage state for rendering the modal based on user roles, enhancing the overall donation flow and user experience.

Changes

File Change Summary
lang/ca.json, lang/en.json, lang/es.json Added new localization strings for detecting project owner address and informing donation restrictions.
src/components/modals/DonationByProjectOwner.tsx Introduced a modal component to inform project owners they cannot donate to their own projects.
src/components/views/donate/DonateIndex.tsx Modified to manage state for showing the donation modal based on user ownership of the project.

Possibly related issues

Poem

🐰 In a world of giving, hopping around,
A modal pops up with a soft, friendly sound.
"Dear project owner," it gently will say,
"Your heart's in the right place, but not this way!"
So choose another project, let kindness abound,
With every donation, joy can be found! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Comment on lines +24 to +69
export const DonationByProjectOwner: React.FC<DonationByProjectOwnerProps> = ({
setShowDonationByProjectOwner,
}) => {
const { formatMessage } = useIntl();
const router = useRouter();
const { closeModal } = useModalAnimation(setShowDonationByProjectOwner);

const navigateToAllProjects = () => {
router.push(Routes.AllProjects);
closeModal();
};

return (
<Modal
closeModal={closeModal}
isAnimating={false}
headerTitle={formatMessage({
id: 'label.project_owner_address_detected',
})}
headerTitlePosition='left'
hiddenClose={true}
headerIcon={<IconAlertTriangleFilled32 size={32} />}
doNotCloseOnClickOutside
>
<ModalContainer>
<ModalBox>
<Lead>
{formatMessage({
id: 'label.project_owner_cant_donate_to_own_project',
})}
</Lead>
</ModalBox>
<Buttons>
<ModalButton
buttonType='primary'
disabled={false}
label={formatMessage({
id: 'label.view_all_projects',
})}
onClick={navigateToAllProjects} // Navigate to the All Projects route
/>
</Buttons>
</ModalContainer>
</Modal>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider making the isAnimating prop dynamic.

The isAnimating prop is hardcoded to false. Consider making it dynamic to reflect the actual animation state.

Apply this diff to make the isAnimating prop dynamic:

-			isAnimating={false}
+			isAnimating={isAnimating}

Committable suggestion was skipped due to low confidence.

Comment on lines +66 to +68
const { userData } = useAppSelector(state => state.user);
const [showDonationByProjectOwner, setShowDonationByProjectOwner] =
useState<boolean | undefined>(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify state initialization.

The showDonationByProjectOwner state is initialized with false but can be simplified.

Apply this diff to simplify the state initialization:

-	const [showDonationByProjectOwner, setShowDonationByProjectOwner] =
-		useState<boolean | undefined>(false);
+	const [showDonationByProjectOwner, setShowDonationByProjectOwner] = useState(false);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { userData } = useAppSelector(state => state.user);
const [showDonationByProjectOwner, setShowDonationByProjectOwner] =
useState<boolean | undefined>(false);
const { userData } = useAppSelector(state => state.user);
const [showDonationByProjectOwner, setShowDonationByProjectOwner] = useState(false);

Comment on lines +86 to +90
useEffect(() => {
setShowDonationByProjectOwner(
userData?.id !== undefined && userData?.id === project.adminUser.id,
);
}, [userData?.id, project.adminUser]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize the useEffect hook.

The useEffect hook for setting showDonationByProjectOwner can be optimized by removing the redundant check for userData?.id !== undefined.

Apply this diff to optimize the useEffect hook:

	useEffect(() => {
		setShowDonationByProjectOwner(
-			userData?.id !== undefined && userData?.id === project.adminUser.id,
+			userData?.id === project.adminUser.id,
		);
	}, [userData?.id, project.adminUser]);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
setShowDonationByProjectOwner(
userData?.id !== undefined && userData?.id === project.adminUser.id,
);
}, [userData?.id, project.adminUser]);
useEffect(() => {
setShowDonationByProjectOwner(
userData?.id === project.adminUser.id,
);
}, [userData?.id, project.adminUser]);

@HrithikSampson HrithikSampson requested review from mohammadranjbarz and removed request for MohammadPCh September 5, 2024 12:58
Copy link
Contributor

@mohammadranjbarz mohammadranjbarz left a comment

Choose a reason for hiding this comment

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

Thanks @HrithikSampson LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: QA
Development

Successfully merging this pull request may close these issues.

2 participants