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 donate button for deactive projects #5041

Merged
merged 2 commits into from
Mar 3, 2025
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
21 changes: 19 additions & 2 deletions src/components/views/donate/Recurring/RecurringDonationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Image from 'next/image';
import Link from 'next/link';
import { useIntl } from 'react-intl';
import BigNumber from 'bignumber.js';
import { EProjectStatus } from '@/apollo/types/gqlEnums';
import { AddressZero, ONE_MONTH_SECONDS } from '@/lib/constants/constants';
import { FlowRateTooltip } from '@/components/GIVeconomyPages/GIVstream.sc';
import { IconWithTooltip } from '@/components/IconWithToolTip';
Expand Down Expand Up @@ -97,6 +98,7 @@ export function mapValueInverse(value: number) {
export const RecurringDonationCard = () => {
const { project, selectedRecurringToken, tokenStreams } = useDonateData();
const isGivethProject = Number(project.id!) === config.GIVETH_PROJECT_ID;
const isActive = project.status?.name === EProjectStatus.ACTIVE;
const [amount, setAmount] = useState(0n);
const [perMonthAmount, setPerMonthAmount] = useState(0n);
const [isUpdating, setIsUpdating] = useState(false);
Expand Down Expand Up @@ -135,7 +137,6 @@ export const RecurringDonationCard = () => {
: selectedRecurringToken?.token.id,
address: address,
});

useEffect(() => {
if (!selectedRecurringToken || !balance) return;
if (selectedRecurringToken.token.isSuperToken) {
Expand Down Expand Up @@ -749,10 +750,26 @@ export const RecurringDonationCard = () => {
</Flex>
</Flex>
</DonatesInfoSection>
{!isActive && (
<div
style={{
marginTop: '10px',
padding: '8px',
width: '100%',
}}
>
<InlineToast
type={EToastType.Warning}
message={formatMessage({
id: 'label.this_project_is_not_active',
})}
/>
</div>
)}
<ActionButton
label={formatMessage({ id: 'label.donate' })}
onClick={handleDonate}
disabled={isFormInvalid}
disabled={!isActive || isFormInvalid}
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ export const ProjectPublicActions = () => {
</SublineBold>
</AlreadyDonatedWrapper>
)}
<Link id='Donate_Project' href={slugToProjectDonate(slug || '')}>
<Link
id='Donate_Project'
href={isActive ? slugToProjectDonate(slug || '') : '#'}
onClick={e => !isActive && e.preventDefault()}
style={{ pointerEvents: !isActive ? 'none' : 'auto' }}
>
<DonateButton
label={formatMessage({ id: 'label.donate' })}
disabled={!isActive}
Expand Down
Loading