Skip to content

Commit 4ed1e0f

Browse files
authored
Merge pull request #987 from ensdomains/feature/fet-1795-moonpay-option-to-use-credit-or-debit-card-doesnt-always
fix moonpay option flickering preview
2 parents 2f78d77 + 6f066d2 commit 4ed1e0f

File tree

3 files changed

+35
-52
lines changed

3 files changed

+35
-52
lines changed

src/components/pages/profile/[name]/registration/steps/Pricing/Pricing.tsx

Lines changed: 34 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useBalance } from 'wagmi'
88
import { GetBalanceData } from 'wagmi/query'
99

1010
import {
11+
Box,
1112
Button,
1213
Field,
1314
Heading,
@@ -93,20 +94,6 @@ const gridAreaStyle = ({ $name }: { $name: string }) => css`
9394

9495
const moonpayInfoItems = Array.from({ length: 2 }, (_, i) => `steps.info.moonpayItems.${i}`)
9596

96-
const PaymentChoiceContainer = styled.div`
97-
width: 100%;
98-
`
99-
100-
const StyledRadioButtonGroup = styled(RadioButtonGroup)(
101-
({ theme }) => css`
102-
border: 1px solid ${theme.colors.border};
103-
border-radius: ${theme.radii.large};
104-
gap: 0;
105-
`,
106-
)
107-
108-
const StyledRadioButton = styled(RadioButton)``
109-
11097
const RadioButtonContainer = styled.div(
11198
({ theme }) => css`
11299
padding: ${theme.space['4']};
@@ -134,21 +121,6 @@ const MoonpayContainer = styled.div`
134121
gap: 5px;
135122
`
136123

137-
const InfoItems = styled.div(
138-
({ theme }) => css`
139-
display: flex;
140-
flex-direction: column;
141-
align-items: center;
142-
justify-content: flex-start;
143-
gap: ${theme.space['4']};
144-
145-
@media (min-width: ${theme.breakpoints.sm}px) {
146-
flex-direction: row;
147-
align-items: stretch;
148-
}
149-
`,
150-
)
151-
152124
const InfoItem = styled.div(
153125
({ theme }) => css`
154126
width: 100%;
@@ -186,11 +158,6 @@ const InfoItem = styled.div(
186158
`,
187159
)
188160

189-
const LabelContainer = styled.div`
190-
display: flex;
191-
flex-wrap: wrap;
192-
`
193-
194161
const CheckboxWrapper = styled.div(
195162
() => css`
196163
width: 100%;
@@ -278,24 +245,31 @@ const PaymentChoice = ({
278245
}) => {
279246
const { t } = useTranslation('register')
280247

248+
console.log({ paymentMethodChoice })
249+
281250
return (
282-
<PaymentChoiceContainer>
251+
<Box width="full">
283252
<StyledTitle color="grey" weight="bold">
284253
{t('steps.info.paymentMethod')}
285254
</StyledTitle>
286255
<Spacer $height="2" />
287-
<StyledRadioButtonGroup
256+
<RadioButtonGroup
257+
borderWidth="1x"
258+
borderColor="border"
259+
borderStyle="solid"
260+
borderRadius="large"
261+
gap="0"
288262
value={paymentMethodChoice}
289-
onChange={(e) => setPaymentMethodChoice(e.target.value as PaymentMethod)}
290263
>
291264
<RadioButtonContainer>
292-
<StyledRadioButton
265+
<RadioButton
293266
data-testid="payment-choice-ethereum"
294267
label={<RadioLabel>{t('steps.info.ethereum')}</RadioLabel>}
295268
name="RadioButtonGroup"
296269
value={PaymentMethod.ethereum}
297270
disabled={hasPendingMoonpayTransaction}
298-
checked={paymentMethodChoice === PaymentMethod.ethereum || undefined}
271+
defaultChecked={paymentMethodChoice === PaymentMethod.ethereum || undefined}
272+
onChange={(e) => setPaymentMethodChoice(e.currentTarget.value as PaymentMethod)}
299273
/>
300274
{paymentMethodChoice === PaymentMethod.ethereum && !hasEnoughEth && (
301275
<>
@@ -325,30 +299,43 @@ const PaymentChoice = ({
325299
)}
326300
</RadioButtonContainer>
327301
<RadioButtonContainer>
328-
<StyledRadioButton
302+
<RadioButton
329303
label={
330-
<LabelContainer>
304+
<Box display="flex" flexWrap="wrap">
331305
<RadioLabel>{t('steps.info.creditOrDebit')}</RadioLabel>
332306
<Typography color="grey" weight="light">
333307
({t('steps.info.additionalFee')})
334308
</Typography>
335-
</LabelContainer>
309+
</Box>
336310
}
337311
name="RadioButtonGroup"
338312
value={PaymentMethod.moonpay}
339-
checked={paymentMethodChoice === PaymentMethod.moonpay || undefined}
313+
onChange={(e) => setPaymentMethodChoice(e.currentTarget.value as PaymentMethod)}
314+
defaultChecked={paymentMethodChoice === PaymentMethod.moonpay || undefined}
340315
/>
341316
{paymentMethodChoice === PaymentMethod.moonpay && (
342317
<>
343318
<Spacer $height="4" />
344-
<InfoItems>
319+
<Box
320+
display="flex"
321+
flexDirection={{
322+
base: 'row',
323+
sm: 'column',
324+
}}
325+
alignItems={{
326+
base: 'center',
327+
sm: 'stretch',
328+
}}
329+
justifyContent="flex-start"
330+
gap="4"
331+
>
345332
{moonpayInfoItems.map((item, idx) => (
346333
<InfoItem key={item}>
347334
<Typography>{idx + 1}</Typography>
348335
<Typography>{t(item)}</Typography>
349336
</InfoItem>
350337
))}
351-
</InfoItems>
338+
</Box>
352339
<Spacer $height="4" />
353340
{hasFailedMoonpayTransaction && (
354341
<Helper alert="error">{t('steps.info.failedMoonpayTransaction')}</Helper>
@@ -361,8 +348,8 @@ const PaymentChoice = ({
361348
</>
362349
)}
363350
</RadioButtonContainer>
364-
</StyledRadioButtonGroup>
365-
</PaymentChoiceContainer>
351+
</RadioButtonGroup>
352+
</Box>
366353
)
367354
}
368355

src/components/pages/profile/[name]/registration/useMoonpayRegistration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const useMoonpayRegistration = (
100100
refetchOnMount: true,
101101
refetchInterval: 1000,
102102
refetchIntervalInBackground: true,
103-
enabled: !!currentExternalTransactionId && !isCompleted,
103+
enabled: !!currentExternalTransactionId && !isCompleted && chainId === 1,
104104
})
105105

106106
return {

src/utils/constants.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ export const GRACE_PERIOD = 90 * 24 * 60 * 60 * 1000
55
export const MOONPAY_WORKER_URL: { [key: number]: string } = {
66
// eslint-disable-next-line @typescript-eslint/naming-convention
77
1: 'https://moonpay-worker.ens-cf.workers.dev',
8-
// eslint-disable-next-line @typescript-eslint/naming-convention
9-
5: 'https://moonpay-worker-goerli.ens-cf.workers.dev',
10-
// eslint-disable-next-line @typescript-eslint/naming-convention
11-
1337: 'https://moonpay-goerli.ens-cf.workers.dev',
128
}
139

1410
export const FAUCET_WORKER_URL = 'https://ens-faucet.ens-cf.workers.dev'

0 commit comments

Comments
 (0)