From a7698fe7615b5c0e2ae19d2eb141213d70e35bb6 Mon Sep 17 00:00:00 2001 From: kris Date: Tue, 12 Dec 2023 16:31:09 +0500 Subject: [PATCH 1/2] fixed CTA button size on DonationPage --- .../app/src/components/DonateComponent.tsx | 1 + packages/app/src/components/RoundedButton.tsx | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/app/src/components/DonateComponent.tsx b/packages/app/src/components/DonateComponent.tsx index 3e4b4862..7ae757de 100644 --- a/packages/app/src/components/DonateComponent.tsx +++ b/packages/app/src/components/DonateComponent.tsx @@ -387,6 +387,7 @@ function DonateComponent({ (false) -// const ButtonStyles = {}; - -function RoundedButton({ title, backgroundColor, color, fontSize, seeType, buttonLink, onPress }: RoundedButtonProps) { - // const { navigate } = useCrossNavigate(); +function RoundedButton({ title, backgroundColor, color, fontSize, seeType, onPress, isDesktop }: RoundedButtonProps) { if (!seeType) { return ( - + Date: Tue, 12 Dec 2023 17:45:56 +0500 Subject: [PATCH 2/2] fixed Breadcrumb on DonationPage --- packages/app/src/App.tsx | 3 - packages/app/src/components/Breadcrumb.tsx | 12 +-- .../app/src/components/DonateComponent.tsx | 42 +++++----- packages/app/src/components/EmptyProfile.tsx | 8 +- packages/app/src/components/Layout.tsx | 2 +- packages/app/src/components/RoundedButton.tsx | 6 +- .../app/src/components/ViewCollective.tsx | 4 - packages/app/src/components/WalletProfile.tsx | 2 +- packages/app/src/pages/DonatePage.tsx | 3 + packages/app/src/pages/ViewCollectivePage.tsx | 77 ++++++++++--------- packages/app/src/pages/ViewStewardsPage.tsx | 4 +- 11 files changed, 81 insertions(+), 82 deletions(-) diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index db3c72f2..4e55afcb 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -11,9 +11,6 @@ import * as MobileRoute from './routes/routing.native'; import * as WebRoute from './routes/routing.web'; import ActivityLogPage from './pages/ActivityLogPage'; -// import WalletProfilePageDonor from './pages/WalletProfilePageDonor'; -// import WalletProfilePageSteward from './pages/WalletProfilePageSteward'; -// import EmptyProfile from './components/EmptyProfile'; import { NativeBaseProvider } from 'native-base'; import CollectiveCardPage from './pages/CollectiveCardPage'; import DonatePage from './pages/DonatePage'; diff --git a/packages/app/src/components/Breadcrumb.tsx b/packages/app/src/components/Breadcrumb.tsx index a07a4532..323c2e43 100644 --- a/packages/app/src/components/Breadcrumb.tsx +++ b/packages/app/src/components/Breadcrumb.tsx @@ -4,25 +4,27 @@ import { Colors } from '../utils/colors'; import { useNavigate } from 'react-router-dom'; interface BreadcrumbProps { - currentPage?: string; + previousPage?: string; + currentPage: string; } -function Breadcrumb({ currentPage }: BreadcrumbProps) { +function Breadcrumb({ currentPage, previousPage }: BreadcrumbProps) { const navigate = useNavigate(); return ( navigate(-1)}> - GoodCollective Home - / {currentPage || 'title'} + {previousPage ?? 'GoodCollective Home'} + / {currentPage} ); } const styles = StyleSheet.create({ container: { + height: 24, alignItems: 'center', flexDirection: 'row', - marginBottom: 0, + marginBottom: 12, }, activePage: { color: Colors.purple[200] }, nextPage: { color: Colors.gray[200] }, diff --git a/packages/app/src/components/DonateComponent.tsx b/packages/app/src/components/DonateComponent.tsx index 7ae757de..1b43c033 100644 --- a/packages/app/src/components/DonateComponent.tsx +++ b/packages/app/src/components/DonateComponent.tsx @@ -42,6 +42,12 @@ const frequencyOptions = [ { value: 'Yearly', label: 'Yearly' }, ]; +const tokenMapping = { + CELO: '0x471EcE3750Da237f93B8E339c536989b8978a438', + cUSD: '0x765de816845861e75a25fca122bb6898b8b1282a', + WBTC: '0xD629eb00dEced2a080B7EC630eF6aC117e614f1b', +}; + function DonateComponent({ walletConected, insufficientLiquidity, @@ -60,32 +66,19 @@ function DonateComponent({ const { supportFlowWithSwap, supportFlow } = useContractCalls(); const { address } = useAccount(); - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const tokenMapping = { - CELO: '0x471EcE3750Da237f93B8E339c536989b8978a438', - cUSD: '0x765de816845861e75a25fca122bb6898b8b1282a', - WBTC: '0xD629eb00dEced2a080B7EC630eF6aC117e614f1b', - // Add other tokens here if needed - }; - useEffect(() => { - if (currency === 'WBTC') { - getPrice('0xD629eb00dEced2a080B7EC630eF6aC117e614f1b').then((res: any) => { - setUsdValue(res * amount); - }); - } - if (currency === 'cUSD') { - getPrice('0x765de816845861e75a25fca122bb6898b8b1282a').then((res: any) => { - setUsdValue(res * amount); - }); - } - if (currency === 'CELO') { - getPrice('0x471EcE3750Da237f93B8E339c536989b8978a438').then((res: any) => { - setUsdValue(res * amount); - }); - } if (currency === 'G$') { + // TODO: is the price of G$ fixed? setUsdValue(0.00018672442844237 * amount); + return; + } + for (const [token, tokenAddress] of Object.entries(tokenMapping)) { + if (currency === token) { + getPrice(tokenAddress).then((res: any) => { + setUsdValue(res * amount); + }); + break; + } } }, [amount, currency, getPrice, usdValue, setUsdValue]); @@ -387,7 +380,7 @@ function DonateComponent({ It looks empty here. {'\n'} Donate to build your impact profile! @@ -18,7 +18,7 @@ function EmptyProfile() { color={Colors.green[200]} fontSize={16} seeType={false} - buttonLink="/" + onPress={() => navigate('/')} /> ); diff --git a/packages/app/src/components/Layout.tsx b/packages/app/src/components/Layout.tsx index b41ffe1d..ad5761f2 100644 --- a/packages/app/src/components/Layout.tsx +++ b/packages/app/src/components/Layout.tsx @@ -55,7 +55,7 @@ const styles = StyleSheet.create({ }, desktopScrollView: { paddingHorizontal: 64, - paddingTop: 40, + paddingTop: 12, paddingBottom: 90, height: '100vh', overflowY: 'scroll', diff --git a/packages/app/src/components/RoundedButton.tsx b/packages/app/src/components/RoundedButton.tsx index a9a357c7..c70c9275 100644 --- a/packages/app/src/components/RoundedButton.tsx +++ b/packages/app/src/components/RoundedButton.tsx @@ -11,10 +11,10 @@ interface RoundedButtonProps { fontSize: number; seeType: boolean; onPress?: any; - isDesktop: boolean; + maxWidth?: number | string; } -function RoundedButton({ title, backgroundColor, color, fontSize, seeType, onPress, isDesktop }: RoundedButtonProps) { +function RoundedButton({ title, backgroundColor, color, fontSize, seeType, onPress, maxWidth }: RoundedButtonProps) { if (!seeType) { return ( diff --git a/packages/app/src/components/ViewCollective.tsx b/packages/app/src/components/ViewCollective.tsx index 2d75a2f3..31336abe 100644 --- a/packages/app/src/components/ViewCollective.tsx +++ b/packages/app/src/components/ViewCollective.tsx @@ -1,7 +1,6 @@ import { useCallback } from 'react'; import { StyleSheet, Text, View, Image } from 'react-native'; import { useState } from 'react'; -// import oceanUri from '../@constants/SafariImagePlaceholder'; import RowItem from './RowItem'; import RoundedButton from './RoundedButton'; import StewardList from './StewardsList'; @@ -16,9 +15,7 @@ import StopDonationModal from './StopDonationModal'; import ThankYouModal from './ThankYouModal'; import { Colors } from '../utils/colors'; import { Link, useMediaQuery } from 'native-base'; -import Breadcrumb from './Breadcrumb'; import { formatTime } from '../hooks/functions/formatTime'; -import { formatAmount } from '../hooks/functions/formatUsdAmount'; interface ViewCollectiveProps { imageUrl?: any; @@ -86,7 +83,6 @@ function ViewCollective({ return ( <> - diff --git a/packages/app/src/components/WalletProfile.tsx b/packages/app/src/components/WalletProfile.tsx index 67094c3f..a79d39e0 100644 --- a/packages/app/src/components/WalletProfile.tsx +++ b/packages/app/src/components/WalletProfile.tsx @@ -94,7 +94,7 @@ function WalletProfile({ if (isDesktopResolution) { return ( <> - + diff --git a/packages/app/src/pages/DonatePage.tsx b/packages/app/src/pages/DonatePage.tsx index f8ee6838..ac045a15 100644 --- a/packages/app/src/pages/DonatePage.tsx +++ b/packages/app/src/pages/DonatePage.tsx @@ -1,10 +1,13 @@ import Layout from '../components/Layout'; import DonateComponent from '../components/DonateComponent'; import React from 'react'; +import Breadcrumb from '../components/Breadcrumb'; function DonatePage() { + const collectiveId = window.location.pathname.slice('/donate/'.length); return ( + (); + const [collectiveData, setCollectiveData] = useState(undefined); const [isLoading, setIsLoading] = useState(true); + useEffect(() => { + console.log('Request: ' + JSON.stringify(request, null, 2)); if (!request || request.length === 0) { setIsLoading(false); // No requests, no loading return; } - const t: any = []; - Promise.all( - request.map((e: any) => { - return axios.get(`https://gateway.pinata.cloud/ipfs/${e.ipfs}`).then(async (res) => { - t.push({ - name: res.data?.name, - description: res.data?.description, - email: res.data?.email, - twitter: res.data?.twitter, - id: e.id, - time: e.timestamp, - contributions: e.contributions, - }); - }); + axios + .get(`https://gateway.pinata.cloud/ipfs/${request[0].ipfs}`) + .then((response) => ({ + name: response.data?.name, + description: response.data?.description, + email: response.data?.email, + twitter: response.data?.twitter, + id: request[0].id, + time: request[0].timestamp, + contributions: request[0]?.contributions, + })) + .then((data) => { + console.log(JSON.stringify(data, null, 2)); + setCollectiveData(data); + }) + .catch((error) => { + console.error(error); }) - ).then(() => { - setSubData(t); - setIsLoading(false); - }); + .finally(() => { + setIsLoading(false); + }); }, [request]); return ( + <> {isLoading ? (

Loading...

+ ) : !collectiveData ? ( + <> ) : ( - subData?.map((t: any, index: number) => ( - - )) + )}
diff --git a/packages/app/src/pages/ViewStewardsPage.tsx b/packages/app/src/pages/ViewStewardsPage.tsx index 2021b280..1cf5b2f8 100644 --- a/packages/app/src/pages/ViewStewardsPage.tsx +++ b/packages/app/src/pages/ViewStewardsPage.tsx @@ -15,10 +15,12 @@ function ViewStewardsPage() { minWidth: 612, }); + const collectiveId = '123'; + if (isDesktopResolution) { return ( - +