@huma-finance/widgets 0.0.59-beta.485 → 0.0.59-beta.486

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huma-finance/widgets",
3
- "version": "0.0.59-beta.485+f8c4840",
3
+ "version": "0.0.59-beta.486+2521877",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -30,8 +30,8 @@
30
30
  "@ethersproject/experimental": "^5.7.0",
31
31
  "@ethersproject/providers": "^5.6.0",
32
32
  "@ethersproject/units": "^5.6.0",
33
- "@huma-finance/sdk": "^0.0.59-beta.485+f8c4840",
34
- "@huma-finance/shared": "^0.0.59-beta.485+f8c4840",
33
+ "@huma-finance/sdk": "^0.0.58",
34
+ "@huma-finance/shared": "^0.0.58",
35
35
  "@mui/icons-material": "^5.3.0",
36
36
  "@mui/material": "^5.0.6",
37
37
  "@mui/styles": "^5.0.2",
@@ -63,6 +63,7 @@
63
63
  "history": "^5.3.0",
64
64
  "jotai": "^1.13.1",
65
65
  "moment": "^2.29.4",
66
+ "persona": "^5.1.0",
66
67
  "qrcode": "^1.5.1",
67
68
  "query-string": "^7.1.1",
68
69
  "react": "^18.2.0",
@@ -137,6 +138,7 @@
137
138
  "@typechain/ethers-v5": "^10.1.0",
138
139
  "@types/jest": "^27.5.2",
139
140
  "@types/node": "^17.0.45",
141
+ "@types/persona": "^0.0.32",
140
142
  "@types/qrcode": "^1.5.0",
141
143
  "@types/react": "^18.0.21",
142
144
  "@types/react-dom": "^18.0.6",
@@ -193,5 +195,5 @@
193
195
  "optionalDependencies": {
194
196
  "encoding": "^0.1.13"
195
197
  },
196
- "gitHead": "f8c4840b6ac1055f7f81ee6e584d3d28838a297e"
198
+ "gitHead": "2521877d3ec21dd5c552804a945184da05dab0e0"
197
199
  }
@@ -88,8 +88,8 @@ export function InputAmountModal({
88
88
  `,
89
89
  info: css`
90
90
  color: ${theme.palette.text.primary};
91
- font-family: 'Uni-Neue-Bold';
92
- font-size: 20px;
91
+ font-family: 'Uni-Neue-Regular';
92
+ font-size: 16px;
93
93
  line-height: 160%;
94
94
  letter-spacing: 0.15px;
95
95
  `,
@@ -1,346 +1,45 @@
1
- import {
2
- CHAINS,
3
- checkIsDev,
4
- configUtil,
5
- DocSignatureStatus,
6
- IdentityService,
7
- KYCCopy,
8
- PoolInfoV2,
9
- timeUtil,
10
- useAuthErrorHandling,
11
- useParamsSearch,
12
- VerificationStatusResult,
13
- } from '@huma-finance/shared'
14
- import { Box, css, useTheme } from '@mui/material'
15
- import { useWeb3React } from '@web3-react/core'
16
- import React, { useCallback, useEffect, useMemo, useState } from 'react'
1
+ import { PoolInfoV2, TrancheType } from '@huma-finance/shared'
2
+ import { BigNumber } from 'ethers'
3
+ import React from 'react'
17
4
 
18
- import { useAppDispatch } from '../../../hooks/useRedux'
19
- import { setError } from '../../../store/widgets.reducers'
20
- import { BottomButton } from '../../BottomButton'
21
- import { HumaSnackBar } from '../../HumaSnackBar'
22
- import { ApproveLenderImg } from '../../images'
23
- import { LoadingModal } from '../../LoadingModal'
24
- import { WrapperModal } from '../../WrapperModal'
25
-
26
- const LoadingCopiesByType: {
27
- [key: string]: {
28
- description: string
29
- }
30
- } = {
31
- verificationStatus: {
32
- description: `Checking your verification status...`,
33
- },
34
- sendDocSignatureLink: {
35
- description: `Sending signature link...`,
36
- },
37
- }
5
+ import { Campaign } from '.'
6
+ import { PersonaEvaluation } from './components/PersonaEvaluation'
7
+ import { SecuritizeEvaluation } from './components/SecuritizeEvaluation'
38
8
 
39
9
  type Props = {
40
10
  poolInfo: PoolInfoV2
11
+ isUniTranche: boolean
12
+ minDepositAmount: BigNumber
13
+ campaign?: Campaign
14
+ changeTranche: (tranche: TrancheType) => void
41
15
  handleClose: () => void
42
16
  }
43
17
 
44
18
  export function Evaluation({
45
19
  poolInfo,
20
+ isUniTranche,
21
+ minDepositAmount,
22
+ campaign,
23
+ changeTranche,
46
24
  handleClose,
47
25
  }: Props): React.ReactElement | null {
48
- const theme = useTheme()
49
- const dispatch = useAppDispatch()
50
- const isDev = checkIsDev()
51
- const { account, chainId } = useWeb3React()
52
- const { kycProvider, code, kycPool } = useParamsSearch()
53
- const {
54
- isWalletOwnershipVerified,
55
- setError: setAuthError,
56
- error: authError,
57
- } = useAuthErrorHandling(isDev)
58
- const [loadingType, setLoadingType] = useState<
59
- 'verificationStatus' | 'sendDocSignatureLink'
60
- >()
61
- const KYCCopies = poolInfo.KYC!
62
- const [kycCopy, setKYCCopy] = useState<KYCCopy>(KYCCopies.verifyIdentity)
63
- const [KYCVerifyStatus, setKYCVerifyStatus] =
64
- useState<VerificationStatusResult>()
65
- const [docSignatureStatus, setDocSignatureStatus] =
66
- useState<DocSignatureStatus['status']>()
67
- const docSignatureCompleted = docSignatureStatus === 'completed'
68
- const [openSnackBar, setOpenSnackBar] = useState<boolean>(false)
69
-
70
- const styles = {
71
- iconWrapper: css`
72
- ${theme.cssMixins.rowCentered};
73
- margin-top: ${theme.spacing(8)};
74
- & > img {
75
- width: 144px;
76
- }
77
- `,
78
- description: css`
79
- ${theme.cssMixins.rowCentered};
80
- margin-top: ${theme.spacing(10)};
81
- padding: ${theme.spacing(0, 2)};
82
- font-family: 'Uni-Neue-Regular';
83
- font-size: 16px;
84
- color: #a8a1b2;
85
- `,
86
- }
87
-
88
- const { envelopeKey, envelopeLastQueryTimeKey, envelopeDocuSignStatusKey } =
89
- useMemo(() => {
90
- const envelopeKey = `${poolInfo.pool.toLowerCase()}-${account?.toLowerCase()}`
91
- const envelopeLastQueryTimeKey = `${envelopeKey}-last-query-time`
92
- const envelopeDocuSignStatusKey = `${envelopeKey}-docuSign-status`
93
- return {
94
- envelopeKey,
95
- envelopeLastQueryTimeKey,
96
- envelopeDocuSignStatusKey,
97
- }
98
- }, [account, poolInfo.pool])
99
-
100
- // DocuSign GET requests to any specific URL can be called not more often than once every 15 minutes.
101
- // https://developers.docusign.com/platform/api-guidelines/#:~:text=Polling,not%20once%20every%2010%20minutes
102
- const checkGetDocSignatureStatusIsAvailable = useCallback(() => {
103
- const lastQueryTime = localStorage.getItem(envelopeLastQueryTimeKey)
104
- if (!lastQueryTime) {
105
- return true
106
- }
107
- const lastQueryTimeNumber = Number(lastQueryTime)
108
- const now = timeUtil.getUnixTimestamp()
109
- const diff = now - lastQueryTimeNumber
110
- const fifteenMinutes = 15 * 60
111
- return diff > fifteenMinutes
112
- }, [envelopeLastQueryTimeKey])
113
-
114
- useEffect(() => {
115
- setKYCCopy(KYCCopies.verifyIdentity)
116
- const docuSignStatus = localStorage.getItem(envelopeDocuSignStatusKey)
117
- setDocSignatureStatus(docuSignStatus as DocSignatureStatus['status'])
118
- if (docuSignStatus === 'completed') {
119
- setKYCCopy(KYCCopies.docUnderReview)
120
- return
121
- }
122
-
123
- const fetchData = async () => {
124
- try {
125
- if (kycProvider && kycPool && account && chainId) {
126
- setLoadingType('verificationStatus')
127
- await IdentityService.onboard(
128
- account,
129
- code as string,
130
- kycPool as string,
131
- chainId,
132
- isDev,
133
- )
134
- }
135
- } catch (e) {
136
- try {
137
- setAuthError(e)
138
- setKYCCopy(KYCCopies.signInRequired)
139
- } catch (e) {
140
- // The repeated call will throw an error of 401, so we can ignore it.
141
- console.log(e)
142
- }
143
- }
144
-
145
- try {
146
- if (account && chainId) {
147
- setLoadingType('verificationStatus')
148
- const verificationStatus =
149
- await IdentityService.getVerificationStatus(
150
- account,
151
- poolInfo.pool,
152
- chainId,
153
- isDev,
154
- )
155
- setKYCVerifyStatus(verificationStatus)
156
- if (verificationStatus.isVerified) {
157
- const envelopeId = localStorage.getItem(envelopeKey)
158
- if (!envelopeId) {
159
- setKYCCopy(KYCCopies.emailSignatureLink)
160
- } else if (!checkGetDocSignatureStatusIsAvailable()) {
161
- setKYCCopy(KYCCopies.resendSignatureLink)
162
- } else {
163
- const { status } = await IdentityService.getDocSignatureStatus(
164
- envelopeId,
165
- chainId,
166
- isDev,
167
- )
168
- localStorage.setItem(
169
- envelopeLastQueryTimeKey,
170
- String(timeUtil.getUnixTimestamp()),
171
- )
172
- localStorage.setItem(envelopeDocuSignStatusKey, status)
173
- setDocSignatureStatus(status)
174
- if (status === 'completed') {
175
- setKYCCopy(KYCCopies.docUnderReview)
176
- // For voided and declined status, we need to send a new link
177
- } else if (['voided', 'declined'].includes(status)) {
178
- localStorage.removeItem(envelopeKey)
179
- localStorage.removeItem(envelopeLastQueryTimeKey)
180
- setKYCCopy(KYCCopies.emailSignatureLink)
181
- } else {
182
- setKYCCopy(KYCCopies.resendSignatureLink)
183
- }
184
- }
185
- } else {
186
- setKYCCopy(KYCCopies.verifyIdentity)
187
- }
188
- }
189
- } catch (e: unknown) {
190
- try {
191
- setAuthError(e)
192
- setKYCCopy(KYCCopies.signInRequired)
193
- } catch (e) {
194
- console.error(e)
195
- dispatch(
196
- setError({
197
- errorMessage: 'Something went wrong, please try again later.',
198
- }),
199
- )
200
- }
201
- } finally {
202
- setLoadingType(undefined)
203
- }
204
- }
205
- fetchData()
206
- }, [
207
- KYCCopies.docUnderReview,
208
- KYCCopies.emailSignatureLink,
209
- KYCCopies.resendSignatureLink,
210
- KYCCopies.signInRequired,
211
- KYCCopies.verifyIdentity,
212
- account,
213
- chainId,
214
- checkGetDocSignatureStatusIsAvailable,
215
- code,
216
- dispatch,
217
- envelopeDocuSignStatusKey,
218
- envelopeKey,
219
- envelopeLastQueryTimeKey,
220
- isDev,
221
- kycPool,
222
- kycProvider,
223
- poolInfo.pool,
224
- setAuthError,
225
- isWalletOwnershipVerified,
226
- ])
227
-
228
- useEffect(() => {
229
- if (
230
- authError &&
231
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
232
- [4001, 'ACTION_REJECTED'].includes((authError as any).code)
233
- ) {
234
- dispatch(
235
- setError({
236
- errorMessage: 'User has rejected the transaction.',
237
- }),
238
- )
239
- }
240
- }, [authError, dispatch])
241
-
242
- const approveLender = async () => {
243
- if (docSignatureCompleted) {
244
- handleClose()
245
- return
246
- }
247
-
248
- const { isNotOnboarded, isVerified } = KYCVerifyStatus || {}
249
-
250
- if (!isVerified) {
251
- const issuerId = CHAINS[chainId!].isTestnet
252
- ? '53a66b32-583e-40e7-ba90-baf516d2cadd'
253
- : '5557baf5-d3c2-4c80-b522-c05a11c6e586'
254
- const baseUrl = configUtil.getKYCProviderBaseUrl(
255
- poolInfo.KYC!.provider,
256
- chainId!,
257
- )
258
- const originUrl = window.location.href.split('?')[0]
259
- const redirectUrl = `${originUrl}?poolName=${
260
- poolInfo.poolName
261
- }&kycProvider=${poolInfo.KYC!.provider}&kycPool=${poolInfo.pool}`
262
- const providerAuthorizeUrl = `${baseUrl}/#/authorize?issuerId=${issuerId}&scope=details&details=verification&redirectUrl=${redirectUrl}`
263
- window.location.href = isNotOnboarded ? providerAuthorizeUrl : baseUrl
264
- } else {
265
- const envelopeId = localStorage.getItem(envelopeKey)
266
- try {
267
- setLoadingType('sendDocSignatureLink')
268
- if (!envelopeId) {
269
- const { envelopeId } = await IdentityService.requestDocSignature(
270
- account!,
271
- chainId!,
272
- isDev,
273
- )
274
- localStorage.setItem(envelopeKey, envelopeId)
275
- localStorage.setItem(
276
- envelopeLastQueryTimeKey,
277
- String(timeUtil.getUnixTimestamp()),
278
- )
279
- setOpenSnackBar(true)
280
- setKYCCopy(KYCCopies.resendSignatureLink)
281
- } else {
282
- await IdentityService.resendDocSignatureLink(
283
- envelopeId,
284
- chainId!,
285
- isDev,
286
- )
287
- setOpenSnackBar(true)
288
- }
289
- } catch (e: unknown) {
290
- try {
291
- const { envelopeId } = await IdentityService.requestDocSignature(
292
- account!,
293
- chainId!,
294
- isDev,
295
- )
296
- localStorage.setItem(envelopeKey, envelopeId)
297
- localStorage.setItem(
298
- envelopeLastQueryTimeKey,
299
- String(timeUtil.getUnixTimestamp()),
300
- )
301
- setOpenSnackBar(true)
302
- setKYCCopy(KYCCopies.resendSignatureLink)
303
- } catch (e) {
304
- setAuthError(e)
305
- setKYCCopy(KYCCopies.signInRequired)
306
- }
307
- } finally {
308
- setLoadingType(undefined)
309
- }
310
- }
26
+ if (poolInfo.KYC?.Securitize) {
27
+ return (
28
+ <SecuritizeEvaluation poolInfo={poolInfo} handleClose={handleClose} />
29
+ )
311
30
  }
312
-
313
- const getEmailLinkSentSnackbar = () => (
314
- <HumaSnackBar
315
- open={openSnackBar}
316
- title='Signature Link Sent'
317
- message='The secure signature session link has been sent to you via email.'
318
- severity='success'
319
- onClose={() => setOpenSnackBar(false)}
320
- />
321
- )
322
-
323
- if (!loadingType) {
31
+ if (poolInfo.KYC?.Persona) {
324
32
  return (
325
- <WrapperModal title={kycCopy.title}>
326
- <Box css={styles.iconWrapper}>
327
- <img src={ApproveLenderImg} alt='approve-lender' />
328
- </Box>
329
- <Box css={styles.description}>{kycCopy.description}</Box>
330
- {Boolean(kycCopy.buttonText) && (
331
- <BottomButton variant='contained' onClick={approveLender}>
332
- {kycCopy.buttonText}
333
- </BottomButton>
334
- )}
335
- {getEmailLinkSentSnackbar()}
336
- </WrapperModal>
33
+ <PersonaEvaluation
34
+ poolInfo={poolInfo}
35
+ handleClose={handleClose}
36
+ isUniTranche={isUniTranche}
37
+ campaign={campaign}
38
+ minDepositAmount={minDepositAmount}
39
+ changeTranche={changeTranche}
40
+ />
337
41
  )
338
42
  }
339
43
 
340
- return (
341
- <LoadingModal
342
- title='Lender Approval'
343
- description={LoadingCopiesByType[loadingType].description}
344
- />
345
- )
44
+ return null
346
45
  }
@@ -1,37 +1,45 @@
1
1
  import {
2
+ CampaignService,
3
+ formatNumber,
2
4
  PoolInfoV2,
3
5
  TrancheType,
4
6
  UnderlyingTokenInfo,
5
- formatNumber,
6
- useLPConfigV2,
7
+ useDebouncedValue,
7
8
  usePoolSafeAllowanceV2,
8
9
  usePoolUnderlyingTokenBalanceV2,
9
10
  } from '@huma-finance/shared'
10
11
  import { useWeb3React } from '@web3-react/core'
11
12
  import { BigNumber, ethers } from 'ethers'
12
- import React, { useState } from 'react'
13
+ import React, { useEffect, useState } from 'react'
13
14
 
14
15
  import { useAppDispatch } from '../../../hooks/useRedux'
15
16
  import { setStep, setSupplyAmount } from '../../../store/widgets.reducers'
16
17
  import { WIDGET_STEP } from '../../../store/widgets.store'
17
18
  import { InputAmountModal } from '../../InputAmountModal'
18
- import { LoadingModal } from '../../LoadingModal'
19
+ import { Campaign } from '.'
19
20
 
20
21
  type Props = {
21
22
  poolInfo: PoolInfoV2
22
23
  poolUnderlyingToken: UnderlyingTokenInfo
23
24
  selectedTranche: TrancheType | undefined
25
+ isUniTranche: boolean
26
+ campaign?: Campaign
24
27
  }
25
28
 
26
29
  export function ChooseAmount({
27
30
  poolInfo,
28
31
  poolUnderlyingToken,
29
32
  selectedTranche,
33
+ isUniTranche,
34
+ campaign,
30
35
  }: Props): React.ReactElement | null {
31
36
  const dispatch = useAppDispatch()
32
37
  const { account, provider } = useWeb3React()
33
38
  const { symbol, decimals } = poolUnderlyingToken
34
39
  const [currentAmount, setCurrentAmount] = useState<number | string>(0)
40
+ const debouncedValue = useDebouncedValue(currentAmount)
41
+ const [campaignPoints, setCampaignPoints] = useState<number>(0)
42
+ const [lockupPeriodMonths, setLockupPeriodMonths] = useState<number>(0)
35
43
  const { allowance = BigNumber.from(0) } = usePoolSafeAllowanceV2(
36
44
  poolInfo.poolName,
37
45
  account,
@@ -46,8 +54,36 @@ export function ChooseAmount({
46
54
  balance,
47
55
  poolUnderlyingToken.decimals,
48
56
  )
49
- const lpConfig = useLPConfigV2(poolInfo.poolName, provider)
50
- const isUniTranche = lpConfig?.maxSeniorJuniorRatio === 0
57
+
58
+ useEffect(() => {
59
+ const getBasePoints = async () => {
60
+ if (campaign && selectedTranche && Number(debouncedValue) > 0) {
61
+ const estimatedPoints = await CampaignService.getEstimatedPoints(
62
+ campaign.campaignGroupId,
63
+ ethers.utils
64
+ .parseUnits(
65
+ String(debouncedValue),
66
+ poolInfo.poolUnderlyingToken.decimals,
67
+ )
68
+ .toString(),
69
+ )
70
+ const campaignPoints = estimatedPoints.find(
71
+ (item) => item.campaignId === campaign.id,
72
+ )
73
+ if (campaignPoints) {
74
+ setCampaignPoints(campaignPoints[`${selectedTranche}TranchePoints`])
75
+ setLockupPeriodMonths(campaignPoints.lockupPeriodMonths)
76
+ }
77
+ }
78
+ }
79
+ getBasePoints()
80
+ }, [
81
+ campaign,
82
+ debouncedValue,
83
+ decimals,
84
+ poolInfo.poolUnderlyingToken.decimals,
85
+ selectedTranche,
86
+ ])
51
87
 
52
88
  const handleChangeAmount = (newAmount: number) => {
53
89
  setCurrentAmount(newAmount)
@@ -65,8 +101,11 @@ export function ChooseAmount({
65
101
  dispatch(setStep(step))
66
102
  }
67
103
 
68
- if (!lpConfig) {
69
- return <LoadingModal title='Supply' />
104
+ let info = `${formatNumber(maxAmountFormatted)} Available`
105
+ if (campaign && campaignPoints > 0) {
106
+ info = `You will earn ${formatNumber(
107
+ campaignPoints,
108
+ )} points for the entire ${lockupPeriodMonths} months right away.`
70
109
  }
71
110
 
72
111
  return (
@@ -79,7 +118,7 @@ export function ChooseAmount({
79
118
  currentAmount={currentAmount}
80
119
  handleChangeAmount={handleChangeAmount}
81
120
  maxAmount={maxAmountFormatted}
82
- info={`${formatNumber(maxAmountFormatted)} Available`}
121
+ info={info}
83
122
  handleAction={handleAction}
84
123
  actionText='SUPPLY'
85
124
  />
@@ -4,11 +4,13 @@ import {
4
4
  formatMoney,
5
5
  PoolInfoV2,
6
6
  sendTxAtom,
7
+ timeUtil,
7
8
  TRANSFER_ABI,
8
9
  UnderlyingTokenInfo,
9
10
  } from '@huma-finance/shared'
10
11
  import { useWeb3React } from '@web3-react/core'
11
12
  import { useAtom } from 'jotai'
13
+ import moment from 'moment'
12
14
  import React, { useCallback, useEffect, useState } from 'react'
13
15
  import { useDispatch } from 'react-redux'
14
16
 
@@ -16,24 +18,31 @@ import {
16
18
  useDoesChainSupportNotifi,
17
19
  useIsFirstTimeNotifiUser,
18
20
  } from '../../../hooks/useNotifi'
19
- import { TxDoneModal } from '../../TxDoneModal'
20
21
  import { setStep } from '../../../store/widgets.reducers'
21
22
  import { WIDGET_STEP } from '../../../store/widgets.store'
23
+ import { TxDoneModal } from '../../TxDoneModal'
24
+ import { Campaign } from '.'
22
25
 
23
26
  type Props = {
24
27
  poolInfo: PoolInfoV2
25
28
  poolUnderlyingToken: UnderlyingTokenInfo
29
+ lpConfig: { withdrawalLockoutPeriodInDays: number }
30
+ campaign?: Campaign
31
+ updateTransactionHash: (hash: string) => void
26
32
  handleAction: () => void
27
33
  }
28
34
 
29
35
  export function Success({
30
36
  poolInfo,
31
37
  poolUnderlyingToken,
38
+ lpConfig,
39
+ campaign,
40
+ updateTransactionHash,
32
41
  handleAction,
33
42
  }: Props): React.ReactElement {
34
43
  const dispatch = useDispatch()
35
44
  const { account, chainId } = useWeb3React()
36
- const [{ txReceipt }] = useAtom(sendTxAtom)
45
+ const [{ txReceipt, txHash }] = useAtom(sendTxAtom)
37
46
  const { symbol, decimals, address } = poolUnderlyingToken
38
47
  const [supplyAmount, setSupplyAmount] = useState<string | undefined>()
39
48
  const { isFirstTimeNotifiUser } = useIsFirstTimeNotifiUser(account, chainId)
@@ -57,23 +66,57 @@ export function Success({
57
66
  }
58
67
  }, [account, address, decimals, poolInfo.poolSafe, txReceipt])
59
68
 
60
- const setupNotificationsOrClose = useCallback(() => {
69
+ useEffect(() => {
70
+ if (txHash) {
71
+ updateTransactionHash(txHash)
72
+ }
73
+ }, [txHash, updateTransactionHash])
74
+
75
+ const handleUserAction = useCallback(() => {
61
76
  if (isFirstTimeNotifiUser && notifiChainSupported) {
62
77
  dispatch(setStep(WIDGET_STEP.Notifications))
78
+ } else if (campaign) {
79
+ dispatch(setStep(WIDGET_STEP.PointsEarned))
63
80
  } else {
64
81
  handleAction()
65
82
  }
66
- }, [dispatch, handleAction, isFirstTimeNotifiUser, notifiChainSupported])
83
+ }, [
84
+ campaign,
85
+ dispatch,
86
+ handleAction,
87
+ isFirstTimeNotifiUser,
88
+ notifiChainSupported,
89
+ ])
67
90
 
68
91
  const content = [
69
92
  `You successfully supplied ${formatMoney(supplyAmount)} ${symbol}.`,
70
93
  ]
71
94
 
95
+ const getSubContent = () => {
96
+ const currentTime = moment().add(
97
+ lpConfig.withdrawalLockoutPeriodInDays,
98
+ 'days',
99
+ )
100
+ return [
101
+ `First redemption date: ${timeUtil.timestampToLL(
102
+ currentTime.unix(),
103
+ )}. You can redeem end of each month after.`,
104
+ ]
105
+ }
106
+
107
+ const getButtonText = () => {
108
+ if (hasNextStep) {
109
+ return "WHAT'S NEXT"
110
+ }
111
+ return campaign ? 'VIEW POINTS' : undefined
112
+ }
113
+
72
114
  return (
73
115
  <TxDoneModal
74
- handleAction={setupNotificationsOrClose}
116
+ handleAction={handleUserAction}
75
117
  content={content}
76
- buttonText={hasNextStep ? "WHAT'S NEXT" : undefined}
118
+ subContent={getSubContent()}
119
+ buttonText={getButtonText()}
77
120
  />
78
121
  )
79
122
  }
@@ -1,10 +1,29 @@
1
- import React from 'react'
1
+ import React, { useCallback } from 'react'
2
+ import { useDispatch } from 'react-redux'
3
+
4
+ import { Campaign } from '.'
2
5
  import { NotifiSubscriptionModal } from '../../Notifi/NotifiSubscriptionModal'
6
+ import { setStep } from '../../../store/widgets.reducers'
7
+ import { WIDGET_STEP } from '../../../store/widgets.store'
3
8
 
4
9
  type Props = {
10
+ campaign?: Campaign
5
11
  handleAction: () => void
6
12
  }
7
13
 
8
- export function Notifications({ handleAction }: Props): React.ReactElement {
9
- return <NotifiSubscriptionModal handleSuccess={handleAction} />
14
+ export function Notifications({
15
+ campaign,
16
+ handleAction,
17
+ }: Props): React.ReactElement {
18
+ const dispatch = useDispatch()
19
+
20
+ const handleUserAction = useCallback(() => {
21
+ if (campaign) {
22
+ dispatch(setStep(WIDGET_STEP.PointsEarned))
23
+ } else {
24
+ handleAction()
25
+ }
26
+ }, [campaign, dispatch, handleAction])
27
+
28
+ return <NotifiSubscriptionModal handleSuccess={handleUserAction} />
10
29
  }