From 05573cdbf2b114a1c355a89f1392ef95ac514ec8 Mon Sep 17 00:00:00 2001
From: kkatusic
Date: Mon, 26 Aug 2024 13:20:54 +0200
Subject: [PATCH 01/49] added project title to notification
---
.../recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx b/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx
index d8d83f5f43..0305bcde03 100644
--- a/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx
+++ b/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx
@@ -204,7 +204,7 @@ export const UpdateStreamInnerModal: FC = ({
<>
{tx && }
= ({
<>
{tx && }
Date: Mon, 26 Aug 2024 15:00:52 +0200
Subject: [PATCH 02/49] Feature: added recurring tab as default for OP address
---
src/components/views/donate/DonationCard.tsx | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/components/views/donate/DonationCard.tsx b/src/components/views/donate/DonationCard.tsx
index 0e706af8f0..d64b3ecece 100644
--- a/src/components/views/donate/DonationCard.tsx
+++ b/src/components/views/donate/DonationCard.tsx
@@ -90,6 +90,15 @@ export const DonationCard: FC = ({
});
}, []);
+ // Check if the 'tab' query parameter is not present in the URL and project 'hasOpAddress' is true.
+ // If both conditions are met, set the active tab to 'RECURRING' using the setTab function.
+ // This ensures that the 'RECURRING' tab is active by default if rpoject has Op Address.
+ useEffect(() => {
+ if (!router.query.tab && hasOpAddress) {
+ setTab(ETabs.RECURRING);
+ }
+ }, [router.query.tab, hasOpAddress]);
+
return (
{!isQRDonation ? (
From 1cb4c02484fd5567ccd3dc5144a21c85e0a07152 Mon Sep 17 00:00:00 2001
From: kkatusic
Date: Mon, 26 Aug 2024 16:49:39 +0200
Subject: [PATCH 03/49] update useEffect dependency
---
src/components/views/donate/DonationCard.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/views/donate/DonationCard.tsx b/src/components/views/donate/DonationCard.tsx
index d64b3ecece..5c4042bcac 100644
--- a/src/components/views/donate/DonationCard.tsx
+++ b/src/components/views/donate/DonationCard.tsx
@@ -97,7 +97,7 @@ export const DonationCard: FC = ({
if (!router.query.tab && hasOpAddress) {
setTab(ETabs.RECURRING);
}
- }, [router.query.tab, hasOpAddress]);
+ }, [router.query, hasOpAddress]);
return (
From 5447b2d3d462f63ca017f7ba3a43597459e55131 Mon Sep 17 00:00:00 2001
From: Hrithik Sampson
Date: Tue, 27 Aug 2024 10:44:56 +0530
Subject: [PATCH 04/49] bug: Add Modal on Donate Page so user can't donate to
his/her own project
---
.../modals/DonationByProjectOwner.tsx | 137 ++++++++++++++++++
src/components/views/donate/DonateIndex.tsx | 22 ++-
2 files changed, 156 insertions(+), 3 deletions(-)
create mode 100644 src/components/modals/DonationByProjectOwner.tsx
diff --git a/src/components/modals/DonationByProjectOwner.tsx b/src/components/modals/DonationByProjectOwner.tsx
new file mode 100644
index 0000000000..9ee7bd9925
--- /dev/null
+++ b/src/components/modals/DonationByProjectOwner.tsx
@@ -0,0 +1,137 @@
+import React from 'react';
+import {
+ brandColors,
+ Button,
+ IconAlertTriangleFilled32,
+ Lead,
+ neutralColors,
+} from '@giveth/ui-design-system';
+import styled from 'styled-components';
+import { useIntl } from 'react-intl';
+import { useRouter } from 'next/router';
+import { Modal } from '@/components/modals/Modal';
+import Routes from '@/lib/constants/Routes';
+import { mediaQueries } from '@/lib/constants/constants';
+import { useModalAnimation } from '@/hooks/useModalAnimation';
+
+// Define the props interface
+interface DonationByProjectOwnerProps {
+ setShowDonationByProjectOwner: (
+ showDonationByProjectOwner: boolean,
+ ) => void;
+}
+
+export const DonationByProjectOwner: React.FC = ({
+ setShowDonationByProjectOwner,
+}) => {
+ const { formatMessage } = useIntl();
+ const router = useRouter();
+ const { closeModal } = useModalAnimation(setShowDonationByProjectOwner);
+
+ const navigateToAllProjects = () => {
+ router.push(Routes.AllProjects);
+ closeModal();
+ };
+
+ return (
+ }
+ doNotCloseOnClickOutside
+ >
+
+
+
+ You cannot donate to a project you are the owner of.
+ There are thousands of projects on Giveth looking for
+ your support! Please choose another project to donate
+ to.
+
+
+
+
+
+
+
+ );
+};
+
+const ModalContainer = styled.div`
+ background: white;
+ color: black;
+ padding: 24px 24px 38px;
+ margin: 0;
+ width: 100%;
+
+ ${mediaQueries.tablet} {
+ width: 494px;
+ }
+`;
+
+const ModalBox = styled.div`
+ color: ${brandColors.deep[900]};
+
+ > :first-child {
+ margin-bottom: 8px;
+ }
+
+ h3 {
+ margin-top: -5px;
+ }
+
+ h6 {
+ color: ${neutralColors.gray[700]};
+ margin-top: -5px;
+ }
+
+ > :last-child {
+ margin: 12px 0 32px 0;
+
+ > span {
+ font-weight: 500;
+ }
+ }
+`;
+
+const ModalButton = styled(Button)`
+ background: ${props =>
+ props.disabled ? brandColors.giv[200] : brandColors.giv[500]};
+
+ &:hover:enabled {
+ background: ${brandColors.giv[700]};
+ }
+
+ :disabled {
+ cursor: not-allowed;
+ }
+
+ > :first-child > div {
+ border-top: 3px solid ${brandColors.giv[200]};
+ animation-timing-function: linear;
+ }
+
+ text-transform: uppercase;
+`;
+
+const Buttons = styled.div`
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+
+ > :first-child {
+ margin: 15px 0;
+ }
+`;
+
+export default DonationByProjectOwner;
diff --git a/src/components/views/donate/DonateIndex.tsx b/src/components/views/donate/DonateIndex.tsx
index d5950c7142..e6e8b96318 100644
--- a/src/components/views/donate/DonateIndex.tsx
+++ b/src/components/views/donate/DonateIndex.tsx
@@ -1,4 +1,4 @@
-import React, { FC, useEffect } from 'react';
+import React, { FC, useEffect, useState } from 'react';
import styled from 'styled-components';
import {
Col,
@@ -24,7 +24,7 @@ import { EContentType } from '@/lib/constants/shareContent';
import { PassportBanner } from '@/components/PassportBanner';
import { useAlreadyDonatedToProject } from '@/hooks/useAlreadyDonatedToProject';
import { Shadow } from '@/components/styled-components/Shadow';
-import { useAppDispatch } from '@/features/hooks';
+import { useAppDispatch, useAppSelector } from '@/features/hooks';
import { setShowHeader } from '@/features/general/general.slice';
import { DonateHeader } from './DonateHeader';
import { DonationCard, ETabs } from './DonationCard';
@@ -44,6 +44,7 @@ import { ChainType } from '@/types/config';
import { useQRCodeDonation } from '@/hooks/useQRCodeDonation';
import EndaomentProjectsInfo from '@/components/views/project/EndaomentProjectsInfo';
import { IDraftDonation } from '@/apollo/types/gqlTypes';
+import DonationByProjectOwner from '@/components/modals/DonationByProjectOwner';
const DonateIndex: FC = () => {
const { formatMessage } = useIntl();
@@ -62,12 +63,14 @@ const DonateIndex: FC = () => {
const { renewExpirationDate } = useQRCodeDonation();
const alreadyDonated = useAlreadyDonatedToProject(project);
+ const { userData } = useAppSelector(state => state.user);
+ const [showDonationByProjectOwner, setShowDonationByProjectOwner] =
+ useState(false);
const dispatch = useAppDispatch();
const isSafeEnv = useIsSafeEnvironment();
const { isOnSolana } = useGeneralWallet();
const router = useRouter();
const { chainId } = useAccount();
-
const [showQRCode, setShowQRCode] = React.useState(
!!router.query.draft_donation,
);
@@ -80,6 +83,12 @@ const DonateIndex: FC = () => {
};
}, [dispatch]);
+ useEffect(() => {
+ setShowDonationByProjectOwner(
+ userData?.id !== undefined && userData?.id === project.adminUser.id,
+ );
+ }, [userData?.id, project.adminUser]);
+
useEffect(() => {
const fetchDonation = async () => {
if (qrDonationStatus === 'success') {
@@ -154,6 +163,13 @@ const DonateIndex: FC = () => {
<>
+ {showDonationByProjectOwner && (
+
+ )}
{alreadyDonated && (
From b71d951508b3c3c1b5ac7edcc72f168d7cd58254 Mon Sep 17 00:00:00 2001
From: Hrithik Sampson
Date: Tue, 27 Aug 2024 11:18:30 +0530
Subject: [PATCH 05/49] chore: add all languages to the DonationByProjectOwner
Modal
---
lang/ca.json | 2 ++
lang/en.json | 2 ++
lang/es.json | 2 ++
src/components/modals/DonationByProjectOwner.tsx | 11 ++++++-----
4 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/lang/ca.json b/lang/ca.json
index 791e811348..c188c94a34 100644
--- a/lang/ca.json
+++ b/lang/ca.json
@@ -1296,6 +1296,8 @@
"label.we_need_a_bit_more_info": "Necessitem una mica més d'informació!",
"label.passport_connected": "Passaport connectat",
"label.increase_passport_score": "Augmenta la puntuació del passaport",
+ "label.project_owner_address_detected": "Adreça del propietari del projecte detectada",
+ "label.project_owner_cant_donate_to_own_project": "No pots donar a un projecte del qual ets propietari. Hi ha milers de projectes a Giveth que busquen el teu suport! Si us plau, tria un altre projecte per donar.",
"label.qf_donor_eligibility.banner.check_eligibility": "Fes que les teves donacions es igualin! Verifica la teva unicitat amb un clic.",
"label.qf_donor_eligibility.banner.recheck_eligibility": "Fes que les teves donacions es igualin! Augmenta la teva puntuació de Gitcoin Passport abans de",
"label.qf_donor_eligibility.banner.more_info_needed": "Necessitem una mica més d'informació per verificar la teva elegibilitat per QF!",
diff --git a/lang/en.json b/lang/en.json
index ee0d5f2299..e1bc3be208 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -1300,6 +1300,8 @@
"label.we_need_a_bit_more_info": "We need a bit more info!",
"label.passport_connected": "Passport connected",
"label.increase_passport_score": "Increase Passport score",
+ "label.project_owner_address_detected": "Project Owner Address Detected",
+ "label.project_owner_cant_donate_to_own_project": "You cannot donate to a project you are the owner of. There are thousands of projects on Giveth looking for your support! Please choose another project to donate to.",
"label.qf_donor_eligibility.banner.check_eligibility": "Get your donations matched! Verify your uniqueness with one click.",
"label.qf_donor_eligibility.banner.recheck_eligibility": "Get your donations matched! Increase your Gitcoin Passport score before",
"label.qf_donor_eligibility.banner.more_info_needed": "We need a bit more information to verify your QF Eligibility!",
diff --git a/lang/es.json b/lang/es.json
index 22caedb7e9..9fd8885fd0 100644
--- a/lang/es.json
+++ b/lang/es.json
@@ -1296,6 +1296,8 @@
"label.we_need_a_bit_more_info": "¡Necesitamos un poco más de información!",
"label.passport_connected": "Pasaporte conectado",
"label.increase_passport_score": "Aumentar la puntuación del pasaporte",
+ "label.project_owner_address_detected": "Dirección del propietario del proyecto detectada",
+ "label.project_owner_cant_donate_to_own_project": "No puedes donar a un proyecto del que eres propietario. ¡Hay miles de proyectos en Giveth que buscan tu apoyo! Por favor, elige otro proyecto para donar.",
"label.qf_donor_eligibility.banner.check_eligibility": "¡Haz que tus donaciones sean igualadas! Verifica tu unicidad con un clic.",
"label.qf_donor_eligibility.banner.recheck_eligibility": "¡Haz que tus donaciones sean igualadas! Aumenta tu puntuación de Gitcoin Passport antes de",
"label.qf_donor_eligibility.banner.more_info_needed": "¡Necesitamos un poco más de información para verificar tu elegibilidad para QF!",
diff --git a/src/components/modals/DonationByProjectOwner.tsx b/src/components/modals/DonationByProjectOwner.tsx
index 9ee7bd9925..62978d202b 100644
--- a/src/components/modals/DonationByProjectOwner.tsx
+++ b/src/components/modals/DonationByProjectOwner.tsx
@@ -37,7 +37,9 @@ export const DonationByProjectOwner: React.FC = ({
}
@@ -46,10 +48,9 @@ export const DonationByProjectOwner: React.FC = ({
- You cannot donate to a project you are the owner of.
- There are thousands of projects on Giveth looking for
- your support! Please choose another project to donate
- to.
+ {formatMessage({
+ id: 'label.project_owner_cant_donate_to_own_project',
+ })}
From 2474052b9473d6fc8755ede9863d0bb84fd13ff7 Mon Sep 17 00:00:00 2001
From: kkatusic
Date: Tue, 27 Aug 2024 14:22:38 +0200
Subject: [PATCH 06/49] fixed typo
---
src/components/views/donate/DonationCard.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/views/donate/DonationCard.tsx b/src/components/views/donate/DonationCard.tsx
index 5c4042bcac..1f8eb01e89 100644
--- a/src/components/views/donate/DonationCard.tsx
+++ b/src/components/views/donate/DonationCard.tsx
@@ -92,7 +92,7 @@ export const DonationCard: FC = ({
// Check if the 'tab' query parameter is not present in the URL and project 'hasOpAddress' is true.
// If both conditions are met, set the active tab to 'RECURRING' using the setTab function.
- // This ensures that the 'RECURRING' tab is active by default if rpoject has Op Address.
+ // This ensures that the 'RECURRING' tab is active by default if project has Op Address.
useEffect(() => {
if (!router.query.tab && hasOpAddress) {
setTab(ETabs.RECURRING);
From 57c3b2c2af16912de8d2f49c3d9a6fe43e8b540e Mon Sep 17 00:00:00 2001
From: Hrithik Sampson
Date: Mon, 19 Aug 2024 19:29:51 +0530
Subject: [PATCH 07/49] fix: trying to resolve order of execution consistency
of hooks in react but falling into queueing issues in react
---
.../SelectTokenModal/SelectTokenModal.tsx | 34 ++++++++++++++++---
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/src/components/views/donate/OnTime/SelectTokenModal/SelectTokenModal.tsx b/src/components/views/donate/OnTime/SelectTokenModal/SelectTokenModal.tsx
index 60f16e7557..45a23d99a6 100644
--- a/src/components/views/donate/OnTime/SelectTokenModal/SelectTokenModal.tsx
+++ b/src/components/views/donate/OnTime/SelectTokenModal/SelectTokenModal.tsx
@@ -8,9 +8,9 @@ import {
IconGIVBack24,
IconSearch16,
} from '@giveth/ui-design-system';
-import { useState, type FC, useEffect } from 'react';
+import { useState, type FC, useEffect, useCallback, use } from 'react';
import { useIntl } from 'react-intl';
-import { erc20Abi, isAddress } from 'viem'; // Assuming `isAddress` is a function from the `viem` library to validate Ethereum addresses
+import { Address, erc20Abi, isAddress } from 'viem'; // Assuming `isAddress` is a function from the `viem` library to validate Ethereum addresses
import { useAccount } from 'wagmi';
import { readContracts } from 'wagmi/actions';
import { IModal } from '@/types/common';
@@ -58,6 +58,30 @@ export const SelectTokenModal: FC = props => {
);
};
+const useTokenBalances = (tokens: IProjectAcceptedToken[] | undefined) => {
+ const [allTokenBalances, setAllTokenBalances] = useState
- {formatAmoutToDisplay(amount)}
+ {formatAmountToDisplay(amount)}
= ({
id: 'label.your_total_donation',
})}
- {formatAmoutToDisplay(amount)}
+ {formatAmountToDisplay(amount)}