nova preferencia!
This commit is contained in:
50
src/App.jsx
50
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() {
|
||||
))}
|
||||
</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>
|
||||
<p className="font-bold text-inherit">{t('appLanguage')}</p>
|
||||
|
||||
@@ -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",
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user