diff --git a/frontend/src/components/Permissions.tsx b/frontend/src/components/Permissions.tsx index 0587bd97..5f2663ac 100644 --- a/frontend/src/components/Permissions.tsx +++ b/frontend/src/components/Permissions.tsx @@ -12,8 +12,8 @@ import { NIP_47_PAY_INVOICE_METHOD, Scope, WalletCapabilities, - iconMap, scopeDescriptions, + scopeIconMap, } from "src/types"; interface PermissionsProps { @@ -122,7 +122,7 @@ const Permissions: React.FC = ({

Scopes

{[...permissions.scopes].map((rm) => { - const PermissionIcon = iconMap[rm]; + const PermissionIcon = scopeIconMap[rm]; return (
= ({ ); }, [capabilities.scopes]); - const [scopeGroup, setScopeGroup] = React.useState(() => { + const [scopeGroup, setScopeGroup] = React.useState(() => { if (!scopes.size || isSetEqual(scopes, fullAccessScopes)) { return SCOPE_GROUP_FULL_ACCESS; } else if (isSetEqual(scopes, readOnlyScopes)) { @@ -73,7 +73,7 @@ const Scopes: React.FC = ({ } }, [fullAccessScopes, onScopeChange, scopeGroup, scopes]); - const handleScopeGroupChange = (scopeGroup: ScopeGroupType) => { + const handleScopeGroupChange = (scopeGroup: ScopeGroup) => { setScopeGroup(scopeGroup); switch (scopeGroup) { case SCOPE_GROUP_FULL_ACCESS: @@ -109,7 +109,7 @@ const Scopes: React.FC = ({ SCOPE_GROUP_FULL_ACCESS, SCOPE_GROUP_READ_ONLY, SCOPE_GROUP_CUSTOM, - ] as ScopeGroupType[] + ] as ScopeGroup[] ).map((sg, index) => { const ScopeGroupIcon = scopeGroupIconMap[sg]; return ( diff --git a/frontend/src/types.ts b/frontend/src/types.ts index d030ade7..75af9e74 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -76,15 +76,19 @@ export type ReadOnlyScope = | "list_transactions" | "notifications"; -export type ScopeGroupType = "full_access" | "read_only" | "custom"; +export type ScopeGroup = "full_access" | "read_only" | "custom"; export type Nip47NotificationType = "payment_received" | "payment_sent"; -export type IconMap = { - [key in string]: LucideIcon; +export type ScopeIconMap = { + [key in Scope]: LucideIcon; }; -export const iconMap: IconMap = { +export type ScopeGroupIconMap = { + [key in ScopeGroup]: LucideIcon; +}; + +export const scopeIconMap: ScopeIconMap = { [NIP_47_GET_BALANCE_METHOD]: WalletMinimal, [NIP_47_GET_INFO_METHOD]: Info, [NIP_47_LIST_TRANSACTIONS_METHOD]: NotebookTabs, @@ -95,7 +99,7 @@ export const iconMap: IconMap = { [NIP_47_NOTIFICATIONS_PERMISSION]: Bell, }; -export const scopeGroupIconMap: IconMap = { +export const scopeGroupIconMap: ScopeGroupIconMap = { [SCOPE_GROUP_FULL_ACCESS]: ArrowDownUp, [SCOPE_GROUP_READ_ONLY]: MoveDown, [SCOPE_GROUP_CUSTOM]: SquarePen, @@ -126,13 +130,13 @@ export const scopeDescriptions: Record = { [NIP_47_NOTIFICATIONS_PERMISSION]: "Receive wallet notifications", }; -export const scopeGroupTitle: Record = { +export const scopeGroupTitle: Record = { [SCOPE_GROUP_FULL_ACCESS]: "Full Access", [SCOPE_GROUP_READ_ONLY]: "Read Only", [SCOPE_GROUP_CUSTOM]: "Custom", }; -export const scopeGroupDescriptions: Record = { +export const scopeGroupDescriptions: Record = { [SCOPE_GROUP_FULL_ACCESS]: "Complete wallet control", [SCOPE_GROUP_READ_ONLY]: "Only view wallet info", [SCOPE_GROUP_CUSTOM]: "Define permissions",