Skip to content

Commit 5347db3

Browse files
authored
Fix: Restore claim disabled message modal overlay (#611) (#626)
* fix: replace useModal with absolute overlay for disabled claim state * fix: gate modal display with claimEnabled flag and remove comments * fix: use standard img tag to ensure maintenance asset renders * chore: restore valid developer comments and remove temporary ones
1 parent 3799dba commit 5347db3

2 files changed

Lines changed: 64 additions & 50 deletions

File tree

‎src/pages/gd/Claim/OldClaim.tsx‎

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
import { useAppKit } from '@reown/appkit/react'
2424
import { QueryParams } from '@usedapp/core'
2525
import { noop } from 'lodash'
26-
// import { useFeatureFlagWithPayload } from 'posthog-react-native'
26+
import { useFeatureFlagWithPayload } from 'posthog-react-native'
2727
import moment from 'moment'
2828

2929
import { getEnv } from 'utils/env'
@@ -39,8 +39,7 @@ import BillyGrin from 'assets/images/claim/billygrin.png'
3939
import BillyConfused from 'assets/images/claim/billyconfused.png'
4040

4141
import { useIsSimpleApp } from 'state/simpleapp/simpleapp'
42-
43-
// import { useDisabledClaimingModal } from './useDisabledClaimModal'
42+
import { useDisabledClaimingModal } from './useDisabledClaimModal'
4443
import { useGoodDappFeatures } from 'hooks/useFeaturesEnabled'
4544

4645
const OldClaim = memo(() => {
@@ -57,9 +56,10 @@ const OldClaim = memo(() => {
5756
const { open } = useAppKit()
5857
const network = SupportedV2Networks[chainId]
5958
const sendData = useSendAnalyticsData()
60-
// todo: fix UI for displaying claiming disabled modal
61-
// const [, payload] = useFeatureFlagWithPayload('claim-feature')
62-
// const { enabled: claimEnabled = true, disabledMessage = '' } = (payload as any) || {}
59+
60+
const [, payload] = useFeatureFlagWithPayload('claim-feature')
61+
const { enabled: claimEnabled = true, disabledMessage = '' } = (payload as any) || {}
62+
6363
const { activeNetworksByFeature, activeChainFeatures } = useGoodDappFeatures()
6464
const supportedChains = activeNetworksByFeature['claimEnabled'] || []
6565
const isProd = getEnv() === 'production'
@@ -69,7 +69,14 @@ const OldClaim = memo(() => {
6969
const isHoliday = holiday >= '12-24' || holiday <= '01-01'
7070

7171
const isSimpleApp = useIsSimpleApp()
72-
// const { Dialog, showModal } = useDisabledClaimingModal(disabledMessage)
72+
73+
const { Dialog, showModal } = useDisabledClaimingModal(disabledMessage)
74+
75+
useEffect(() => {
76+
if (!claimEnabled) {
77+
showModal()
78+
}
79+
}, [claimEnabled, showModal])
7380

7481
const isMinipay = isMiniPay()
7582

@@ -143,6 +150,12 @@ const OldClaim = memo(() => {
143150

144151
const handleClaim = useCallback(async () => {
145152
setRefreshRate('everyBlock')
153+
154+
if (!claimEnabled) {
155+
showModal()
156+
return false
157+
}
158+
146159
if (activeChainFeatures['claimEnabled'] || !isProd || isMinipay) {
147160
// minipay doesnt handle gasPrice correctly, so we let it decide
148161
const claim = await send(isMinipay ? { gasPrice: undefined } : {})
@@ -164,12 +177,12 @@ const OldClaim = memo(() => {
164177
sendData({ event: 'claim', action: 'claim_success', network })
165178
return true
166179
} else {
167-
// showModal()
180+
showModal()
168181
}
169182

170183
return false
171184
// eslint-disable-next-line react-hooks/exhaustive-deps
172-
}, [send, network, sendData, activeChainFeatures, isSimpleApp])
185+
}, [send, network, sendData, activeChainFeatures, isSimpleApp, claimEnabled, showModal])
173186

174187
const handleConnect = useCallback(async () => {
175188
if (!address) {
@@ -192,7 +205,7 @@ const OldClaim = memo(() => {
192205
},
193206
lg: {
194207
flexDirection: 'row',
195-
justifyContent: 'justify-evenly',
208+
justifyContent: 'space-evenly',
196209
},
197210
})
198211

@@ -294,9 +307,7 @@ const OldClaim = memo(() => {
294307
content: [
295308
{
296309
description: {
297-
text: `After claiming your G$, use it to support your community, buy products and services, support causes you care about, vote in the GoodDAO, and more.
298-
299-
Learn how here`,
310+
text: `After claiming your G$, use it to support your community, buy products and services, support causes you care about, vote in the GoodDAO, and more. \n\nLearn how here`,
300311
color: 'white',
301312
},
302313
...(isSmallTabletView && { imgSrc: BillyHappy }),
@@ -333,10 +344,11 @@ Learn how here`,
333344
return (
334345
<>
335346
<Box w="100%" mb="8" style={mainView}>
336-
{/* <Dialog /> */}
337347
<CentreBox style={claimView}>
338348
<div className="flex flex-col items-center text-center lg:w-1/2">
339-
<Box style={balanceContainer}>
349+
<Box style={balanceContainer} position="relative" borderRadius="2xl" overflow="hidden">
350+
<Dialog />
351+
340352
{claimed ? (
341353
<Box justifyContent="center" display="flex" alignItems="center" textAlign="center">
342354
<ClaimBalance refresh={refreshRate} />
Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,46 @@
1-
import React, { useCallback } from 'react'
2-
import { Image, Title, useModal } from '@gooddollar/good-design'
3-
import { Box, Text, View } from 'native-base'
4-
import { noop } from 'lodash'
1+
import { useCallback, useState } from 'react'
2+
import { Title } from '@gooddollar/good-design'
3+
import { Box, Text } from 'native-base'
54

65
import Maintance from 'assets/images/claim/maintance.png'
76

8-
const DialogHeader = () => (
9-
<Box>
10-
<Title color="main" fontSize="l" lineHeight={36}>
11-
Claiming Unavailable
12-
</Title>
13-
</Box>
14-
)
7+
export const useDisabledClaimingModal = (message: string) => {
8+
const [isVisible, setIsVisible] = useState(false)
159

16-
const DialogBody = ({ message }: { message: string }) => (
17-
<View>
18-
<Image resizeMode="contain" source={{ uri: Maintance }} w="auto" h={120} mb={4} />
19-
<Text fontFamily="subheading" lineHeight="20px">
20-
{message}
21-
</Text>
22-
</View>
23-
)
10+
const showModal = useCallback(() => setIsVisible(true), [])
2411

25-
export const useDisabledClaimingModal = (message: string) => {
26-
const { Modal, showModal } = useModal()
12+
const Dialog = useCallback(() => {
13+
if (!isVisible) return null
2714

28-
const Dialog = useCallback(
29-
() => (
30-
<React.Fragment>
31-
<Modal
32-
_modalContainer={{ paddingLeft: 18, paddingRight: 18, paddingBottom: 18 }}
33-
header={<DialogHeader />}
34-
body={<DialogBody message={message} />}
35-
onClose={noop}
36-
closeText="x"
37-
/>
38-
</React.Fragment>
39-
),
40-
[Modal]
41-
)
15+
return (
16+
<Box
17+
position="absolute"
18+
top={0}
19+
bottom={0}
20+
left={0}
21+
right={0}
22+
zIndex={50}
23+
display="flex"
24+
alignItems="center"
25+
justifyContent="center"
26+
borderRadius="2xl"
27+
>
28+
<Box bg="white" p={6} borderRadius="xl" alignItems="center" shadow={3} w="90%" maxW="320px">
29+
<Title color="main" fontSize="l" lineHeight={36} mb={2}>
30+
Claiming Unavailable
31+
</Title>
32+
<img
33+
src={Maintance}
34+
alt="Maintenance"
35+
style={{ height: '120px', objectFit: 'contain', marginBottom: '16px' }}
36+
/>
37+
<Text fontFamily="subheading" lineHeight="20px" textAlign="center" color="gray.600">
38+
{message || 'Claiming is temporarily disabled.'}
39+
</Text>
40+
</Box>
41+
</Box>
42+
)
43+
}, [isVisible, message])
4244

4345
return { Dialog, showModal }
4446
}

0 commit comments

Comments
 (0)