+ fill(m.phone.removeDialog.description, { phoneNumber: stringToFormattedPhoneString(phone.value) })
+ }
+ actionLabel={m.phone.removeDialog.confirm}
+ cancelLabel={m.phone.removeDialog.cancel}
+ onConfirm={phone => onRemovePhone(phone.id)}
+ />
) : null}
>
);
diff --git a/packages/ui/src/mosaic/features/user-profile/user-profile-account-section/user-profile-remove-email.dialog.tsx b/packages/ui/src/mosaic/features/user-profile/user-profile-account-section/user-profile-remove-email.dialog.tsx
deleted file mode 100644
index 6857f2a8ec7..00000000000
--- a/packages/ui/src/mosaic/features/user-profile/user-profile-account-section/user-profile-remove-email.dialog.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import * as stylex from '@stylexjs/stylex';
-import type { ReactNode } from 'react';
-
-import { Button } from '../../../components/button';
-import { Dialog } from '../../../components/dialog';
-import { Heading } from '../../../components/heading';
-import { Text } from '../../../components/text';
-import { rich } from '../../../utils/messages';
-import { styles } from '../user-profile-profile-panel.styles';
-import { userProfileAccountSectionMessages as m } from './user-profile-account-section.messages';
-
-const components = {
- strong: (children?: ReactNode) => {children},
-};
-
-export interface UserProfileRemoveEmailDialogProps {
- emailAddress: string;
- open: boolean;
- onOpenChange: (open: boolean) => void;
- onConfirm: () => void;
-}
-
-export function UserProfileRemoveEmailDialog({
- emailAddress,
- open,
- onOpenChange,
- onConfirm,
-}: UserProfileRemoveEmailDialogProps) {
- return (
-
-
- }>{m.email.removeDialog.title}
- }>
- {rich(m.email.removeDialog.description, { values: { emailAddress }, components })}
-
-
- }>{m.email.removeDialog.cancel}
-
-
-
-
- );
-}
diff --git a/packages/ui/src/mosaic/features/user-profile/user-profile-account-section/user-profile-remove-phone.dialog.tsx b/packages/ui/src/mosaic/features/user-profile/user-profile-account-section/user-profile-remove-phone.dialog.tsx
deleted file mode 100644
index 2c496a1cbeb..00000000000
--- a/packages/ui/src/mosaic/features/user-profile/user-profile-account-section/user-profile-remove-phone.dialog.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import * as stylex from '@stylexjs/stylex';
-import type { ReactNode } from 'react';
-
-import { Button } from '../../../components/button';
-import { Dialog } from '../../../components/dialog';
-import { Heading } from '../../../components/heading';
-import { Text } from '../../../components/text';
-import { rich } from '../../../utils/messages';
-import { styles } from '../user-profile-profile-panel.styles';
-import { userProfileAccountSectionMessages as m } from './user-profile-account-section.messages';
-
-const components = {
- strong: (children?: ReactNode) => {children},
-};
-
-export interface UserProfileRemovePhoneDialogProps {
- phoneNumber: string;
- open: boolean;
- onOpenChange: (open: boolean) => void;
- onConfirm: () => void;
-}
-
-export function UserProfileRemovePhoneDialog({
- phoneNumber,
- open,
- onOpenChange,
- onConfirm,
-}: UserProfileRemovePhoneDialogProps) {
- return (
-
-
- }>{m.phone.removeDialog.title}
- }>
- {rich(m.phone.removeDialog.description, { values: { phoneNumber }, components })}
-
-
- }>{m.phone.removeDialog.cancel}
-
-
-
-
- );
-}
diff --git a/packages/ui/src/mosaic/features/user-profile/user-profile-account-section/user-profile-verify-email-link.dialog.tsx b/packages/ui/src/mosaic/features/user-profile/user-profile-account-section/user-profile-verify-email-link.dialog.tsx
index af8a25f61f7..765477b9280 100644
--- a/packages/ui/src/mosaic/features/user-profile/user-profile-account-section/user-profile-verify-email-link.dialog.tsx
+++ b/packages/ui/src/mosaic/features/user-profile/user-profile-account-section/user-profile-verify-email-link.dialog.tsx
@@ -1,5 +1,4 @@
import * as stylex from '@stylexjs/stylex';
-import type { ReactNode } from 'react';
import { Banner } from '../../../components/banner';
import { Button } from '../../../components/button';
@@ -8,15 +7,11 @@ import type { DialogTriggerProps } from '../../../components/dialog';
import { Dialog } from '../../../components/dialog';
import { Spinner } from '../../../components/spinner';
import { Text } from '../../../components/text';
-import { rich } from '../../../utils/messages';
+import { fill, rich } from '../../../utils/messages';
import { styles as profileStyles } from '../user-profile-profile-panel.styles';
import { userProfileVerifyEmailLinkMessages as m } from './user-profile-verify-email-link.messages';
import { styles } from './user-profile-verify-email-link.styles';
-const components = {
- strong: (children?: ReactNode) => {children},
-};
-
export interface UserProfileVerifyEmailLinkDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
@@ -70,7 +65,7 @@ export function UserProfileVerifyEmailLinkDialog({
{m.waiting}
- {rich(m.description, { values: { emailAddress }, components })}
+ {fill(m.description, { emailAddress })}
diff --git a/packages/ui/src/mosaic/features/user-profile/user-profile-remove-connected-account.dialog.tsx b/packages/ui/src/mosaic/features/user-profile/user-profile-remove-connected-account.dialog.tsx
deleted file mode 100644
index c1e0e50e685..00000000000
--- a/packages/ui/src/mosaic/features/user-profile/user-profile-remove-connected-account.dialog.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import { Banner } from '../../components/banner';
-import { Button, SubmitButton } from '../../components/button';
-import { Dialog } from '../../components/dialog';
-import { Heading } from '../../components/heading';
-import { Text } from '../../components/text';
-import { fill } from '../../utils/messages';
-import { userProfileConnectedAccountsMessages as m } from './user-profile-connected-accounts.messages';
-
-export interface UserProfileRemoveConnectedAccountDialogProps {
- provider: string;
- open: boolean;
- onOpenChange: (open: boolean) => void;
- onConfirm: () => void;
- isPending?: boolean;
- errorMessage?: string;
-}
-
-export function UserProfileRemoveConnectedAccountDialog({
- provider,
- open,
- onOpenChange,
- onConfirm,
- isPending,
- errorMessage,
-}: UserProfileRemoveConnectedAccountDialogProps) {
- return (
-
-
- }>{m.removeDialog.title}
- }>
- {fill(m.removeDialog.description, { provider: provider })}
-
- {errorMessage ? (
-
- {errorMessage}
-
- ) : null}
-
- }
- >
- {m.removeDialog.cancel}
-
-
- {m.removeDialog.confirm}
-
-
-
-
- );
-}
diff --git a/packages/ui/src/mosaic/features/user-profile/user-profile-remove-web3-wallet.dialog.tsx b/packages/ui/src/mosaic/features/user-profile/user-profile-remove-web3-wallet.dialog.tsx
deleted file mode 100644
index d9c149c6cb3..00000000000
--- a/packages/ui/src/mosaic/features/user-profile/user-profile-remove-web3-wallet.dialog.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { Banner } from '../../components/banner';
-import { Button, SubmitButton } from '../../components/button';
-import { Dialog } from '../../components/dialog';
-import { Heading } from '../../components/heading';
-import { Text } from '../../components/text';
-import { fill } from '../../utils/messages';
-import { userProfileWeb3WalletsMessages as m } from './user-profile-web3-wallets.messages';
-
-export interface UserProfileRemoveWeb3WalletDialogProps {
- address: string;
- isVerified: boolean;
- open: boolean;
- onOpenChange: (open: boolean) => void;
- onConfirm: () => void;
- isPending?: boolean;
- errorMessage?: string;
-}
-
-export function UserProfileRemoveWeb3WalletDialog({
- address,
- isVerified,
- open,
- onOpenChange,
- onConfirm,
- isPending,
- errorMessage,
-}: UserProfileRemoveWeb3WalletDialogProps) {
- return (
-
-
- }>{m.removeDialog.title}
- }>
- {fill(m.removeDialog.description, { wallet: address })}
-
- {isVerified ? {m.removeDialog.signInWarning} : null}
- {errorMessage ? (
-
- {errorMessage}
-
- ) : null}
-
- }
- >
- {m.removeDialog.cancel}
-
-
- {m.removeDialog.confirm}
-
-
-
-
- );
-}
diff --git a/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallet-row.view.tsx b/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallet-row.view.tsx
index cb23bbda5c9..e552a47b108 100644
--- a/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallet-row.view.tsx
+++ b/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallet-row.view.tsx
@@ -1,5 +1,4 @@
import * as stylex from '@stylexjs/stylex';
-import { useState } from 'react';
import { Badge } from '../../components/badge';
import { Button } from '../../components/button';
@@ -8,7 +7,6 @@ import { Section } from '../../components/section';
import { fill } from '../../utils/messages';
import type { UserProfileMenuAction } from './user-profile-action-menu';
import { UserProfileActionMenu } from './user-profile-action-menu';
-import { UserProfileRemoveWeb3WalletDialog } from './user-profile-remove-web3-wallet.dialog';
import { userProfileWeb3WalletsMessages as m } from './user-profile-web3-wallets.messages';
import { styles } from './user-profile-web3-wallets.styles';
import type { UserProfileWeb3Provider, UserProfileWeb3Wallet } from './user-profile-web3-wallets-section.view';
@@ -22,9 +20,8 @@ export function UserProfileWeb3WalletRowView({
wallet: UserProfileWeb3Wallet | UserProfileWeb3Provider;
onConnect?: (id: string) => void;
onSetPrimary?: (id: string) => void;
- onRemove?: (id: string) => void;
+ onRemove?: (wallet: UserProfileWeb3Wallet) => void;
}) {
- const [open, setOpen] = useState(false);
const iconUrl = wallet.iconUrl?.trim();
const linkedWallet = 'address' in wallet ? wallet : undefined;
const address = linkedWallet?.address;
@@ -35,7 +32,7 @@ export function UserProfileWeb3WalletRowView({
actions.push({ label: m.setPrimary, onClick: () => onSetPrimary(wallet.id) });
}
if (linkedWallet && onRemove && linkedWallet.canRemove !== false) {
- actions.push({ label: m.remove, color: 'negative', onClick: () => setOpen(true) });
+ actions.push({ label: m.remove, color: 'negative', onClick: () => onRemove(linkedWallet) });
}
return (
@@ -99,19 +96,7 @@ export function UserProfileWeb3WalletRowView({
- {linkedWallet && onRemove && linkedWallet.canRemove !== false ? (
- onRemove(wallet.id)}
- isPending={linkedWallet.isRemoving}
- errorMessage={linkedWallet.removalError}
- />
- ) : null}
-
+ />
) : null}
diff --git a/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallets-section.view.tsx b/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallets-section.view.tsx
index 84d2671f18a..ce30a1fd448 100644
--- a/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallets-section.view.tsx
+++ b/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallets-section.view.tsx
@@ -1,4 +1,9 @@
+import { useMemo } from 'react';
+
+import { truncateWithEndVisible } from '../../../utils/truncateTextWithEndVisible';
+import { Confirmation } from '../../blocks/confirmation';
import { Section } from '../../components/section';
+import { fill } from '../../utils/messages';
import { UserProfileWeb3WalletRowView } from './user-profile-web3-wallet-row.view';
import { userProfileWeb3WalletsMessages as m } from './user-profile-web3-wallets.messages';
@@ -17,8 +22,6 @@ export interface UserProfileWeb3Wallet {
isPrimary?: boolean;
isVerified: boolean;
canRemove?: boolean;
- isRemoving?: boolean;
- removalError?: string;
primaryError?: string;
}
@@ -27,7 +30,7 @@ export interface UserProfileWeb3WalletsSectionViewProps {
availableProviders?: UserProfileWeb3Provider[];
onConnect?: (id: string) => void;
onSetPrimary?: (id: string) => void;
- onRemove?: (id: string) => void;
+ onRemove?: (id: string) => void | Promise;
}
export function UserProfileWeb3WalletsSectionView({
@@ -37,32 +40,51 @@ export function UserProfileWeb3WalletsSectionView({
onSetPrimary,
onRemove,
}: UserProfileWeb3WalletsSectionViewProps) {
- if (wallets.length === 0 && (availableProviders.length === 0 || !onConnect)) {
- return null;
- }
+ const removeWallet = useMemo(() => Confirmation.createHandle(), []);
+ const hasRows = wallets.length > 0 || (availableProviders.length > 0 && Boolean(onConnect));
return (
-
- {m.title}
-
- {wallets.map(wallet => (
-
- ))}
- {onConnect
- ? availableProviders.map(provider => (
+ <>
+ {hasRows ? (
+
+ {m.title}
+
+ {wallets.map(wallet => (
removeWallet.open(wallet) : undefined}
/>
- ))
- : null}
-
-
+ ))}
+ {onConnect
+ ? availableProviders.map(provider => (
+
+ ))
+ : null}
+
+
+ ) : null}
+ {onRemove ? (
+ onRemove(wallet.id)}
+ />
+ ) : null}
+ >
);
}
+
+function describeWalletRemoval(wallet: UserProfileWeb3Wallet) {
+ return fill(wallet.isVerified ? m.removeDialog.verifiedDescription : m.removeDialog.description, {
+ wallet: truncateWithEndVisible(wallet.address, 13, 4),
+ });
+}
diff --git a/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallets.messages.ts b/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallets.messages.ts
index 3ffe00aae49..451dd43ef11 100644
--- a/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallets.messages.ts
+++ b/packages/ui/src/mosaic/features/user-profile/user-profile-web3-wallets.messages.ts
@@ -10,9 +10,9 @@ export const userProfileWeb3WalletsMessages = {
removeDialog: {
title: 'Remove wallet?',
description: '{wallet} will be removed from this account.',
- signInWarning: 'You will no longer be able to sign in using this web3 wallet.',
+ verifiedDescription:
+ '{wallet} will be removed from this account. You will no longer be able to sign in using this web3 wallet.',
confirm: 'Remove',
- pending: 'Removing wallet',
cancel: 'Cancel',
},
};