Armario 2 feito
This commit is contained in:
17
src/App.jsx
17
src/App.jsx
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user