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

Add recurring to donation page #3385

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
41625de
hide default header in donate page
MohammadPCh Oct 24, 2023
a22e8ca
add DonateHeader
MohammadPCh Oct 24, 2023
ccbbce9
add DonateHeader to DonateIndex
MohammadPCh Oct 24, 2023
ff55217
add useShowHiderByScroll hook
MohammadPCh Oct 24, 2023
1f29c45
use useShowHiderByScroll in header
MohammadPCh Oct 24, 2023
297b9fd
use useShowHiderByScroll in DonateHeader
MohammadPCh Oct 24, 2023
a2b82cd
update container
MohammadPCh Oct 24, 2023
1cd2903
init DonationCard
MohammadPCh Oct 24, 2023
a527911
use DonationCard
MohammadPCh Oct 24, 2023
1819405
add tabs
MohammadPCh Oct 24, 2023
0e9b96b
add EmptyTab
MohammadPCh Oct 24, 2023
b57c04c
init RecurringDonationCard
MohammadPCh Oct 24, 2023
906e9ed
add RecurringDonationCard to DonationCard
MohammadPCh Oct 24, 2023
fb1203a
fix desc style
MohammadPCh Oct 24, 2023
9cf37ad
init RecurringSection
MohammadPCh Oct 24, 2023
712a052
disable eruda
MohammadPCh Oct 25, 2023
4156239
add InputWrapper
MohammadPCh Oct 26, 2023
413b718
udpate Input styles
MohammadPCh Oct 26, 2023
6147885
add Currency type
MohammadPCh Oct 26, 2023
a184206
add SUPER_FLUID_TOKENS to OptimismNetworkConfig
MohammadPCh Oct 26, 2023
3c02033
add production tokens
MohammadPCh Oct 26, 2023
bfcd24a
init development tokens
MohammadPCh Oct 26, 2023
b276cac
init SelectTokenModal
MohammadPCh Oct 26, 2023
c6595ea
add SelectTokenModal to RecurringDonationCard
MohammadPCh Oct 26, 2023
418abd7
update currencies name
MohammadPCh Oct 26, 2023
46f55af
change currency to token
MohammadPCh Oct 26, 2023
117683d
init token info
MohammadPCh Oct 26, 2023
96dbfbd
move SelectTokenModal
MohammadPCh Oct 26, 2023
75471f1
separate token icon
MohammadPCh Oct 26, 2023
f7889c3
support size in TokenIcon
MohammadPCh Oct 26, 2023
bcf3306
update token info styles
MohammadPCh Oct 26, 2023
69e3e1f
fix SelectTokenModal width
MohammadPCh Oct 26, 2023
458d521
add carret icon
MohammadPCh Oct 26, 2023
b1c18c1
make token selectable
MohammadPCh Oct 26, 2023
9fac0c0
add state to TokenInfo
MohammadPCh Oct 26, 2023
01c1bc3
add fetchBalance
MohammadPCh Oct 26, 2023
e437bfb
show real balance
MohammadPCh Oct 26, 2023
ba32e3c
format balances
MohammadPCh Oct 26, 2023
24b1802
update SUPER_FLUID_TOKENS type
MohammadPCh Oct 26, 2023
5f0cafd
remove ETH address
MohammadPCh Oct 26, 2023
19d66db
use useBalance hook to fetch user balance
MohammadPCh Oct 26, 2023
7568205
change selected token type
MohammadPCh Oct 26, 2023
1527a2c
add disable state
MohammadPCh Oct 26, 2023
b6c4776
show available amount
MohammadPCh Oct 26, 2023
a4f4902
add refetch functionality
MohammadPCh Oct 29, 2023
87d1c95
Merge branch 'develop' into add-recurring-to-donation-page
MohammadPCh Oct 29, 2023
5f3fb97
add eth to SUPER_FLUID_TOKENS
MohammadPCh Oct 30, 2023
7d7d471
change cursor on refresh icon
MohammadPCh Oct 30, 2023
2035d4a
yarn add @superfluid-finance/sdk-core
MohammadPCh Oct 30, 2023
830e769
add ISuperToken
MohammadPCh Nov 4, 2023
5fd6a1d
update development super tokens
MohammadPCh Nov 4, 2023
753edcc
update production super tokens
MohammadPCh Nov 4, 2023
b73253d
add superFluidSubgraph
MohammadPCh Nov 4, 2023
db1754f
add superFluidSubgraph dev
MohammadPCh Nov 4, 2023
ba2f118
add superFluidSubgraph prod
MohammadPCh Nov 4, 2023
4252c66
add FETCH_USER_STREAMS
MohammadPCh Nov 4, 2023
103a3a1
fetch user stream
MohammadPCh Nov 4, 2023
16da63c
init ISuperfluidStream interface
MohammadPCh Nov 6, 2023
beb594d
show super tokens
MohammadPCh Nov 6, 2023
afc9732
remove chain native currency
MohammadPCh Nov 6, 2023
5eb76ce
handle native currency in fetchBalance
MohammadPCh Nov 6, 2023
2276427
add eth address
MohammadPCh Nov 6, 2023
ecbd28d
handle undefined data
MohammadPCh Nov 6, 2023
7da0d40
fetch all balances together
MohammadPCh Nov 6, 2023
eb5b5b3
show balance in TokenInfo
MohammadPCh Nov 6, 2023
569bcba
pass balances
MohammadPCh Nov 6, 2023
e4a42f6
add isSuperToken
MohammadPCh Nov 6, 2023
eac7d36
handle super tokens in Token Icon
MohammadPCh Nov 6, 2023
ae18a90
handle super tokens icon
MohammadPCh Nov 6, 2023
8235fa3
update types
MohammadPCh Nov 6, 2023
aa7dd1e
add token to FETCH_USER_STREAMS
MohammadPCh Nov 6, 2023
5b9962d
separate superfluid types
MohammadPCh Nov 6, 2023
4436b1d
categorize streams by token
MohammadPCh Nov 6, 2023
209c685
change address to id in token
MohammadPCh Nov 6, 2023
6fab16a
add tokenStreams
MohammadPCh Nov 6, 2023
3bbdc64
hide tokens with stream
MohammadPCh Nov 6, 2023
85b7017
fix disable condition
MohammadPCh Nov 6, 2023
630ff0b
init StreamInfo
MohammadPCh Nov 6, 2023
a25a19a
fix styles
MohammadPCh Nov 23, 2023
e19feb8
update tokenInfo balance style
MohammadPCh Nov 23, 2023
c1fffab
add givback row
MohammadPCh Nov 23, 2023
172e5c8
update ui-design-system
MohammadPCh Nov 23, 2023
76f227e
show givback badge
MohammadPCh Nov 23, 2023
da8ba48
add Eligible Tokens title
MohammadPCh Nov 23, 2023
b7415be
update stream info
MohammadPCh Nov 23, 2023
8843ae8
show streams info
MohammadPCh Nov 23, 2023
2caa446
update StreamInfo data
MohammadPCh Nov 23, 2023
5e1b347
update StreamInfo styles
MohammadPCh Nov 23, 2023
fd59804
fix selected stream icon
MohammadPCh Nov 23, 2023
5c8d70b
limitFraction
MohammadPCh Nov 23, 2023
de7f922
add currentFlowRate
MohammadPCh Nov 23, 2023
db52a44
show end date
MohammadPCh Nov 23, 2023
0254694
show run out month
MohammadPCh Nov 26, 2023
ed4e63c
add Funding projects count
MohammadPCh Nov 26, 2023
23ea044
update tokenInfo styles
MohammadPCh Nov 26, 2023
9b39e0c
increase number of fractions
MohammadPCh Nov 26, 2023
09da3af
add superfluid sdk
MohammadPCh Nov 26, 2023
6ca1b26
decrease the ethers version
MohammadPCh Nov 27, 2023
d0512fc
add ethers helper
MohammadPCh Nov 27, 2023
c597486
init sf
MohammadPCh Nov 27, 2023
e455b2e
add getEthersSigner
MohammadPCh Nov 27, 2023
9c559ba
fix address
MohammadPCh Nov 27, 2023
02fd28e
update onDonate
MohammadPCh Nov 27, 2023
f7f6fe2
init onDonateEth and onDonate
MohammadPCh Nov 27, 2023
e0ca388
Merge branch 'superfluid-develop-branch' into add-recurring-to-donati…
MohammadPCh Nov 28, 2023
02fb1ca
remove handle modals
MohammadPCh Nov 28, 2023
700da8f
fix address imports
MohammadPCh Nov 28, 2023
f550f12
fix other address imports
MohammadPCh Nov 28, 2023
c74530d
fix connect button
MohammadPCh Nov 28, 2023
dbd132f
remove handle modal
MohammadPCh Nov 28, 2023
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
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@
},
"dependencies": {
"@apollo/client": "^3.8.3",
"@giveth/ui-design-system": "^1.11.17",
"@giveth/ui-design-system": "^1.11.18",
"@reduxjs/toolkit": "^1.9.5",
"@segment/snippet": "^4.15.3",
"@sentry/nextjs": "^7.69.0",
"@superfluid-finance/sdk-core": "^0.6.12",
"@uniswap/v3-sdk": "^3.10.0",
"@web3modal/wagmi": "^3.1.0",
"apollo-upload-client": "^17.0.0",
"bignumber.js": "^9.1.2",
"deepmerge": "^4.2.2",
"ethers": "^6.7.1",
"ethers": "5.7.2",
"framer-motion": "^10.12.12",
"graphql": "^16.8.0",
"graphql": "^16.8.1",
"lodash.isequal": "^4.5.0",
"lottie-react": "^2.3.1",
"next": "^13.5.1",
Expand Down
4 changes: 2 additions & 2 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
}
};
asyncFunc();
}, []);

Check warning on line 172 in pages/_app.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useEffect has missing dependencies: 'asPath', 'pathname', 'query', and 'router'. Either include them or remove the dependency array

return (
<>
Expand Down Expand Up @@ -219,7 +219,7 @@
}}
/>
)}
{process.env.NEXT_PUBLIC_ENV !==
{/* {process.env.NEXT_PUBLIC_ENV !==
'production' && (
<Script
id='console-script'
Expand All @@ -228,7 +228,7 @@
__html: `javascript:(function () { var script = document.createElement('script'); script.src="https://cdn.jsdelivr.net/npm/eruda"; document.body.append(script); script.onload = function () { eruda.init(); } })();`,
}}
/>
)}
)} */}

<FooterWrapper />
<ModalController />
Expand Down
31 changes: 31 additions & 0 deletions src/apollo/gql/gqlUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,37 @@ export const VALIDATE_TOKEN = gql`
}
`;

export const FETCH_USER_STREAMS = `
query FetchUserStreams($address: String!) {
streams(
where: { sender: $address }
) {
id
sender {
id
}
receiver {
id
}
token {
__typename
id
name
symbol
decimals
isSuperToken
underlyingToken {
id
name
symbol
decimals
}
}
currentFlowRate
}
}
`;

export const FETCH_USER_GIVPOWER_BY_ADDRESS = `
query unipoolBalance($id: String!) {
unipoolBalance(
Expand Down
3 changes: 1 addition & 2 deletions src/components/AddTokenButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { brandColors, P } from '@giveth/ui-design-system';
import Image from 'next/image';
import { FC, useState, useEffect } from 'react';
import styled from 'styled-components';
import { useAccount } from 'wagmi';
import { type Address, useAccount } from 'wagmi';
import { Flex } from './styled-components/Flex';
import { Address } from '@/types/config';
import { addToken } from '@/lib/metamask';

interface IAddGIVTokenButton {
Expand Down
33 changes: 2 additions & 31 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ import { isGIVeconomyRoute as checkIsGIVeconomyRoute } from '@/lib/helpers';
import { CommunityMenu } from '../menu/CommunityMenu';
import { useNavigationInfo } from '@/hooks/useNavigationInfo';
import config from '@/configuration';
import { useShowHiderByScroll } from '@/hooks/useShowHiderByScroll';

export interface IHeader {
theme?: ETheme;
show?: boolean;
}

const Header: FC<IHeader> = () => {
const [showHeader, setShowHeader] = useState(true);
const [showBackBtn, setShowBackBtn] = useState(false);

const [showSidebar, sidebarCondition, openSidebar, closeSidebar] =
Expand All @@ -87,6 +87,7 @@ const Header: FC<IHeader> = () => {
const isDesktop = useMediaQuery(device.laptopL);
const isMobile = useMediaQuery(device.mobileL);
const { open: openConnectModal } = useWeb3Modal();
const showHeader = useShowHiderByScroll();

const isGIVeconomyRoute = checkIsGIVeconomyRoute(router.route);

Expand Down Expand Up @@ -128,36 +129,6 @@ const Header: FC<IHeader> = () => {
);
}, [router.route]);

useEffect(() => {
const threshold = 0;
let lastScrollY = window.pageYOffset;
let ticking = false;

const updateScrollDir = () => {
const scrollY = window.pageYOffset;

if (Math.abs(scrollY - lastScrollY) < threshold) {
ticking = false;
return;
}
const show = scrollY <= lastScrollY;
setShowHeader(show);
lastScrollY = scrollY > 0 ? scrollY : 0;
ticking = false;
};

const onScroll = () => {
if (!ticking) {
window.requestAnimationFrame(updateScrollDir);
ticking = true;
}
};

window.addEventListener('scroll', onScroll);

return () => window.removeEventListener('scroll', onScroll);
}, [showHeader]);

const { modalCallback: signInThenCreate } = useModalCallback(() =>
router.push(Routes.CreateProject),
);
Expand Down
3 changes: 1 addition & 2 deletions src/components/modals/ConfirmSubmit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import {
} from '@giveth/ui-design-system';
import styled from 'styled-components';
import { FC } from 'react';
import { useNetwork } from 'wagmi';
import { type Address, useNetwork } from 'wagmi';
import config from '@/configuration';
import TikAnimation from '@/animations/tik.json';
import ErrorAnimation from '@/animations/error.json';
import { AddTokenButton } from '../AddTokenButton';
import { Flex } from '../styled-components/Flex';
import LottieControl from '@/components/LottieControl';
import { WrappedSpinner } from '../Spinner';
import { Address } from '@/types/config';

const AddTokenRow = styled(Flex)`
margin-top: 16px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import styled from 'styled-components';
import { useForm } from 'react-hook-form';
import { Dispatch, FC, SetStateAction, useState } from 'react';
import { getAddress, isAddress } from 'viem';
import { type Address } from 'wagmi';
import { IProject, IWalletAddress } from '@/apollo/types/types';
import Input from '../../Input';
import { requiredOptions } from '@/lib/constants/regex';
import { client } from '@/apollo/apolloClient';
import { ADD_RECIPIENT_ADDRESS_TO_PROJECT } from '@/apollo/gql/gqlProjects';
import InlineToast, { EToastType } from '../../toasts/InlineToast';
import { suggestNewAddress } from '@/lib/helpers';
import { Address } from '@/types/config';
import { chainNameById } from '@/lib/network';

interface IAddNewAddress {
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/create/CreateProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { captureException } from '@sentry/nextjs';
import { FormProvider, useForm } from 'react-hook-form';
import { Container } from '@giveth/ui-design-system';
import { getAddress } from 'viem';
import { type Address } from 'wagmi';
import {
ACTIVATE_PROJECT,
CREATE_PROJECT,
Expand Down Expand Up @@ -47,7 +48,6 @@ import { useAppDispatch } from '@/features/hooks';
import NameInput from '@/components/views/create/NameInput';
import CreateProjectAddAddressModal from './CreateProjectAddAddressModal';
import AddressInterface from './AddressInterface';
import { Address } from '@/types/config';
import { ProjectGuidelineModal } from '@/components/modals/ProjectGuidelineModal';
import StorageLabel from '@/lib/localStorage';

Expand Down
86 changes: 86 additions & 0 deletions src/components/views/donate/DonateHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import Image from 'next/image';
import { FC } from 'react';
import { useRouter } from 'next/router';
import { useIntl } from 'react-intl';
import { useAccount, useNetwork } from 'wagmi';
import { useWeb3Modal } from '@web3modal/wagmi/react';
import Link from 'next/link';
import { Caption, B, neutralColors } from '@giveth/ui-design-system';
import styled from 'styled-components';
import { Flex, FlexSpacer } from '@/components/styled-components/Flex';
import { useAppSelector } from '@/features/hooks';
import { ETheme } from '@/features/general/general.slice';

import { isGIVeconomyRoute as checkIsGIVeconomyRoute } from '@/lib/helpers';
import {
StyledHeader,
Logo,
ConnectButton,
} from '@/components/Header/Header.sc';
import { UserButtonWithMenu } from '@/components/menu/UserButtonWithMenu';
import Routes from '@/lib/constants/Routes';
import { useDonateData } from '@/context/donate.context';
import { useShowHiderByScroll } from '@/hooks/useShowHiderByScroll';

export interface IHeader {
theme?: ETheme;
show?: boolean;
}

export const DonateHeader: FC<IHeader> = () => {
const theme = useAppSelector(state => state.general.theme);
const { formatMessage } = useIntl();
const { address } = useAccount();
const { chain } = useNetwork();
const router = useRouter();
const { open: openConnectModal } = useWeb3Modal();
const { project } = useDonateData();
const showHeader = useShowHiderByScroll();
const chainId = chain?.id;
const isGIVeconomyRoute = checkIsGIVeconomyRoute(router.route);

return (
<StyledHeader alignItems='center' theme={theme} show={showHeader}>
<Flex alignItems='center' gap='16px'>
<Link href={Routes.Project + '/' + project.slug}>
<Logo>
<Image
width='26'
height='26'
alt='Giveth logo'
src={`/images/back-2.svg`}
/>
</Logo>
</Link>
<Flex flexDirection='column' gap='4px'>
<StyledCaption medium>Donating to</StyledCaption>
<B>{project.title}</B>
</Flex>
</Flex>
<FlexSpacer />
<Flex gap='8px'>
{address && chainId ? (
<UserButtonWithMenu
isHeaderShowing={showHeader}
theme={theme}
/>
) : (
<ConnectButton
buttonType='primary'
size='small'
label={formatMessage({
id: isGIVeconomyRoute
? 'component.button.connect_wallet'
: 'component.button.sign_in',
})}
onClick={() => openConnectModal?.()}
/>
)}
</Flex>
</StyledHeader>
);
};

const StyledCaption = styled(Caption)`
color: ${neutralColors.gray[700]};
`;
Loading
Loading