Skip to content

Commit

Permalink
Merge pull request #4285 from Giveth/show-qf-related-component-on-rec…
Browse files Browse the repository at this point in the history
…urring-donation

Show qf related component on recurring donation
  • Loading branch information
MohammadPCh authored Jun 19, 2024
2 parents 94fcf28 + f3ea165 commit 01ed229
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
25 changes: 16 additions & 9 deletions src/components/views/donate/DonateIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '@giveth/ui-design-system';
import { useIntl } from 'react-intl';
import { useRouter } from 'next/router';
import { useAccount } from 'wagmi';
import SocialBox from '../../DonateSocialBox';
import NiceBanner from './NiceBanner';
// import PurchaseXDAI from './PurchaseXDAIBanner';
Expand All @@ -31,6 +32,7 @@ import QFSection from '../project/projectActionCard/QFSection';
import ProjectCardImage from '@/components/project-card/ProjectCardImage';
import { useGeneralWallet } from '@/providers/generalWalletProvider';
import { DonatePageProjectDescription } from './DonatePageProjectDescription';
import { getActiveRound } from '@/helpers/qf';

const DonateIndex: FC = () => {
const { formatMessage } = useIntl();
Expand All @@ -41,6 +43,7 @@ const DonateIndex: FC = () => {
const isSafeEnv = useIsSafeEnvironment();
const { isOnSolana } = useGeneralWallet();
const router = useRouter();
const { chainId } = useAccount();

useEffect(() => {
dispatch(setShowHeader(false));
Expand All @@ -50,6 +53,9 @@ const DonateIndex: FC = () => {
}, [dispatch]);

const isRecurringTab = router.query.tab?.toString() === ETabs.RECURRING;
const { activeStartedRound } = getActiveRound(project.qfRounds);
const isOnEligibleNetworks =
chainId && activeStartedRound?.eligibleNetworks?.includes(chainId);

return successDonation ? (
<>
Expand Down Expand Up @@ -86,15 +92,16 @@ const DonateIndex: FC = () => {
<ImageWrapper>
<ProjectCardImage image={project.image} />
</ImageWrapper>
{!isMobile &&
!isRecurringTab &&
hasActiveQFRound ? (
<QFSection projectData={project} />
) : (
<DonatePageProjectDescription
projectData={project}
/>
)}
{!isMobile ? (
(!isRecurringTab && hasActiveQFRound) ||
(isRecurringTab && isOnEligibleNetworks) ? (
<QFSection projectData={project} />
) : (
<DonatePageProjectDescription
projectData={project}
/>
)
) : null}
</InfoWrapper>
</Col>
</Row>
Expand Down
1 change: 1 addition & 0 deletions src/components/views/donate/DonateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ const DonateModal: FC<IDonateModalProps> = props => {
setSuccessDonation({
txHash: txHashArray,
givBackEligible,
chainId,
});
}, 4000);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,16 +452,16 @@ const RecurringDonationInnerModal: FC<IRecurringDonationInnerModalProps> = ({
{ txHash: tx.hash, chainType: ChainType.EVM },
{ txHash: tx.hash, chainType: ChainType.EVM },
],
excludeFromQF: true,
isRecurring: true,
givBackEligible: true,
chainId: config.OPTIMISM_NETWORK_NUMBER,
});
} else {
setSuccessDonation({
txHash: [{ txHash: tx.hash, chainType: ChainType.EVM }],
excludeFromQF: true,
isRecurring: true,
givBackEligible: true,
chainId: config.OPTIMISM_NETWORK_NUMBER,
});
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/components/views/donate/SuccessView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import React, { FC, useEffect, useState } from 'react';
import styled from 'styled-components';
import { useIntl } from 'react-intl';
import { useAccount } from 'wagmi';
import ExternalLink from '@/components/ExternalLink';
import { client } from '@/apollo/apolloClient';
import { FETCH_GIVETH_PROJECT_BY_ID } from '@/apollo/gql/gqlProjects';
Expand All @@ -38,6 +37,7 @@ export const SuccessView: FC = () => {
const {
givBackEligible,
txHash = [],
chainId,
excludeFromQF,
isRecurring,
} = successDonation || {};
Expand All @@ -49,9 +49,6 @@ export const SuccessView: FC = () => {
info: { passportState },
} = usePassport();

const { chain } = useAccount();
const networkId = chain?.id;

const message = hasMultipleTxs ? (
<>
{formatMessage(
Expand All @@ -70,7 +67,7 @@ export const SuccessView: FC = () => {
const { activeStartedRound } = getActiveRound(project.qfRounds);

const isOnEligibleNetworks =
networkId && activeStartedRound?.eligibleNetworks?.includes(networkId);
chainId && activeStartedRound?.eligibleNetworks?.includes(chainId);

useEffect(() => {
if (!hasMultipleTxs) return;
Expand Down
1 change: 1 addition & 0 deletions src/context/donate.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface TxHashWithChainType {
}
interface ISuccessDonation {
txHash: TxHashWithChainType[];
chainId: number;
givBackEligible?: boolean;
excludeFromQF?: boolean;
isRecurring?: boolean;
Expand Down

0 comments on commit 01ed229

Please sign in to comment.