This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
/
WalletUpdate.tsx
138 lines (122 loc) · 3.64 KB
/
WalletUpdate.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { images } from "app/assets/images";
import { Button } from "app/components/Button";
import { CircularProgressBar } from "app/components/CircularProgressBar";
import { Modal } from "app/components/Modal";
import { TabPanel, Tabs } from "app/components/Tabs";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
type WalletUpdateProps = {
isOpen: boolean;
onClose?: any;
onCancel?: any;
};
const { WalletUpdateBanner, WalletUpdateReadyBanner } = images.wallet.components.walletUpdate;
export const FirstStep = () => {
const { t } = useTranslation();
return (
<section data-testid="WalletUpdate__first-step">
<div className="mb-8 text-center">
<p className="text-sm text-theme-neutral-dark md:text-base">
{t("WALLETS.MODAL_WALLET_UPDATE.DESCRIPTION_1")}
</p>
</div>
</section>
);
};
export const SecondStep = () => {
const { t } = useTranslation();
return (
<section data-testid="WalletUpdate__second-step">
{/* TODO: Remove the class name `mb-8` in the functional code */}
<div className="flex w-2/5 mx-auto mb-8">
<div className="flex-1">
<p className="text-sm font-semibold text-theme-neutral-light">{t("COMMON.DOWNLOADED")}</p>
<p className="text-sm font-bold text-theme-neutral-dark">154 KB / 154 KB</p>
</div>
<div className="flex-1">
<div className="flex justify-center">
<CircularProgressBar value={78} size={50} strokeWidth={5} fontSize={0.8} />
</div>
</div>
</div>
</section>
);
};
export const ThirdStep = () => {
const { t } = useTranslation();
return (
<section data-testid="WalletUpdate__third-step">
<div className="mb-6 text-center">
<p className="text-sm text-theme-neutral-dark md:text-base">
{t("WALLETS.MODAL_WALLET_UPDATE.DESCRIPTION_2")}
</p>
</div>
</section>
);
};
export const WalletUpdate = ({ isOpen, onClose, onCancel }: WalletUpdateProps) => {
const { t } = useTranslation();
const [activeStep, setActiveStep] = useState(1);
const handleBack = () => {
setActiveStep(activeStep - 1);
};
const handleNext = () => {
setActiveStep(activeStep + 1);
};
return (
<Modal
title={t("WALLETS.MODAL_WALLET_UPDATE.TITLE", { version: "3.0.7" })}
image={
activeStep < 3 ? <WalletUpdateBanner className="my-8" /> : <WalletUpdateReadyBanner className="my-8" />
}
isOpen={isOpen}
onClose={onClose}
>
<Tabs activeId={activeStep}>
<TabPanel tabId={1}>
<FirstStep />
</TabPanel>
<TabPanel tabId={2}>
<SecondStep />
</TabPanel>
<TabPanel tabId={3}>
<ThirdStep />
</TabPanel>
<div className="flex flex-col justify-center space-x-0 sm:flex-row sm:space-x-3">
{activeStep === 1 && (
<>
<Button
variant="plain"
className="mt-2 sm:mt-0"
onClick={onCancel}
data-testid="WalletUpdate__cancel-button"
>
{t("COMMON.UPDATE_LATER")}
</Button>
<Button onClick={handleNext} data-testid="WalletUpdate__update-button">
{t("COMMON.UPDATE_NOW")}
</Button>
</>
)}
{/* TODO: Remove these buttons from the second step in the functional code */}
{activeStep === 2 && (
<>
<Button variant="plain" onClick={handleBack} data-testid="WalletUpdate__back-button">
{t("COMMON.BACK")}
</Button>
<Button onClick={handleNext} data-testid="WalletUpdate__continue-button">
{t("COMMON.CONTINUE")}
</Button>
</>
)}
{activeStep === 3 && (
<Button data-testid="WalletUpdate__install-button">{t("COMMON.INSTALL")}</Button>
)}
</div>
</Tabs>
</Modal>
);
};
WalletUpdate.defaultProps = {
isOpen: false,
};