|
1 | | -import React, { useMemo } from 'react'; |
| 1 | +import React, { useContext, useEffect } from 'react'; |
2 | 2 | import { useTranslation } from 'react-i18next'; |
| 3 | +import { useAtomValue } from 'jotai'; |
| 4 | +import { noOp } from 'wallet-common-helpers'; |
3 | 5 |
|
4 | 6 | import Button from '@popup/popupX/shared/Button'; |
5 | | -import IdCard from '@popup/popupX/shared/IdCard'; |
| 7 | +import { ConfirmedIdCard, RejectedIdCard, PendingIdCard } from '@popup/popupX/shared/IdCard'; |
6 | 8 | import Page from '@popup/popupX/shared/Page'; |
7 | 9 | import Text from '@popup/popupX/shared/Text'; |
8 | | -import { useAtomValue } from 'jotai'; |
9 | | -import { identitiesAtom, identityProvidersAtom } from '@popup/store/identity'; |
| 10 | +import { identitiesAtomWithLoading } from '@popup/store/identity'; |
10 | 11 | import { CreationStatus } from '@shared/storage/types'; |
| 12 | +import { fullscreenPromptContext } from '@popup/popupX/page-layouts/FullscreenPromptLayout'; |
| 13 | +import { absoluteRoutes } from '@popup/popupX/constants/routes'; |
11 | 14 |
|
12 | 15 | export default function IdIssuanceSubmitted() { |
13 | 16 | const { t } = useTranslation('x', { keyPrefix: 'idIssuance.submitted' }); |
14 | | - const providers = useAtomValue(identityProvidersAtom); |
15 | | - const identity = useAtomValue(identitiesAtom).slice(-1)[0]; |
16 | | - const provider = useMemo( |
17 | | - () => providers.find((p) => p.ipInfo.ipIdentity === identity.providerIndex), |
18 | | - [identity.providerIndex] |
19 | | - ); |
| 17 | + const { loading, value: identities } = useAtomValue(identitiesAtomWithLoading); |
| 18 | + const { setReturnLocation, withClose } = useContext(fullscreenPromptContext); |
| 19 | + |
| 20 | + useEffect(() => { |
| 21 | + setReturnLocation(absoluteRoutes.settings.identities.path); |
| 22 | + }, [setReturnLocation]); |
20 | 23 |
|
21 | | - if (provider === undefined) { |
| 24 | + if (loading) { |
22 | 25 | return null; |
23 | 26 | } |
24 | 27 |
|
25 | | - const providerName = provider.metadata.display ?? provider.ipInfo.ipDescription.name; |
| 28 | + const identity = identities.slice(-1)[0]; |
26 | 29 |
|
27 | 30 | return ( |
28 | 31 | <Page> |
29 | 32 | <Page.Top heading={t('title')} /> |
30 | 33 | <Text.Capture>{t('description')}</Text.Capture> |
31 | | - {identity.status === CreationStatus.Pending && ( |
32 | | - <IdCard className="m-t-20" idProviderName={providerName} identityName={identity.name} /> |
33 | | - )} |
34 | | - {identity.status === CreationStatus.Rejected && ( |
35 | | - <IdCard className="m-t-20" idProviderName={providerName} identityName={identity.name} /> |
36 | | - )} |
37 | | - {identity.status === CreationStatus.Confirmed && ( |
38 | | - <IdCard className="m-t-20" idProviderName={providerName} identityName={identity.name} /> |
39 | | - )} |
| 34 | + <div className="m-t-20"> |
| 35 | + {identity.status === CreationStatus.Pending && <PendingIdCard identity={identity} />} |
| 36 | + {identity.status === CreationStatus.Rejected && <RejectedIdCard identity={identity} />} |
| 37 | + {identity.status === CreationStatus.Confirmed && <ConfirmedIdCard identity={identity} />} |
| 38 | + </div> |
40 | 39 | <Page.Footer> |
41 | | - <Button.Main className="m-t-20" label={t('buttonContinue')} /> |
| 40 | + <Button.Main className="m-t-20" label={t('buttonContinue')} onClick={withClose(noOp)} /> |
42 | 41 | </Page.Footer> |
43 | 42 | </Page> |
44 | 43 | ); |
|
0 commit comments