Armario 2 feito

This commit is contained in:
2026-04-15 12:44:50 +01:00
parent bd56d8e01a
commit ca5b48a9d6
6 changed files with 3273 additions and 3283 deletions

View File

@@ -6,7 +6,7 @@ import {
Edit2, Image as ImageIcon, Check, RotateCcw, Trash,
PanelLeftClose, PanelLeftOpen, Sparkles, CloudSun,
ArrowRight, Droplets, CheckCircle2, PieChart, History,
X, Download, Bell, Globe
X, Download, Bell, Globe, Filter
} from 'lucide-react';
import {
@@ -170,17 +170,22 @@ export default function App() {
};
try {
if (editingItem) {
const docRef = doc(db, 'artifacts', appId, 'users', user.uid, 'clothes', editingItem.id);
// Guardamos o id se for edição antes de apagar o estado
const currentEditId = editingItem ? editingItem.id : null;
// Navegação instantânea (Optimistic UI Update)
setEditingItem(null);
setImageUrlDraft('');
setView('closet');
if (currentEditId) {
const docRef = doc(db, 'artifacts', appId, 'users', user.uid, 'clothes', currentEditId);
await updateDoc(docRef, itemData);
} else {
itemData.createdAt = new Date().getTime();
const clothesCol = collection(db, 'artifacts', appId, 'users', user.uid, 'clothes');
await addDoc(clothesCol, itemData);
}
setEditingItem(null);
setImageUrlDraft('');
setView('closet');
} catch (e) {
console.error(e);
} finally {