Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6004194
fix: Prevent Uniswap widget crashes on 100% price impact trades
supersonicwisd1 Jul 14, 2025
ad8846f
updated patch_reference.md
supersonicwisd1 Jul 14, 2025
3e16bb0
separate concerns
supersonicwisd1 Jul 14, 2025
f39e512
Revert "updated patch_reference.md"
supersonicwisd1 Jul 15, 2025
9b2be7e
Add clean uniswap patch for 100% price impact fix
supersonicwisd1 Aug 4, 2025
2c71b08
Add clean uniswap patch for price impact fix
supersonicwisd1 Aug 4, 2025
27225ef
fix: handle uniswap widget error
supersonicwisd1 Aug 5, 2025
c2d859b
Update gitignore
supersonicwisd1 Aug 5, 2025
4eb0910
updated gitignore file
supersonicwisd1 Aug 5, 2025
54c30ed
updates suggest by yhy the reviewer
supersonicwisd1 Aug 5, 2025
655c4c5
Update .gitignore
supersonicwisd1 Aug 6, 2025
d75cfa5
Merge branch 'GoodDollar:master' into master
supersonicwisd1 Sep 8, 2025
90e423a
feat: implement Buy G$ page with progress bar and Onramper widget
supersonicwisd1 Sep 13, 2025
0edd742
remove: removed fallback on posthog
supersonicwisd1 Sep 13, 2025
aa1dfac
chore: update localization catalogs
supersonicwisd1 Sep 13, 2025
42994ce
rm: Updated gitignore file
supersonicwisd1 Sep 15, 2025
16768e3
fix: fixing critical bugs and standards
supersonicwisd1 Sep 15, 2025
4b4fd71
rm: remove falback for posthog
supersonicwisd1 Sep 15, 2025
2d9cfb6
fix: feedback fix on security, performance, functionality and design
supersonicwisd1 Sep 15, 2025
2410d7d
fix: security and functionality fix
supersonicwisd1 Sep 17, 2025
c33295d
fix: address all Korbit AI review feedback for Buy G$ feature
supersonicwisd1 Oct 16, 2025
e96a55f
fix: connect widget events to progress bar and fix swap lock bug
supersonicwisd1 Oct 29, 2025
41e4994
Merge branch 'master' of https://github.com/GoodDollar/GoodProtocolUI…
L03TJ3 Dec 18, 2025
6c842be
Update src/components/CustomGdOnramperWidget/CustomOnramper.tsx
L03TJ3 Dec 18, 2025
2074013
fix: show wallet connection placeholder on Buy G$ page
supersonicwisd1 Dec 19, 2025
9431ac8
Merge branch 'feat/buy-gd' of github.com:supersonicwisd1/GoodProtocol…
supersonicwisd1 Dec 19, 2025
87d5232
fix: update BuyGD to use new wallet connection system
supersonicwisd1 Dec 19, 2025
7363f3e
refactor: use GdOnramperWidget from good-design package
supersonicwisd1 Jan 14, 2026
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
203 changes: 203 additions & 0 deletions src/components/BuyProgressBar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
import React, { useEffect, useState, useMemo } from 'react'
import { Box, HStack, Circle, Text } from 'native-base'

export type BuyStep = 1 | 2 | 3

export interface StepConfig {
number: number
label: string
}

interface BuyProgressBarProps {
currentStep: BuyStep
isLoading?: boolean
steps?: StepConfig[]
}

const BuyProgressBar: React.FC<BuyProgressBarProps> = ({
currentStep,
isLoading = false,
steps = [
{ number: 1, label: 'Buy cUSD' },
{ number: 2, label: 'We swap cUSD to G$' },
{ number: 3, label: 'Done' },
],
}) => {
const [animatedWidth, setAnimatedWidth] = useState(0)

// Handle animated progress line
useEffect(() => {
if (isLoading && currentStep >= 1) {
// Explicitly reset animatedWidth to 0 at the start of a new loading phase
setAnimatedWidth(0)
// Animate progress line when loading
let progress = 0
const interval = setInterval(() => {
progress += 2
if (progress <= 100) {
setAnimatedWidth(progress)
} else {
clearInterval(interval)
}
}, 50) // 50ms intervals for smooth animation

return () => clearInterval(interval)
} else {
// Set to 100% if not loading (completed state)
setAnimatedWidth(100)
}
}, [isLoading, currentStep])

const getStepStatus = (stepNumber: number) => {
// Step 1 should ALWAYS be blue (active when current, completed when past)
if (stepNumber === 1) {
if (currentStep === 1) {
return isLoading ? 'loading' : 'active'
} else {
return 'completed' // Step 1 is completed when we're on step 2 or 3
}
}
// Steps 2 and 3 follow normal logic
if (stepNumber < currentStep) return 'completed'
if (stepNumber === currentStep) return isLoading ? 'loading' : 'active'
return 'pending'
}

// Memoize circle props objects to avoid recreation on every render
const circlePropsMap = useMemo(
() => ({
completed: {
size: '12',
mb: 2,
justifyContent: 'center',
alignItems: 'center',
bg: 'blue.500',
},
active: {
size: '12',
mb: 2,
justifyContent: 'center',
alignItems: 'center',
bg: 'blue.500',
},
loading: {
size: '12',
mb: 2,
justifyContent: 'center',
alignItems: 'center',
bg: 'blue.500',
borderWidth: 3,
borderColor: 'blue.200',
animation: 'pulse 2s infinite',
},
pending: {
size: '12',
mb: 2,
justifyContent: 'center',
alignItems: 'center',
bg: 'gray.300',
},
}),
[]
)

const getCircleProps = (status: string) => {
return circlePropsMap[status as keyof typeof circlePropsMap] || circlePropsMap.pending
}

const getLineProps = (stepNumber: number, lineIndex: number) => {
// Line between step 1 and 2 (lineIndex = 0)
if (lineIndex === 0) {
if (currentStep === 1 && isLoading) {
// Animation state: "1 Blue with progress bar animation"
return {
bg: 'blue.500',
width: `${animatedWidth}%`,
transition: 'width 0.1s ease-out',
}
} else if (currentStep >= 2) {
// Static line when step 2 or higher
return {
bg: 'blue.500',
width: '100%',
}
}
}

// Line between step 2 and 3 (lineIndex = 1)
if (lineIndex === 1) {
if (currentStep === 2 && isLoading) {
// Animation state: "2 Blue with progress bar animation"
return {
bg: 'blue.500',
width: `${animatedWidth}%`,
transition: 'width 0.1s ease-out',
}
} else if (currentStep >= 3) {
// Static line when step 3
return {
bg: 'blue.500',
width: '100%',
}
}
}

// Default: gray line (not active)
return {
bg: 'gray.300',
width: '100%',
}
}

const getTextColor = (status: string) => {
return status === 'pending' ? 'gray.500' : 'black'
}

return (
<Box width="100%" mb={6} mt={4} data-testid="custom-progress-bar">
<HStack justifyContent="space-between" alignItems="flex-start" position="relative">
{steps.map((step, index) => {
const status = getStepStatus(step.number)

return (
<React.Fragment key={step.number}>
<Box alignItems="center" flex={1} position="relative">
<Circle {...getCircleProps(status)}>
<Text color="white" fontWeight="bold" fontSize="md">
{step.number}
</Text>
</Circle>
<Text
textAlign="center"
fontSize="sm"
color={getTextColor(status)}
fontFamily="subheading"
maxWidth="120px"
lineHeight="tight"
>
{step.label}
</Text>
</Box>

{index < steps.length - 1 && (
<Box
position="absolute"
top="6"
left={`${33.33 * (index + 1) - 16.67}%`}
right={`${66.67 - 33.33 * (index + 1) + 16.67}%`}
height="2px"
bg="gray.300"
zIndex={-1}
>
<Box height="100%" {...getLineProps(step.number + 1, index)} borderRadius="1px" />
</Box>
)}
</React.Fragment>
)
})}
</HStack>
</Box>
)
}

export { BuyProgressBar }
10 changes: 7 additions & 3 deletions src/language/locales/af/catalog.po
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,7 @@ msgstr ""
msgid "Change"
msgstr "Verander"

#: src/pages/gd/BuyGD/index.tsx:84
#: src/pages/gd/BuyGD/index.tsx:83
msgid "Choose the currency you want to use and buy cUSD. Your cUSD is then automatically converted into G$."
msgstr ""

Expand Down Expand Up @@ -2883,6 +2883,10 @@ msgstr "Bevestig hierdie transaksie in jou beursie"
msgid "Congratulations!"
msgstr ""

#: src/pages/gd/BuyGD/index.tsx:90
msgid "Connect a wallet to buy G$"
msgstr ""

#: src/pages/gd/MicroBridge/index.tsx:36
#: src/pages/gd/Portfolio/index.tsx:459
msgid "Connect a wallet to see your portfolio"
Expand Down Expand Up @@ -3165,7 +3169,7 @@ msgstr "op die"
#~ "Please be patient, loading information in the Swap widget may take some time. Thanks for waiting!"
#~ msgstr ""

#: src/components/Web3ReactManager/index.tsx:86
#: src/components/Web3ReactManager/index.tsx:84
msgid "Oops! An unknown error occurred. Please refresh the page, or visit from another browser or device"
msgstr "Oeps! 'n Onbekende fout het voorgekom. Verfris asseblief die bladsy, of besoek vanaf 'n ander blaaier of toestel"

Expand Down Expand Up @@ -3320,7 +3324,7 @@ msgstr ""
msgid "Success!"
msgstr "Sukses!"

#: src/pages/gd/BuyGD/index.tsx:71
#: src/pages/gd/BuyGD/index.tsx:70
msgid "Support global financial inclusion and contribute to social impact by purchasing GoodDollars (G$)."
msgstr ""

Expand Down
10 changes: 7 additions & 3 deletions src/language/locales/ar/catalog.po
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,7 @@ msgstr ""
msgid "Change"
msgstr "تغيير"

#: src/pages/gd/BuyGD/index.tsx:84
#: src/pages/gd/BuyGD/index.tsx:83
msgid "Choose the currency you want to use and buy cUSD. Your cUSD is then automatically converted into G$."
msgstr ""

Expand Down Expand Up @@ -2883,6 +2883,10 @@ msgstr "قم بتأكيد هذه المعاملة في محفظتك"
msgid "Congratulations!"
msgstr ""

#: src/pages/gd/BuyGD/index.tsx:90
msgid "Connect a wallet to buy G$"
msgstr ""

#: src/pages/gd/MicroBridge/index.tsx:36
#: src/pages/gd/Portfolio/index.tsx:459
msgid "Connect a wallet to see your portfolio"
Expand Down Expand Up @@ -3165,7 +3169,7 @@ msgstr "على"
#~ "Please be patient, loading information in the Swap widget may take some time. Thanks for waiting!"
#~ msgstr ""

#: src/components/Web3ReactManager/index.tsx:86
#: src/components/Web3ReactManager/index.tsx:84
msgid "Oops! An unknown error occurred. Please refresh the page, or visit from another browser or device"
msgstr "عفوًا! حدث خطأ غير معروف. يرجى تحديث الصفحة، أو الزيارة من متصفح أو جهاز آخر"

Expand Down Expand Up @@ -3320,7 +3324,7 @@ msgstr ""
msgid "Success!"
msgstr "النجاح!"

#: src/pages/gd/BuyGD/index.tsx:71
#: src/pages/gd/BuyGD/index.tsx:70
msgid "Support global financial inclusion and contribute to social impact by purchasing GoodDollars (G$)."
msgstr ""

Expand Down
10 changes: 7 additions & 3 deletions src/language/locales/ca/catalog.po
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,7 @@ msgstr ""
msgid "Change"
msgstr ""

#: src/pages/gd/BuyGD/index.tsx:84
#: src/pages/gd/BuyGD/index.tsx:83
msgid "Choose the currency you want to use and buy cUSD. Your cUSD is then automatically converted into G$."
msgstr ""

Expand Down Expand Up @@ -2883,6 +2883,10 @@ msgstr ""
msgid "Congratulations!"
msgstr ""

#: src/pages/gd/BuyGD/index.tsx:90
msgid "Connect a wallet to buy G$"
msgstr ""

#: src/pages/gd/MicroBridge/index.tsx:36
#: src/pages/gd/Portfolio/index.tsx:459
msgid "Connect a wallet to see your portfolio"
Expand Down Expand Up @@ -3165,7 +3169,7 @@ msgstr ""
#~ "Please be patient, loading information in the Swap widget may take some time. Thanks for waiting!"
#~ msgstr ""

#: src/components/Web3ReactManager/index.tsx:86
#: src/components/Web3ReactManager/index.tsx:84
msgid "Oops! An unknown error occurred. Please refresh the page, or visit from another browser or device"
msgstr ""

Expand Down Expand Up @@ -3320,7 +3324,7 @@ msgstr ""
msgid "Success!"
msgstr ""

#: src/pages/gd/BuyGD/index.tsx:71
#: src/pages/gd/BuyGD/index.tsx:70
msgid "Support global financial inclusion and contribute to social impact by purchasing GoodDollars (G$)."
msgstr ""

Expand Down
10 changes: 7 additions & 3 deletions src/language/locales/cs/catalog.po
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,7 @@ msgstr ""
msgid "Change"
msgstr ""

#: src/pages/gd/BuyGD/index.tsx:84
#: src/pages/gd/BuyGD/index.tsx:83
msgid "Choose the currency you want to use and buy cUSD. Your cUSD is then automatically converted into G$."
msgstr ""

Expand Down Expand Up @@ -2883,6 +2883,10 @@ msgstr ""
msgid "Congratulations!"
msgstr ""

#: src/pages/gd/BuyGD/index.tsx:90
msgid "Connect a wallet to buy G$"
msgstr ""

#: src/pages/gd/MicroBridge/index.tsx:36
#: src/pages/gd/Portfolio/index.tsx:459
msgid "Connect a wallet to see your portfolio"
Expand Down Expand Up @@ -3165,7 +3169,7 @@ msgstr ""
#~ "Please be patient, loading information in the Swap widget may take some time. Thanks for waiting!"
#~ msgstr ""

#: src/components/Web3ReactManager/index.tsx:86
#: src/components/Web3ReactManager/index.tsx:84
msgid "Oops! An unknown error occurred. Please refresh the page, or visit from another browser or device"
msgstr ""

Expand Down Expand Up @@ -3320,7 +3324,7 @@ msgstr ""
msgid "Success!"
msgstr ""

#: src/pages/gd/BuyGD/index.tsx:71
#: src/pages/gd/BuyGD/index.tsx:70
msgid "Support global financial inclusion and contribute to social impact by purchasing GoodDollars (G$)."
msgstr ""

Expand Down
10 changes: 7 additions & 3 deletions src/language/locales/da/catalog.po
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,7 @@ msgstr ""
msgid "Change"
msgstr ""

#: src/pages/gd/BuyGD/index.tsx:84
#: src/pages/gd/BuyGD/index.tsx:83
msgid "Choose the currency you want to use and buy cUSD. Your cUSD is then automatically converted into G$."
msgstr ""

Expand Down Expand Up @@ -2883,6 +2883,10 @@ msgstr ""
msgid "Congratulations!"
msgstr ""

#: src/pages/gd/BuyGD/index.tsx:90
msgid "Connect a wallet to buy G$"
msgstr ""

#: src/pages/gd/MicroBridge/index.tsx:36
#: src/pages/gd/Portfolio/index.tsx:459
msgid "Connect a wallet to see your portfolio"
Expand Down Expand Up @@ -3165,7 +3169,7 @@ msgstr ""
#~ "Please be patient, loading information in the Swap widget may take some time. Thanks for waiting!"
#~ msgstr ""

#: src/components/Web3ReactManager/index.tsx:86
#: src/components/Web3ReactManager/index.tsx:84
msgid "Oops! An unknown error occurred. Please refresh the page, or visit from another browser or device"
msgstr ""

Expand Down Expand Up @@ -3320,7 +3324,7 @@ msgstr ""
msgid "Success!"
msgstr ""

#: src/pages/gd/BuyGD/index.tsx:71
#: src/pages/gd/BuyGD/index.tsx:70
msgid "Support global financial inclusion and contribute to social impact by purchasing GoodDollars (G$)."
msgstr ""

Expand Down
Loading