Skip to content

Commit

Permalink
feat: delete profile (#5476)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Nardi <mark.nardi@iota.org>
  • Loading branch information
begonaalvarezd and MarkNerdi996 committed Dec 27, 2022
1 parent b4b18f7 commit fb2a772
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/mobile/features/features.ts
Expand Up @@ -94,7 +94,7 @@ const features = {
enabled: false,
},
deleteProfile: {
enabled: false,
enabled: true,
},
},
advanced: {
Expand Down
Expand Up @@ -4,9 +4,10 @@ import {
AppLockView,
ThemeView,
ChangePasswordView,
DeleteProfileView,
DiagnosticsView,
ErrorLogView,
LanguageView,
DiagnosticsView,
WalletFinderView,
} from '../../../../views/dashboard/drawers/profile/views/settings'
import { SettingsRoute } from '../../../routers'
Expand Down Expand Up @@ -45,26 +46,33 @@ export const SETTINGS_ROUTE_META = {
icon: SETTINGS_ICON_SVG[SettingsRoute.ChangePassword],
view: ChangePasswordView,
},
[SettingsRoute.DeleteProfile]: {
name: `views.settings.${SettingsRoute.DeleteProfile}.title`,
category: SettingsCategory.Security,
enabled: security?.[SettingsRoute.DeleteProfile]?.enabled,
icon: SETTINGS_ICON_SVG[SettingsRoute.DeleteProfile],
view: DeleteProfileView,
},
// Advanced
[SettingsRoute.WalletFinder]: {
name: `views.settings.${SettingsRoute.WalletFinder}.title`,
category: SettingsCategory.Advanced,
enabled: advanced?.[SettingsRoute.WalletFinder]?.enabled,
icon: SETTINGS_ICON_SVG[SettingsRoute.WalletFinder],
view: WalletFinderView,
},
[SettingsRoute.ErrorLog]: {
name: `views.settings.${SettingsRoute.ErrorLog}.title`,
category: SettingsCategory.Advanced,
enabled: advanced?.[SettingsRoute.ErrorLog]?.enabled,
icon: SETTINGS_ICON_SVG[SettingsRoute.ErrorLog],
view: ErrorLogView,
},
// Advanced
[SettingsRoute.Diagnostics]: {
name: `views.settings.${SettingsRoute.Diagnostics}.title`,
category: SettingsCategory.Advanced,
enabled: advanced?.[SettingsRoute.Diagnostics]?.enabled,
icon: SETTINGS_ICON_SVG[SettingsRoute.Diagnostics],
view: DiagnosticsView,
},
[SettingsRoute.WalletFinder]: {
name: `views.settings.${SettingsRoute.WalletFinder}.title`,
category: SettingsCategory.Advanced,
enabled: advanced?.[SettingsRoute.WalletFinder]?.enabled,
icon: SETTINGS_ICON_SVG[SettingsRoute.WalletFinder],
view: WalletFinderView,
},
}
@@ -0,0 +1,54 @@
<script lang="typescript">
import { deleteProfile } from '@contexts/settings'
import { localize } from '@core/i18n'
import { isSoftwareProfile } from '@core/profile'
import { setStrongholdPassword } from '@core/profile-manager'
import { Button, ButtonSize, ButtonVariant, PasswordInput, Text, TextType } from 'shared/components'
let isBusy = false
let error = ''
let password: string
async function handleDeleteClick(): Promise<void> {
isBusy = true
error = ''
try {
await setStrongholdPassword(password)
await deleteProfile()
} catch (err) {
error = localize(err.error)
}
isBusy = false
}
</script>

<div class="flex-1 flex flex-col justify-between space-y-4">
<div class="flex flex-col space-y-4">
<Text type={TextType.p}>{localize('popups.deleteProfile.confirmation')}</Text>
{#if $isSoftwareProfile}
<Text type={TextType.p} secondary classes="mb-3">{localize('popups.deleteProfile.typePassword')}</Text>
<PasswordInput
{error}
classes="w-full mb-8"
bind:value={password}
showRevealToggle
placeholder={localize('general.password')}
autofocus
submitHandler={handleDeleteClick}
disabled={isBusy}
/>
{/if}
</div>
<Button
disabled={(!password && $isSoftwareProfile) || isBusy}
size={ButtonSize.Medium}
classes="w-full"
onClick={handleDeleteClick}
variant={ButtonVariant.Warning}
{isBusy}
>
{localize('actions.delete')}
</Button>
</div>
@@ -1,7 +1,8 @@
export { default as AppLockView } from './AppLockView.svelte'
export { default as ChangePasswordView } from './ChangePasswordView.svelte'
export { default as ErrorLogView } from './ErrorLogView.svelte'
export { default as DeleteProfileView } from './DeleteProfileView.svelte'
export { default as DiagnosticsView } from './DiagnosticsView.svelte'
export { default as ErrorLogView } from './ErrorLogView.svelte'
export { default as LanguageView } from './LanguageView.svelte'
export { default as SettingsIndexView } from './SettingsIndexView.svelte'
export { default as ThemeView } from './ThemeView.svelte'
Expand Down

0 comments on commit fb2a772

Please sign in to comment.