diff --git a/src/App.jsx b/src/App.jsx index 9493ad4..9e2e61d 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -62,6 +62,7 @@ export default function App() { const [showLangModal, setShowLangModal] = useState(false); const [theme, setTheme] = useState('theme-indigo'); const [cardSize, setCardSize] = useState('large'); + const [defaultPage, setDefaultPage] = useState('dashboard'); const [weatherData, setWeatherData] = useState(null); // Estado para Partilha de Looks @@ -162,6 +163,11 @@ export default function App() { saveUserSetting('cardSize', newVal); }; + const handleDefaultPageChange = (newVal) => { + setDefaultPage(newVal); + saveUserSetting('defaultPage', newVal); + }; + // Buscar o look partilhado pelo link const fetchSharedLook = async (lookId) => { if (!lookId) return; @@ -229,7 +235,7 @@ export default function App() { } }; initAuth(); - const unsubscribe = onAuthStateChanged(auth, (currentUser) => { + const unsubscribe = onAuthStateChanged(auth, async (currentUser) => { if (!currentUser) { // Reset de todo o estado ao fazer logout para não contaminar a próxima conta setUser(null); @@ -244,18 +250,36 @@ export default function App() { setWeatherAlerts(true); setWeatherData(null); setView('auth'); + setLoading(false); } else { // Carregar tema guardado para este utilizador específico const savedTheme = localStorage.getItem(`app-theme-${currentUser.uid}`) || 'theme-indigo'; setTheme(savedTheme); setUser(currentUser); - setView('dashboard'); + + try { + const profileDocRef = doc(db, 'artifacts', appId, 'users', currentUser.uid, 'profile', 'data'); + const snap = await getDoc(profileDocRef); + let initialView = 'dashboard'; + if (snap.exists()) { + const data = snap.data(); + if (data.settings && data.settings.defaultPage) { + initialView = data.settings.defaultPage === 'planning' ? 'planner' : data.settings.defaultPage; + setDefaultPage(initialView); + } + } + setView(initialView); + } catch(e) { + setView('dashboard'); + } + // Verificar se há um look partilhado no URL const sharedId = sharedLookRef.current || new URLSearchParams(window.location.search).get('shared'); sharedLookRef.current = ''; if (sharedId) fetchSharedLook(sharedId); + + setLoading(false); } - setLoading(false); }); return () => unsubscribe(); }, []); @@ -301,6 +325,9 @@ export default function App() { if (data.settings.notificationsEnabled !== undefined) setNotificationsEnabled(data.settings.notificationsEnabled); if (data.settings.weatherAlerts !== undefined) setWeatherAlerts(data.settings.weatherAlerts); if (data.settings.cardSize !== undefined) setCardSize(data.settings.cardSize); + if (data.settings.defaultPage !== undefined) { + setDefaultPage(data.settings.defaultPage === 'planning' ? 'planner' : data.settings.defaultPage); + } } } else setUserProfile({}); @@ -2091,6 +2118,23 @@ export default function App() { ))} +
+
+

{t('defaultPage') || 'Página Inicial'}

+

{t('defaultPageDesc') || 'Página que aparece após o login'}

+
+
+ {['dashboard', 'closet', 'outfits', 'planner'].map(s => ( + + ))} +
+

{t('appLanguage')}

diff --git a/src/lib/i18n.js b/src/lib/i18n.js index d9b68ce..462999b 100644 --- a/src/lib/i18n.js +++ b/src/lib/i18n.js @@ -201,6 +201,8 @@ export const translations = { small: "Pequeno", medium: "Médio", large: "Grande", + defaultPage: "Página Inicial", + defaultPageDesc: "Página que aparece após o login", }, EN: { loginModeIntro: "The Future of Your Style", @@ -404,6 +406,8 @@ export const translations = { small: "Small", medium: "Medium", large: "Large", + defaultPage: "Home Page", + defaultPageDesc: "Page that appears after login", }, ES: { loginModeIntro: "El Futuro de Tu Estilo", @@ -607,6 +611,8 @@ export const translations = { small: "Pequeño", medium: "Medio", large: "Grande", + defaultPage: "Página de Inicio", + defaultPageDesc: "Página que aparece después de iniciar sesión", }, FR: { loginModeIntro: "Le Futur de Ton Style", @@ -810,6 +816,8 @@ export const translations = { small: "Petit", medium: "Moyen", large: "Grand", + defaultPage: "Page d'Accueil", + defaultPageDesc: "Page qui apparaît après la connexion", }, DE: { loginModeIntro: "Die Zukunft deines Stils", @@ -1013,5 +1021,7 @@ export const translations = { small: "Klein", medium: "Mittel", large: "Groß", + defaultPage: "Startseite", + defaultPageDesc: "Seite, die nach der Anmeldung angezeigt wird", } };