import { Navigate } from 'react-router-dom';

const RootRedirect = () => {
    // Check for saved language preference
    const savedLang = localStorage.getItem('preferred_language');

    // Default to French if no preference or invalid
    const targetLang = (savedLang === 'en' || savedLang === 'fr') ? savedLang : 'fr';

    // We use Navigate to redirect
    return <Navigate to={`/${targetLang}`} replace />;
};

export default RootRedirect;
