fixes
This commit is contained in:
12
App.tsx
12
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<Website>) => {
|
||||
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];
|
||||
|
@@ -40,7 +40,7 @@ const CategoryEditModal: React.FC<CategoryEditModalProps> = ({ category, edit, o
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-end gap-4">
|
||||
<button onClick={handleSave} className="bg-green-500 hover:bg-green-400 text-white font-bold py-2 px-6 rounded-lg">
|
||||
<button onClick={() => onSave(name)} className="bg-green-500 hover:bg-green-400 text-white font-bold py-2 px-6 rounded-lg">
|
||||
Save
|
||||
</button>
|
||||
<button onClick={onClose} className="bg-gray-600 hover:bg-gray-500 text-white font-bold py-2 px-6 rounded-lg">
|
||||
|
@@ -76,6 +76,7 @@ const WebsiteEditModal: React.FC<WebsiteEditModalProps> = ({ website, edit, onCl
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
console.log({ id: website?.id, name, url, icon });
|
||||
onSave({ id: website?.id, name, url, icon });
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user