@huma-finance/widgets 0.0.80 → 0.0.81-beta.1108

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.
Files changed (68) hide show
  1. package/API.md +0 -11
  2. package/dist/index.js +60790 -64401
  3. package/dist/src/components/Lend/solanaSupply/6-Transfer.d.ts +2 -3
  4. package/dist/src/components/Lend/solanaSupply/7-Success.d.ts +1 -4
  5. package/dist/src/components/Lend/solanaSupply/index.d.ts +1 -7
  6. package/dist/src/components/Lend/stellarSupply/index.d.ts +0 -4
  7. package/dist/src/components/Lend/supply/1-Evaluation.d.ts +8 -0
  8. package/dist/src/components/Lend/supplyV2/6-Transfer.d.ts +2 -5
  9. package/dist/src/components/Lend/supplyV2/7-Success.d.ts +1 -3
  10. package/dist/src/components/Lend/supplyV2/8-Notifications.d.ts +1 -3
  11. package/dist/src/components/Lend/supplyV2/index.d.ts +1 -9
  12. package/dist/src/hooks/useEA.d.ts +0 -2
  13. package/dist/src/store/widgets.reducers.d.ts +1 -2
  14. package/dist/src/store/widgets.store.d.ts +0 -4
  15. package/package.json +6 -6
  16. package/src/components/CreditLine/borrow/1-Evaluation.tsx +1 -11
  17. package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +1 -10
  18. package/src/components/Lend/solanaSupply/6-Transfer.tsx +4 -34
  19. package/src/components/Lend/solanaSupply/7-Success.tsx +2 -16
  20. package/src/components/Lend/solanaSupply/index.tsx +1 -66
  21. package/src/components/Lend/stellarSupply/index.tsx +0 -5
  22. package/src/components/Lend/supply/{1-Evaluation/EvaluationEA.tsx → 1-Evaluation.tsx} +9 -9
  23. package/src/components/Lend/supply/index.tsx +0 -1
  24. package/src/components/Lend/supplyV2/6-Transfer.tsx +7 -35
  25. package/src/components/Lend/supplyV2/7-Success.tsx +2 -18
  26. package/src/components/Lend/supplyV2/8-Notifications.tsx +3 -26
  27. package/src/components/Lend/supplyV2/index.tsx +15 -72
  28. package/src/components/SolanaTxSendModal.tsx +1 -1
  29. package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +1 -10
  30. package/src/hooks/useEA.ts +4 -22
  31. package/src/store/widgets.reducers.ts +0 -7
  32. package/src/store/widgets.store.ts +0 -4
  33. package/vite.config.ts +1 -1
  34. package/dist/src/components/Lend/components/ApproveLenderBase.d.ts +0 -14
  35. package/dist/src/components/Lend/components/PersonaEvaluation.d.ts +0 -17
  36. package/dist/src/components/Lend/components/SecuritizeEvaluation.d.ts +0 -8
  37. package/dist/src/components/Lend/solanaSupply/1-Evaluation.d.ts +0 -12
  38. package/dist/src/components/Lend/solanaSupply/2-ApproveLender.d.ts +0 -10
  39. package/dist/src/components/Lend/solanaSupply/8-PointsEarned.d.ts +0 -11
  40. package/dist/src/components/Lend/supply/1-Evaluation/EvaluationEA.d.ts +0 -8
  41. package/dist/src/components/Lend/supply/1-Evaluation/EvaluationKYC.d.ts +0 -8
  42. package/dist/src/components/Lend/supply/1-Evaluation/index.d.ts +0 -9
  43. package/dist/src/components/Lend/supplyV2/2-Evaluation.d.ts +0 -12
  44. package/dist/src/components/Lend/supplyV2/3-ApproveLender.d.ts +0 -10
  45. package/dist/src/components/PointsEarned.d.ts +0 -10
  46. package/dist/src/components/SignIn.d.ts +0 -6
  47. package/dist/src/cosmos/CreditLineBorrow.fixture.d.ts +0 -2
  48. package/dist/src/cosmos/CreditLinePayment.fixture.d.ts +0 -2
  49. package/dist/src/cosmos/InvoiceFactoringBorrow.fixture.d.ts +0 -2
  50. package/dist/src/cosmos/InvoiceFactoringPayment.fixture.d.ts +0 -2
  51. package/dist/src/cosmos/LendSupply.fixture.d.ts +0 -2
  52. package/dist/src/cosmos/LendWithdraw.fixture.d.ts +0 -2
  53. package/dist/src/cosmos/SDKTesting.fixture.d.ts +0 -2
  54. package/dist/src/cosmos/SuperfluidFactoringBorrow.fixture.d.ts +0 -2
  55. package/dist/src/cosmos/WalletWrapper.d.ts +0 -3
  56. package/dist/src/cosmos/utils/index.d.ts +0 -18
  57. package/src/components/Lend/components/ApproveLenderBase.tsx +0 -128
  58. package/src/components/Lend/components/PersonaEvaluation.tsx +0 -371
  59. package/src/components/Lend/components/SecuritizeEvaluation.tsx +0 -343
  60. package/src/components/Lend/solanaSupply/1-Evaluation.tsx +0 -43
  61. package/src/components/Lend/solanaSupply/2-ApproveLender.tsx +0 -45
  62. package/src/components/Lend/solanaSupply/8-PointsEarned.tsx +0 -189
  63. package/src/components/Lend/supply/1-Evaluation/EvaluationKYC.tsx +0 -369
  64. package/src/components/Lend/supply/1-Evaluation/index.tsx +0 -31
  65. package/src/components/Lend/supplyV2/2-Evaluation.tsx +0 -47
  66. package/src/components/Lend/supplyV2/3-ApproveLender.tsx +0 -35
  67. package/src/components/PointsEarned.tsx +0 -135
  68. package/src/components/SignIn.tsx +0 -53
@@ -1,369 +0,0 @@
1
- import {
2
- CHAINS,
3
- configUtil,
4
- DocSignatureStatus,
5
- IdentityService,
6
- PoolInfoType,
7
- timeUtil,
8
- VerificationStatusResult,
9
- } from '@huma-finance/shared'
10
- import {
11
- useAuthErrorHandling,
12
- useParamsSearch,
13
- checkIsDev,
14
- } from '@huma-finance/web-shared'
15
- import { Box, css, useTheme } from '@mui/material'
16
- import { useWeb3React } from '@web3-react/core'
17
- import React, { useCallback, useEffect, useMemo, useState } from 'react'
18
-
19
- import { useAppDispatch } from '../../../../hooks/useRedux'
20
- import { setError } from '../../../../store/widgets.reducers'
21
- import { BottomButton } from '../../../BottomButton'
22
- import { HumaSnackBar } from '../../../HumaSnackBar'
23
- import { ApproveLenderImg } from '../../../images'
24
- import { LoadingModal } from '../../../LoadingModal'
25
- import { WrapperModal } from '../../../WrapperModal'
26
-
27
- const KYCProvider = 'Securitize'
28
-
29
- type KYCCopy = {
30
- title: string
31
- description: string
32
- buttonText?: string
33
- }
34
-
35
- // TODO: Add copies for the other pools. Currently only the Jia pool is using the KYC process.
36
- const JiaPoolCopies = {
37
- signInRequired: {
38
- title: 'Sign In',
39
- description:
40
- 'Please sign in to verify that you are the owner of the wallet.',
41
- },
42
- verifyIdentity: {
43
- title: 'Verify Identity',
44
- description: `This pool is only available to professional/accredited investors at the moment, with minimum investments of $10,000. Please complete identity verification and investor accreditation via ${KYCProvider}.`,
45
- buttonText: 'VERIFY MY IDENTITY',
46
- },
47
- emailSignatureLink: {
48
- title: 'Pool Documents',
49
- description: `By lending to this pool, you become a subscriber member of the Jia Pioneer Fund LLC. Please sign the LLC Agreement via DocuSign, securing your off-chain claim to the Fund's returns and collateral.`,
50
- buttonText: 'EMAIL DOCUSIGN LINK',
51
- },
52
- resendSignatureLink: {
53
- title: 'Resend Documents',
54
- description: `Please check your inbox for the LLC Agreement sent via DocuSign. If you haven't received it, check your spam folder or click below to resend.`,
55
- buttonText: 'RESEND DOCUSIGN LINK',
56
- },
57
- docUnderReview: {
58
- title: 'Under Review',
59
- description:
60
- 'Your documents are being reviewed and you will be notified upon approval. Thank you for your patience. Any questions? Email invest@jia.xyz.',
61
- buttonText: 'THANK YOU',
62
- },
63
- }
64
-
65
- const LoadingCopiesByType: {
66
- [key: string]: {
67
- description: string
68
- }
69
- } = {
70
- verificationStatus: {
71
- description: `Checking your verification status...`,
72
- },
73
- sendDocSignatureLink: {
74
- description: `Sending signature link...`,
75
- },
76
- }
77
-
78
- type Props = {
79
- poolInfo: PoolInfoType
80
- handleClose: () => void
81
- }
82
-
83
- export function EvaluationKYC({
84
- poolInfo,
85
- handleClose,
86
- }: Props): React.ReactElement | null {
87
- const theme = useTheme()
88
- const dispatch = useAppDispatch()
89
- const isDev = checkIsDev()
90
- const { account, chainId } = useWeb3React()
91
- const { kycProvider, code, kycPool } = useParamsSearch()
92
- const { isWalletOwnershipVerified, setAuthError, authError } =
93
- useAuthErrorHandling(isDev)
94
- const [loadingType, setLoadingType] = useState<
95
- 'verificationStatus' | 'sendDocSignatureLink'
96
- >()
97
- const [kycCopy, setKYCCopy] = useState<KYCCopy>(JiaPoolCopies.verifyIdentity)
98
- const [KYCVerifyStatus, setKYCVerifyStatus] =
99
- useState<VerificationStatusResult>()
100
- const [docSignatureStatus, setDocSignatureStatus] =
101
- useState<DocSignatureStatus['status']>()
102
- const docSignatureCompleted = docSignatureStatus === 'completed'
103
- const [openSnackBar, setOpenSnackBar] = useState<boolean>(false)
104
-
105
- const styles = {
106
- iconWrapper: css`
107
- ${theme.cssMixins.rowCentered};
108
- margin-top: ${theme.spacing(8)};
109
- & > img {
110
- width: 144px;
111
- }
112
- `,
113
- description: css`
114
- ${theme.cssMixins.rowCentered};
115
- margin-top: ${theme.spacing(10)};
116
- padding: ${theme.spacing(0, 2)};
117
- font-weight: 400;
118
- font-size: 16px;
119
- color: ${theme.palette.text.secondary};
120
- `,
121
- }
122
-
123
- const { envelopeKey, envelopeLastQueryTimeKey, envelopeDocuSignStatusKey } =
124
- useMemo(() => {
125
- const envelopeKey = `${poolInfo.pool.toLowerCase()}-${account?.toLowerCase()}`
126
- const envelopeLastQueryTimeKey = `${envelopeKey}-last-query-time`
127
- const envelopeDocuSignStatusKey = `${envelopeKey}-docuSign-status`
128
- return {
129
- envelopeKey,
130
- envelopeLastQueryTimeKey,
131
- envelopeDocuSignStatusKey,
132
- }
133
- }, [account, poolInfo.pool])
134
-
135
- // DocuSign GET requests to any specific URL can be called not more often than once every 15 minutes.
136
- // https://developers.docusign.com/platform/api-guidelines/#:~:text=Polling,not%20once%20every%2010%20minutes
137
- const checkGetDocSignatureStatusIsAvailable = useCallback(() => {
138
- const lastQueryTime = localStorage.getItem(envelopeLastQueryTimeKey)
139
- if (!lastQueryTime) {
140
- return true
141
- }
142
- const lastQueryTimeNumber = Number(lastQueryTime)
143
- const now = timeUtil.getUnixTimestamp()
144
- const diff = now - lastQueryTimeNumber
145
- const fifteenMinutes = 15 * 60
146
- return diff > fifteenMinutes
147
- }, [envelopeLastQueryTimeKey])
148
-
149
- useEffect(() => {
150
- setKYCCopy(JiaPoolCopies.verifyIdentity)
151
- const docuSignStatus = localStorage.getItem(envelopeDocuSignStatusKey)
152
- setDocSignatureStatus(docuSignStatus as DocSignatureStatus['status'])
153
- if (docuSignStatus === 'completed') {
154
- setKYCCopy(JiaPoolCopies.docUnderReview)
155
- return
156
- }
157
-
158
- const fetchData = async () => {
159
- try {
160
- if (kycProvider && kycPool && account && chainId) {
161
- setLoadingType('verificationStatus')
162
- await IdentityService.onboard(
163
- account,
164
- code as string,
165
- kycPool as string,
166
- chainId,
167
- isDev,
168
- )
169
- }
170
- } catch (e) {
171
- try {
172
- setAuthError(e)
173
- setKYCCopy(JiaPoolCopies.signInRequired)
174
- } catch (e) {
175
- // The repeated call will throw an error of 401, so we can ignore it.
176
- console.log(e)
177
- }
178
- }
179
-
180
- try {
181
- if (account && chainId) {
182
- setLoadingType('verificationStatus')
183
- const verificationStatus =
184
- await IdentityService.getVerificationStatus(
185
- account,
186
- poolInfo.pool,
187
- chainId,
188
- isDev,
189
- )
190
- setKYCVerifyStatus(verificationStatus)
191
- if (verificationStatus.isVerified) {
192
- const envelopeId = localStorage.getItem(envelopeKey)
193
- if (!envelopeId) {
194
- setKYCCopy(JiaPoolCopies.emailSignatureLink)
195
- } else if (!checkGetDocSignatureStatusIsAvailable()) {
196
- setKYCCopy(JiaPoolCopies.resendSignatureLink)
197
- } else {
198
- const { status } = await IdentityService.getDocSignatureStatus(
199
- envelopeId,
200
- chainId,
201
- isDev,
202
- )
203
- localStorage.setItem(
204
- envelopeLastQueryTimeKey,
205
- String(timeUtil.getUnixTimestamp()),
206
- )
207
- localStorage.setItem(envelopeDocuSignStatusKey, status)
208
- setDocSignatureStatus(status)
209
- if (status === 'completed') {
210
- setKYCCopy(JiaPoolCopies.docUnderReview)
211
- // For voided and declined status, we need to send a new link
212
- } else if (['voided', 'declined'].includes(status)) {
213
- localStorage.removeItem(envelopeKey)
214
- localStorage.removeItem(envelopeLastQueryTimeKey)
215
- setKYCCopy(JiaPoolCopies.emailSignatureLink)
216
- } else {
217
- setKYCCopy(JiaPoolCopies.resendSignatureLink)
218
- }
219
- }
220
- }
221
- }
222
- } catch (e: unknown) {
223
- try {
224
- setAuthError(e)
225
- setKYCCopy(JiaPoolCopies.signInRequired)
226
- } catch (e) {
227
- console.error(e)
228
- dispatch(
229
- setError({
230
- errorMessage: 'Something went wrong, please try again later.',
231
- }),
232
- )
233
- }
234
- } finally {
235
- setLoadingType(undefined)
236
- }
237
- }
238
- fetchData()
239
- }, [
240
- account,
241
- chainId,
242
- checkGetDocSignatureStatusIsAvailable,
243
- code,
244
- dispatch,
245
- envelopeDocuSignStatusKey,
246
- envelopeKey,
247
- envelopeLastQueryTimeKey,
248
- isDev,
249
- kycPool,
250
- kycProvider,
251
- poolInfo.pool,
252
- setAuthError,
253
- isWalletOwnershipVerified,
254
- ])
255
-
256
- useEffect(() => {
257
- if (
258
- authError &&
259
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
260
- [4001, 'ACTION_REJECTED'].includes((authError as any).code)
261
- ) {
262
- dispatch(
263
- setError({
264
- errorMessage: 'User has rejected the transaction.',
265
- }),
266
- )
267
- }
268
- }, [authError, dispatch])
269
-
270
- const approveLender = async () => {
271
- if (docSignatureCompleted) {
272
- handleClose()
273
- return
274
- }
275
-
276
- const { isNotOnboarded, isVerified } = KYCVerifyStatus || {}
277
-
278
- if (!isVerified) {
279
- const issuerId = CHAINS[chainId!].isTestnet
280
- ? '53a66b32-583e-40e7-ba90-baf516d2cadd'
281
- : '5557baf5-d3c2-4c80-b522-c05a11c6e586'
282
- const baseUrl = configUtil.getKYCProviderBaseUrl(KYCProvider, chainId!)
283
- const originUrl = window.location.href.split('?')[0]
284
- const redirectUrl = `${originUrl}?poolName=${poolInfo.poolName}&chainId=${poolInfo.chainId}&poolType=${poolInfo.poolType}&kycProvider=${KYCProvider}&kycPool=${poolInfo.pool}`
285
- const providerAuthorizeUrl = `${baseUrl}/#/authorize?issuerId=${issuerId}&scope=details&details=verification&redirectUrl=${redirectUrl}`
286
- window.location.href = isNotOnboarded ? providerAuthorizeUrl : baseUrl
287
- } else {
288
- const envelopeId = localStorage.getItem(envelopeKey)
289
- try {
290
- setLoadingType('sendDocSignatureLink')
291
- if (!envelopeId) {
292
- const { envelopeId } = await IdentityService.requestDocSignature(
293
- account!,
294
- chainId!,
295
- isDev,
296
- )
297
- localStorage.setItem(envelopeKey, envelopeId)
298
- localStorage.setItem(
299
- envelopeLastQueryTimeKey,
300
- String(timeUtil.getUnixTimestamp()),
301
- )
302
- setOpenSnackBar(true)
303
- setKYCCopy(JiaPoolCopies.resendSignatureLink)
304
- } else {
305
- await IdentityService.resendDocSignatureLink(
306
- envelopeId,
307
- chainId!,
308
- isDev,
309
- )
310
- setOpenSnackBar(true)
311
- }
312
- } catch (e: unknown) {
313
- try {
314
- const { envelopeId } = await IdentityService.requestDocSignature(
315
- account!,
316
- chainId!,
317
- isDev,
318
- )
319
- localStorage.setItem(envelopeKey, envelopeId)
320
- localStorage.setItem(
321
- envelopeLastQueryTimeKey,
322
- String(timeUtil.getUnixTimestamp()),
323
- )
324
- setOpenSnackBar(true)
325
- setKYCCopy(JiaPoolCopies.resendSignatureLink)
326
- } catch (e) {
327
- setAuthError(e)
328
- setKYCCopy(JiaPoolCopies.signInRequired)
329
- }
330
- } finally {
331
- setLoadingType(undefined)
332
- }
333
- }
334
- }
335
-
336
- const getEmailLinkSentSnackbar = () => (
337
- <HumaSnackBar
338
- open={openSnackBar}
339
- title='Signature Link Sent'
340
- message='The secure signature session link has been sent to you via email.'
341
- severity='success'
342
- onClose={() => setOpenSnackBar(false)}
343
- />
344
- )
345
-
346
- if (!loadingType) {
347
- return (
348
- <WrapperModal title={kycCopy.title}>
349
- <Box css={styles.iconWrapper}>
350
- <img src={ApproveLenderImg} alt='approve-lender' />
351
- </Box>
352
- <Box css={styles.description}>{kycCopy.description}</Box>
353
- {Boolean(kycCopy.buttonText) && (
354
- <BottomButton variant='contained' onClick={approveLender}>
355
- {kycCopy.buttonText}
356
- </BottomButton>
357
- )}
358
- {getEmailLinkSentSnackbar()}
359
- </WrapperModal>
360
- )
361
- }
362
-
363
- return (
364
- <LoadingModal
365
- title='Lender Approval'
366
- description={LoadingCopiesByType[loadingType].description}
367
- />
368
- )
369
- }
@@ -1,31 +0,0 @@
1
- import { PoolInfoType } from '@huma-finance/shared'
2
- import React from 'react'
3
-
4
- import { EvaluationEA } from './EvaluationEA'
5
- import { EvaluationKYC } from './EvaluationKYC'
6
-
7
- type Props = {
8
- poolInfo: PoolInfoType
9
- handleClose: () => void
10
- handleApproveSuccess: () => void
11
- }
12
-
13
- export function Evaluation({
14
- poolInfo,
15
- handleClose,
16
- handleApproveSuccess,
17
- }: Props): React.ReactElement | null {
18
- const lenderApprovalProvider = poolInfo.extra?.lenderApprovalProvider
19
- const isKYC = lenderApprovalProvider?.type === 'KYC'
20
-
21
- if (isKYC) {
22
- return <EvaluationKYC poolInfo={poolInfo} handleClose={handleClose} />
23
- }
24
-
25
- return (
26
- <EvaluationEA
27
- poolInfo={poolInfo}
28
- handleApproveSuccess={handleApproveSuccess}
29
- />
30
- )
31
- }
@@ -1,47 +0,0 @@
1
- import {
2
- CHAIN_TYPE,
3
- CloseModalOptions,
4
- NETWORK_TYPE,
5
- PoolInfoV2,
6
- } from '@huma-finance/shared'
7
- import React from 'react'
8
-
9
- import { Campaign } from '.'
10
- import { PersonaEvaluation } from '../components/PersonaEvaluation'
11
- import { SecuritizeEvaluation } from '../components/SecuritizeEvaluation'
12
-
13
- type Props = {
14
- poolInfo: PoolInfoV2
15
- networkType: NETWORK_TYPE
16
- campaign?: Campaign
17
- documentHash?: string
18
- handleClose: (options?: CloseModalOptions) => void
19
- }
20
-
21
- export function Evaluation({
22
- poolInfo,
23
- networkType,
24
- campaign,
25
- documentHash,
26
- handleClose,
27
- }: Props): React.ReactElement | null {
28
- if (poolInfo.KYC?.Securitize) {
29
- return (
30
- <SecuritizeEvaluation poolInfo={poolInfo} handleClose={handleClose} />
31
- )
32
- }
33
- if (poolInfo.KYC?.Persona && documentHash) {
34
- return (
35
- <PersonaEvaluation
36
- poolInfo={poolInfo}
37
- handleClose={handleClose}
38
- campaign={campaign}
39
- networkType={networkType}
40
- chainType={CHAIN_TYPE.EVM}
41
- documentHash={documentHash}
42
- />
43
- )
44
- }
45
-
46
- return null
47
- }
@@ -1,35 +0,0 @@
1
- import {
2
- CHAIN_TYPE,
3
- getEvmNetworkType,
4
- PoolInfoV2,
5
- TrancheType,
6
- } from '@huma-finance/shared'
7
- import React from 'react'
8
-
9
- import { ApproveLenderBase } from '../components/ApproveLenderBase'
10
-
11
- type Props = {
12
- poolInfo: PoolInfoV2
13
- isUniTranche: boolean
14
- documentHash?: string
15
- changeTranche: (tranche: TrancheType) => void
16
- }
17
-
18
- export function ApproveLender({
19
- poolInfo,
20
- isUniTranche,
21
- documentHash,
22
- changeTranche,
23
- }: Props): React.ReactElement {
24
- return (
25
- <ApproveLenderBase
26
- juniorTrancheVault={poolInfo.juniorTrancheVault}
27
- seniorTrancheVault={poolInfo.seniorTrancheVault}
28
- isUniTranche={isUniTranche}
29
- documentHash={documentHash}
30
- chainType={CHAIN_TYPE.EVM}
31
- networkType={getEvmNetworkType(poolInfo.chainId)}
32
- changeTranche={changeTranche}
33
- />
34
- )
35
- }
@@ -1,135 +0,0 @@
1
- import {
2
- CloseModalOptions,
3
- FEATHERS_TO_HUMA_RATIO,
4
- formatNumber,
5
- isEmpty,
6
- } from '@huma-finance/shared'
7
- import { txAtom } from '@huma-finance/web-shared'
8
- import { Box, css, useTheme } from '@mui/material'
9
- import { useResetAtom } from 'jotai/utils'
10
- import React, { useCallback } from 'react'
11
- import { useDispatch } from 'react-redux'
12
-
13
- import { useAppSelector } from '../hooks/useRedux'
14
- import { resetState } from '../store/widgets.reducers'
15
- import { selectWidgetState } from '../store/widgets.selectors'
16
- import { BottomButton } from './BottomButton'
17
- import { CongratulationsIcon, HumaPointsIcon, RibbonIcon } from './icons'
18
-
19
- type Props = {
20
- lpConfig: { withdrawalLockupPeriodDays?: number }
21
- handleAction: (options?: CloseModalOptions) => void
22
- }
23
-
24
- export function PointsEarned({
25
- lpConfig,
26
- handleAction,
27
- }: Props): React.ReactElement {
28
- const theme = useTheme()
29
- const dispatch = useDispatch()
30
- const reset = useResetAtom(txAtom)
31
- const { pointsAccumulated } = useAppSelector(selectWidgetState)
32
- const hasPointsAccumulated =
33
- !isEmpty(pointsAccumulated) && pointsAccumulated! > 0
34
- const lockupMonths = Math.round(
35
- (lpConfig.withdrawalLockupPeriodDays ?? 0) / 30,
36
- )
37
- const monthText =
38
- lockupMonths > 1 ? `${lockupMonths} months` : `${lockupMonths} month`
39
-
40
- const rewardsAccumulated = pointsAccumulated
41
- ? pointsAccumulated / FEATHERS_TO_HUMA_RATIO
42
- : undefined
43
-
44
- const handleCloseModal = useCallback(() => {
45
- reset()
46
- dispatch(resetState())
47
- handleAction({ isSuccess: true })
48
- }, [dispatch, handleAction, reset])
49
-
50
- const styles = {
51
- wrapper: css`
52
- height: 518px;
53
- position: relative;
54
- `,
55
- congrats: css`
56
- margin: ${theme.spacing(-4, -4.5, 0, -4.5)};
57
- `,
58
- ribbon: css`
59
- position: relative;
60
- ${theme.cssMixins.rowHCentered};
61
- font-weight: 700;
62
- margin-top: ${theme.spacing(-8)};
63
- color: ${theme.palette.text.primary};
64
- font-size: 20px;
65
- line-height: 160%;
66
- letter-spacing: 0.15px;
67
- `,
68
- ribbonContent: css`
69
- ${theme.cssMixins.rowVCentered};
70
- position: absolute;
71
- top: ${theme.spacing(1)};
72
-
73
- svg {
74
- margin-right: ${theme.spacing(1)};
75
- }
76
- `,
77
- entirePoints: css`
78
- color: ${theme.palette.text.tertiary};
79
- text-align: center;
80
- font-weight: 700;
81
- font-size: 20px;
82
- line-height: 160%;
83
- letter-spacing: 0.15px;
84
- margin-top: ${theme.spacing(7)};
85
- `,
86
- entirePointsDetails: css`
87
- color: ${theme.palette.text.tertiary};
88
- text-align: center;
89
- font-weight: 400;
90
- font-size: 16px;
91
- line-height: 150%;
92
- letter-spacing: 0.15px;
93
- margin-top: ${theme.spacing(4)};
94
- `,
95
- everyday: css`
96
- font-weight: 700;
97
- `,
98
- }
99
-
100
- return (
101
- <Box css={styles.wrapper}>
102
- <Box css={styles.congrats}>
103
- <CongratulationsIcon />
104
- </Box>
105
- <Box css={styles.ribbon}>
106
- <RibbonIcon />
107
- <Box css={styles.ribbonContent}>
108
- <HumaPointsIcon />
109
- <Box>
110
- {hasPointsAccumulated
111
- ? `${formatNumber(rewardsAccumulated)} $HUMA`
112
- : 'Rewards earned'}
113
- </Box>
114
- </Box>
115
- </Box>
116
- <Box css={styles.entirePoints}>
117
- {hasPointsAccumulated ? (
118
- <>
119
- <Box>Congratulations,</Box>
120
- <Box>you've earned {rewardsAccumulated} $HUMA</Box>
121
- </>
122
- ) : (
123
- <Box>Congratulations on joining the Huma Protocol!</Box>
124
- )}
125
- </Box>
126
- <Box css={styles.entirePointsDetails}>
127
- You'll earn rewards <span css={styles.everyday}>everyday</span> for{' '}
128
- {monthText} straight.
129
- </Box>
130
- <BottomButton variant='contained' onClick={handleCloseModal}>
131
- GREAT
132
- </BottomButton>
133
- </Box>
134
- )
135
- }
@@ -1,53 +0,0 @@
1
- import { Box, css, Typography, useTheme } from '@mui/material'
2
- import React from 'react'
3
- import { ApproveLenderImg } from './images'
4
-
5
- type Props = {
6
- description?: string
7
- }
8
-
9
- export function SignIn({ description }: Props): React.ReactElement {
10
- const theme = useTheme()
11
- const styles = {
12
- wrapper: css`
13
- height: 518px;
14
- position: relative;
15
- `,
16
- header: css`
17
- ${theme.cssMixins.rowHCentered};
18
- margin-top: ${theme.spacing(-0.5)};
19
- `,
20
- icon: css`
21
- ${theme.cssMixins.rowHCentered};
22
- margin-top: ${theme.spacing(12)};
23
- margin-right: ${theme.spacing(4)};
24
- & > img {
25
- width: 170px;
26
- }
27
- `,
28
- content: css`
29
- ${theme.cssMixins.rowHCentered};
30
- margin-top: ${theme.spacing(4)};
31
- font-weight: 400;
32
- font-size: 16px;
33
- line-height: 24px;
34
- color: ${theme.palette.text.secondary};
35
- margin-bottom: ${theme.spacing(8)};
36
- `,
37
- }
38
-
39
- return (
40
- <Box css={styles.wrapper}>
41
- <Typography variant='h6' css={styles.header}>
42
- Sign In
43
- </Typography>
44
- <Box css={styles.icon}>
45
- <img src={ApproveLenderImg} alt='approve-lender' />
46
- </Box>
47
- <Box css={styles.content}>
48
- {description ??
49
- 'Please sign in to verify your ownership of the wallet.'}
50
- </Box>
51
- </Box>
52
- )
53
- }