diff --git a/src/App.tsx b/src/App.tsx index 3c31f3b..18dc951 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -13,6 +13,7 @@ function App() { const [searchText, setSearchText] = useState(''); const [showFavoritesOnly, setShowFavoritesOnly] = useState(false); const [fontSize] = useState(14); + const [username, setUsername] = useState(''); useEffect(() => { const savedServer = localStorage.getItem('serverURL'); @@ -26,6 +27,7 @@ function App() { password: savedPassword, }); setApi(apiInstance); + setUsername(savedUsername); setIsLoggedIn(true); } }, []); @@ -58,9 +60,21 @@ function App() { const apiInstance = new NextcloudAPI({ serverURL, username, password }); setApi(apiInstance); + setUsername(username); setIsLoggedIn(true); }; + const handleLogout = () => { + localStorage.removeItem('serverURL'); + localStorage.removeItem('username'); + localStorage.removeItem('password'); + setApi(null); + setUsername(''); + setNotes([]); + setSelectedNoteId(null); + setIsLoggedIn(false); + }; + const handleCreateNote = async () => { if (!api) return; try { @@ -136,6 +150,8 @@ function App() { onCreateNote={handleCreateNote} onDeleteNote={handleDeleteNote} onSync={syncNotes} + onLogout={handleLogout} + username={username} searchText={searchText} onSearchChange={setSearchText} showFavoritesOnly={showFavoritesOnly} diff --git a/src/components/NotesList.tsx b/src/components/NotesList.tsx index dbb8ee4..02da069 100644 --- a/src/components/NotesList.tsx +++ b/src/components/NotesList.tsx @@ -8,6 +8,8 @@ interface NotesListProps { onCreateNote: () => void; onDeleteNote: (note: Note) => void; onSync: () => void; + onLogout: () => void; + username: string; searchText: string; onSearchChange: (text: string) => void; showFavoritesOnly: boolean; @@ -21,6 +23,8 @@ export function NotesList({ onCreateNote, onDeleteNote, onSync, + onLogout, + username, searchText, onSearchChange, showFavoritesOnly, @@ -168,6 +172,27 @@ export function NotesList({ )) )} + + {/* User Info and Logout */} +