From c37fdd321ae17563a15b8de58d09ab00373c95fc Mon Sep 17 00:00:00 2001 From: 230419 <230419@epvc.pt> Date: Wed, 6 May 2026 11:02:38 +0100 Subject: [PATCH] novo botao --- src/App.jsx | 292 +++++++++++++++++++++++++++++++++++++----------- src/lib/i18n.js | 15 +++ 2 files changed, 243 insertions(+), 64 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 5a68d87..74be53f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -90,6 +90,7 @@ export default function App() { const [plannerMode, setPlannerMode] = useState('month'); const [plannerCurrentDate, setPlannerCurrentDate] = useState(new Date()); const [outfitPlans, setOutfitPlans] = useState([]); + const [showDailyOutfitModal, setShowDailyOutfitModal] = useState(false); const [showPlannerPicker, setShowPlannerPicker] = useState(false); const [plannerPickerDate, setPlannerPickerDate] = useState(null); @@ -407,13 +408,42 @@ export default function App() { const assignOutfitToDay = async (dateStr, lookId) => { if (!user) return; const planRef = doc(db, 'artifacts', appId, 'users', user.uid, 'outfitPlans', dateStr); - if (lookId) { - await setDoc(planRef, { date: dateStr, lookId, updatedAt: new Date().getTime() }); + + const existingPlan = outfitPlans.find(p => p.date === dateStr); + let currentLookIds = []; + if (existingPlan) { + currentLookIds = existingPlan.lookIds || (existingPlan.lookId ? [existingPlan.lookId] : []); + } + + if (lookId === null) { + await deleteDoc(planRef); + return; + } + + if (currentLookIds.includes(lookId)) { + currentLookIds = currentLookIds.filter(id => id !== lookId); + } else { + currentLookIds = [...currentLookIds, lookId]; + } + + if (currentLookIds.length > 0) { + await setDoc(planRef, { date: dateStr, lookIds: currentLookIds, updatedAt: new Date().getTime() }, { merge: true }); } else { await deleteDoc(planRef); } }; + const todayObj = new Date(); + todayObj.setHours(0, 0, 0, 0); + const todayStrGlobal = `${todayObj.getFullYear()}-${String(todayObj.getMonth()+1).padStart(2,'0')}-${String(todayObj.getDate()).padStart(2,'0')}`; + const getLooksForDayGlobal = (ds) => { + const p = outfitPlans.find(plan => plan.date === ds); + if (!p) return []; + const ids = p.lookIds || (p.lookId ? [p.lookId] : []); + return ids.map(id => looks.find(l => l.id === id)).filter(Boolean); + }; + const dailyLooks = getLooksForDayGlobal(todayStrGlobal); + const baseClothes = view === 'wishlist' ? wishlistClothes : activeClothes; const availableColors = useMemo(() => { @@ -1048,6 +1078,9 @@ export default function App() {
{look.name}
- {isWeek &&{look.items.length} {t('piecesShort')}
} + {dayLooks.length > 0 ? ( +{look.name}
+ {isWeek &&{look.items.length} {t('piecesShort')}
} +{t('noOutfitPlanned')}
+{t('goToPlanning')}
+