nova preferencia!

This commit is contained in:
2026-05-09 22:05:54 +01:00
parent 12ec0ba3ec
commit 95bb34b46d
2 changed files with 57 additions and 3 deletions

View File

@@ -62,6 +62,7 @@ export default function App() {
const [showLangModal, setShowLangModal] = useState(false); const [showLangModal, setShowLangModal] = useState(false);
const [theme, setTheme] = useState('theme-indigo'); const [theme, setTheme] = useState('theme-indigo');
const [cardSize, setCardSize] = useState('large'); const [cardSize, setCardSize] = useState('large');
const [defaultPage, setDefaultPage] = useState('dashboard');
const [weatherData, setWeatherData] = useState(null); const [weatherData, setWeatherData] = useState(null);
// Estado para Partilha de Looks // Estado para Partilha de Looks
@@ -162,6 +163,11 @@ export default function App() {
saveUserSetting('cardSize', newVal); saveUserSetting('cardSize', newVal);
}; };
const handleDefaultPageChange = (newVal) => {
setDefaultPage(newVal);
saveUserSetting('defaultPage', newVal);
};
// Buscar o look partilhado pelo link // Buscar o look partilhado pelo link
const fetchSharedLook = async (lookId) => { const fetchSharedLook = async (lookId) => {
if (!lookId) return; if (!lookId) return;
@@ -229,7 +235,7 @@ export default function App() {
} }
}; };
initAuth(); initAuth();
const unsubscribe = onAuthStateChanged(auth, (currentUser) => { const unsubscribe = onAuthStateChanged(auth, async (currentUser) => {
if (!currentUser) { if (!currentUser) {
// Reset de todo o estado ao fazer logout para não contaminar a próxima conta // Reset de todo o estado ao fazer logout para não contaminar a próxima conta
setUser(null); setUser(null);
@@ -244,18 +250,36 @@ export default function App() {
setWeatherAlerts(true); setWeatherAlerts(true);
setWeatherData(null); setWeatherData(null);
setView('auth'); setView('auth');
setLoading(false);
} else { } else {
// Carregar tema guardado para este utilizador específico // Carregar tema guardado para este utilizador específico
const savedTheme = localStorage.getItem(`app-theme-${currentUser.uid}`) || 'theme-indigo'; const savedTheme = localStorage.getItem(`app-theme-${currentUser.uid}`) || 'theme-indigo';
setTheme(savedTheme); setTheme(savedTheme);
setUser(currentUser); setUser(currentUser);
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'); setView('dashboard');
}
// Verificar se há um look partilhado no URL // Verificar se há um look partilhado no URL
const sharedId = sharedLookRef.current || new URLSearchParams(window.location.search).get('shared'); const sharedId = sharedLookRef.current || new URLSearchParams(window.location.search).get('shared');
sharedLookRef.current = ''; sharedLookRef.current = '';
if (sharedId) fetchSharedLook(sharedId); if (sharedId) fetchSharedLook(sharedId);
}
setLoading(false); setLoading(false);
}
}); });
return () => unsubscribe(); return () => unsubscribe();
}, []); }, []);
@@ -301,6 +325,9 @@ export default function App() {
if (data.settings.notificationsEnabled !== undefined) setNotificationsEnabled(data.settings.notificationsEnabled); if (data.settings.notificationsEnabled !== undefined) setNotificationsEnabled(data.settings.notificationsEnabled);
if (data.settings.weatherAlerts !== undefined) setWeatherAlerts(data.settings.weatherAlerts); if (data.settings.weatherAlerts !== undefined) setWeatherAlerts(data.settings.weatherAlerts);
if (data.settings.cardSize !== undefined) setCardSize(data.settings.cardSize); 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({}); else setUserProfile({});
@@ -2091,6 +2118,23 @@ export default function App() {
))} ))}
</div> </div>
</div> </div>
<div className="flex items-center justify-between">
<div>
<p className="font-bold text-inherit">{t('defaultPage') || 'Página Inicial'}</p>
<p className="text-[10px] uppercase tracking-widest opacity-50 text-inherit">{t('defaultPageDesc') || 'Página que aparece após o login'}</p>
</div>
<div className="flex gap-2">
{['dashboard', 'closet', 'outfits', 'planner'].map(s => (
<button
key={s}
onClick={() => handleDefaultPageChange(s)}
className={`px-3 py-1.5 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all border-2 ${defaultPage === s ? 'border-primary-600 bg-primary-600 text-white shadow-lg shadow-primary-600/30 scale-105' : 'border-transparent bg-gray-100 dark:bg-gray-800 text-gray-500 hover:bg-gray-200 dark:hover:bg-gray-700'}`}
>
{s === 'dashboard' ? t('dashboard') : s === 'closet' ? t('myCloset') : s === 'outfits' ? t('outfits') : t('planning')}
</button>
))}
</div>
</div>
<div className="flex items-center justify-between pt-4 border-t border-gray-100 dark:border-gray-800"> <div className="flex items-center justify-between pt-4 border-t border-gray-100 dark:border-gray-800">
<div> <div>
<p className="font-bold text-inherit">{t('appLanguage')}</p> <p className="font-bold text-inherit">{t('appLanguage')}</p>

View File

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