Login.jsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { useEffect, useState } from 'react'
  2. import api from '../api'
  3. export default function Login() {
  4. const [oidcConfig, setOidcConfig] = useState({ enabled: false, label: 'Se connecter via SSO' })
  5. const [loading, setLoading] = useState(true)
  6. useEffect(() => {
  7. api.get('/auth/oidc/config')
  8. .then(res => setOidcConfig(res.data))
  9. .catch(() => {})
  10. .finally(() => setLoading(false))
  11. }, [])
  12. const handleSso = () => {
  13. window.location.href = '/api/auth/oidc/login'
  14. }
  15. return (
  16. <div className="min-h-screen bg-gradient-to-br from-blue-50 to-blue-100 flex items-center justify-center p-4">
  17. <div className="bg-white rounded-2xl shadow-lg p-8 w-full max-w-sm text-center">
  18. <div className="text-5xl mb-3">🏠</div>
  19. <h1 className="text-2xl font-bold text-gray-900">Gestion Locative</h1>
  20. <p className="text-gray-500 mt-1 mb-8">Connectez-vous à votre espace</p>
  21. {loading ? (
  22. <div className="flex justify-center py-4">
  23. <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
  24. </div>
  25. ) : oidcConfig.enabled ? (
  26. <button type="button" onClick={handleSso}
  27. className="w-full flex items-center justify-center gap-2 py-3 px-4 bg-blue-600 hover:bg-blue-700 text-white rounded-xl font-semibold text-base transition-colors shadow">
  28. 🔑 {oidcConfig.label}
  29. </button>
  30. ) : (
  31. <div className="bg-orange-50 border border-orange-200 rounded-xl p-4 text-sm text-orange-700">
  32. ⚠️ Le SSO n'est pas configuré.<br />Contactez l'administrateur.
  33. </div>
  34. )}
  35. </div>
  36. </div>
  37. )
  38. }