-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: create dialog on remember wallet
Show dialog when enabling remember wallet to better inform users about what the feature is. The dialog is an element itself called EnableRememberWalletDialog. This dialog is (also) controlled by a new config variable called hideEnableRememberWalletDialog. Also created DisableRememberWalletDialog component (just a refactor).
- Loading branch information
1 parent
6f207ca
commit 7789b86
Showing
4 changed files
with
88 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...eb/src/routes/settings/components/manage-accounts/dialogs/disableRememberWalletDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
import { Dialog, DialogButtons } from '@/components/dialog/dialog'; | ||
import { Button } from '@/components/forms'; | ||
|
||
type Props = { | ||
open: boolean; | ||
onClose: () => void; | ||
onConfirm: () => void; | ||
} | ||
export const DisableRememberWalletDialog = ({ open, onClose, onConfirm }: Props) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Dialog title={t('newSettings.appearance.remebmerWallet.warningTitle')} medium onClose={onClose} open={open}> | ||
<p>{t('newSettings.appearance.remebmerWallet.warning')}</p> | ||
<DialogButtons> | ||
<Button primary onClick={onConfirm}>{t('dialog.confirm')}</Button> | ||
<Button secondary onClick={onClose}>{t('dialog.cancel')}</Button> | ||
</DialogButtons> | ||
</Dialog> | ||
); | ||
}; |
48 changes: 48 additions & 0 deletions
48
...web/src/routes/settings/components/manage-accounts/dialogs/enableRememberWalletDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Dialog, DialogButtons } from '@/components/dialog/dialog'; | ||
import { Button, Checkbox } from '@/components/forms'; | ||
import { useLoad } from '@/hooks/api'; | ||
import { getConfig, setConfig } from '@/utils/config'; | ||
|
||
type Props = { | ||
open: boolean; | ||
onClose: () => void; | ||
} | ||
export const EnableRememberWalletDialog = ({ open, onClose }: Props) => { | ||
const { t } = useTranslation(); | ||
const config = useLoad(getConfig); | ||
const [checked, setChecked] = useState(false); | ||
const [shouldNotShowDialog, setShouldNotShowDialog] = useState(false); | ||
|
||
useEffect(() => { | ||
if (config && config.frontend) { | ||
setShouldNotShowDialog(config.frontend.hideEnableRememberWalletDialog); | ||
} | ||
}, [config]); | ||
|
||
if (shouldNotShowDialog) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Dialog title={t('newSettings.appearance.remebmerWallet.enable.title')} medium open={open}> | ||
<p>{t('newSettings.appearance.remebmerWallet.enable.description')}</p> | ||
<Checkbox | ||
id="dont_show_enable_remember_wallet" | ||
label={t('buy.info.skip')} | ||
checked={checked} | ||
onChange={(e) => setChecked(e.target.checked)} | ||
/> | ||
<DialogButtons> | ||
<Button primary onClick={() => { | ||
onClose(); | ||
if (checked) { | ||
setConfig({ frontend: { hideEnableRememberWalletDialog: true } }); | ||
setShouldNotShowDialog(true); | ||
} | ||
}}>{t('button.ok')}</Button> | ||
</DialogButtons> | ||
</Dialog> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters