diff --git a/src/pages/NostrSettings.tsx b/src/pages/NostrSettings.tsx index 88158877..83805e81 100644 --- a/src/pages/NostrSettings.tsx +++ b/src/pages/NostrSettings.tsx @@ -1,13 +1,44 @@ -import { ArrowLeft, Wifi } from 'lucide-react'; +import { ArrowLeft, Wifi, Users, UserPlus, LogOut, Trash2, User } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Label } from '@/components/ui/label'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; +import { Badge } from '@/components/ui/badge'; import { RelaySelector } from '@/components/RelaySelector'; +import LoginDialog from '@/components/auth/LoginDialog'; +import SignupDialog from '@/components/auth/SignupDialog'; import { useIsMobile } from '@/hooks/useIsMobile'; import { useNavigate } from 'react-router-dom'; +import { useLoggedInAccounts, type Account } from '@/hooks/useLoggedInAccounts'; +import { genUserName } from '@/lib/genUserName'; +import { useState } from 'react'; export function NostrSettings() { const isMobile = useIsMobile(); const navigate = useNavigate(); + const { authors, currentUser, setLogin, removeLogin } = useLoggedInAccounts(); + const [showLoginDialog, setShowLoginDialog] = useState(false); + const [showSignupDialog, setShowSignupDialog] = useState(false); + + const handleSwitchAccount = (accountId: string) => { + setLogin(accountId); + }; + + const handleRemoveAccount = (accountId: string) => { + removeLogin(accountId); + }; + + const handleLoginSuccess = () => { + setShowLoginDialog(false); + }; + + const handleSignupComplete = () => { + setShowSignupDialog(false); + }; + + const getDisplayName = (account: Account) => { + return account.metadata?.name ?? genUserName(account.pubkey); + }; return (
@@ -47,12 +78,158 @@ export function NostrSettings() { )}
+ {/* Account Management */} + + + + + Nostr Accounts + + + + {authors.length === 0 ? ( +
+ +

+ No accounts logged in. Add an account to get started. +

+
+ + +
+
+ ) : ( + <> + {/* Account List */} +
+ {authors.map((account) => ( +
+ + + + {getDisplayName(account).charAt(0).toUpperCase()} + + + +
+
+

+ {getDisplayName(account)} +

+ {currentUser?.id === account.id && ( + + Current + + )} +
+

+ {account.pubkey.slice(0, 16)}... +

+ {account.metadata?.about && ( +

+ {account.metadata.about} +

+ )} +
+ +
+ {currentUser?.id !== account.id && ( + + )} + +
+
+ ))} +
+ + {/* Add Account Actions */} +
+
+ + +
+
+ + )} +
+
+ {/* Relay Configuration */} -
- - -
+ + + + + Relay Configuration + + + +
+ + +
+
+
+ + {/* Login Dialog */} + setShowLoginDialog(false)} + onLogin={handleLoginSuccess} + onSignup={() => { + setShowLoginDialog(false); + setShowSignupDialog(true); + }} + /> + + {/* Signup Dialog */} + setShowSignupDialog(false)} + onComplete={handleSignupComplete} + />
); }