From 593ad6bdb2b532eb89c5f176339f200c0a191ed1 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Fri, 30 Jun 2023 14:52:26 -0500 Subject: [PATCH] show type of account on account picker --- .changeset/grumpy-apes-tell.md | 5 ++++ src/components/account-info-badge.tsx | 27 +++++++++++++++++++++ src/components/page/account-switcher.tsx | 15 +++++++----- src/hooks/use-shareable-profile-id.ts | 4 +-- src/views/login/components/account-card.tsx | 19 +++++++++------ src/views/login/start.tsx | 2 +- src/views/user/about.tsx | 17 ++++++++++--- 7 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 .changeset/grumpy-apes-tell.md create mode 100644 src/components/account-info-badge.tsx diff --git a/.changeset/grumpy-apes-tell.md b/.changeset/grumpy-apes-tell.md new file mode 100644 index 000000000..e6a4d56e6 --- /dev/null +++ b/.changeset/grumpy-apes-tell.md @@ -0,0 +1,5 @@ +--- +"nostrudel": patch +--- + +show type of account on account picker diff --git a/src/components/account-info-badge.tsx b/src/components/account-info-badge.tsx new file mode 100644 index 000000000..117aae938 --- /dev/null +++ b/src/components/account-info-badge.tsx @@ -0,0 +1,27 @@ +import { Badge, BadgeProps } from "@chakra-ui/react"; +import { Account } from "../services/account"; + +export default function AccountInfoBadge({ account, ...props }: BadgeProps & { account: Account }) { + if (account.useExtension) { + return ( + + extension + + ); + } + if (account.secKey) { + return ( + + nsec + + ); + } + if (account.readonly) { + return ( + + read-only + + ); + } + return null; +} diff --git a/src/components/page/account-switcher.tsx b/src/components/page/account-switcher.tsx index 935b106e0..dce148950 100644 --- a/src/components/page/account-switcher.tsx +++ b/src/components/page/account-switcher.tsx @@ -15,12 +15,14 @@ import { import { getUserDisplayName } from "../../helpers/user-metadata"; import useSubject from "../../hooks/use-subject"; import { useUserMetadata } from "../../hooks/use-user-metadata"; -import accountService from "../../services/account"; +import accountService, { Account } from "../../services/account"; import { AddIcon } from "../icons"; import { UserAvatar } from "../user-avatar"; import { useLocation, useNavigate } from "react-router-dom"; +import AccountInfoBadge from "../account-info-badge"; -function AccountItem({ pubkey }: { pubkey: string }) { +function AccountItem({ account }: { account: Account }) { + const pubkey = account.pubkey; const metadata = useUserMetadata(pubkey, []); const accord = useAccordionContext(); @@ -32,9 +34,10 @@ function AccountItem({ pubkey }: { pubkey: string }) { return ( - - {getUserDisplayName(metadata, pubkey)} - + + {getUserDisplayName(metadata, pubkey)} + + } aria-label="Remove Account" @@ -60,7 +63,7 @@ export function AccountSwitcherList() { return ( {otherAccounts.map((account) => ( - + ))} + ); }