From d4c18844715c390f8ed6b2adccdd2c9caa67e170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Henrique?= Date: Tue, 26 Aug 2025 22:11:42 -0300 Subject: [PATCH] fixes --- App.tsx | 12 +++++++++++- components/CategoryEditModal.tsx | 2 +- components/WebsiteEditModal.tsx | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/App.tsx b/App.tsx index c554e46..5be3690 100755 --- a/App.tsx +++ b/App.tsx @@ -69,6 +69,14 @@ const App: React.FC = () => { localStorage.setItem('config', JSON.stringify(config)); }, [config]); + useEffect(() => { + try { + localStorage.setItem('categories', JSON.stringify(categories)); + } catch (error) { + console.error('Error saving categories to localStorage', error); + } + }, [categories]); + const handleSaveConfig = (newConfig: Config) => { setConfig(newConfig); setIsConfigModalOpen(false); @@ -80,10 +88,11 @@ const App: React.FC = () => { const handleSaveWebsite = (website: Partial) => { if (editingWebsite) { + const idToUpdate = website.id ?? editingWebsite.id; const newCategories = categories.map(category => ({ ...category, websites: category.websites.map(w => - w.id === website.id ? { ...w, ...website } : w + w.id === idToUpdate ? { ...w, ...website, id: idToUpdate } : w ), })); setCategories(newCategories); @@ -145,6 +154,7 @@ const App: React.FC = () => { }; const handleMoveWebsite = (website: Website, direction: 'left' | 'right') => { + const categoryIndex = categories.findIndex(cat => cat.websites.some(w => w.id === website.id)); if (categoryIndex === -1) return; const category = categories[categoryIndex]; diff --git a/components/CategoryEditModal.tsx b/components/CategoryEditModal.tsx index b1e1c39..dcd8979 100644 --- a/components/CategoryEditModal.tsx +++ b/components/CategoryEditModal.tsx @@ -40,7 +40,7 @@ const CategoryEditModal: React.FC = ({ category, edit, o )}
-