-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Feat/issue 4612 #4626
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe 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 Changes
Possibly related issues
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 3
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> | ||
); | ||
}; |
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.
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.
const { userData } = useAppSelector(state => state.user); | ||
const [showDonationByProjectOwner, setShowDonationByProjectOwner] = | ||
useState<boolean | undefined>(false); |
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.
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.
const { userData } = useAppSelector(state => state.user); | |
const [showDonationByProjectOwner, setShowDonationByProjectOwner] = | |
useState<boolean | undefined>(false); | |
const { userData } = useAppSelector(state => state.user); | |
const [showDonationByProjectOwner, setShowDonationByProjectOwner] = useState(false); |
useEffect(() => { | ||
setShowDonationByProjectOwner( | ||
userData?.id !== undefined && userData?.id === project.adminUser.id, | ||
); | ||
}, [userData?.id, project.adminUser]); |
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.
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.
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]); |
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.
Thanks @HrithikSampson LGTM
…/issue-4612 Update Branch
relates to #4612
Summary of Changes:
Add a Modal preventing users to donate to their own Page
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
Bug Fixes