refactor(auth): extract shared page header into AuthPageHeader component
- add AuthPageHeader component to centralize title/description markup - replace inline header divs in LoginPage, RegisterPage, LogoutPage, ForgotPasswordPage, ResetPasswordPage, and ConfirmEmailPage with AuthPageHeader
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
export default function AuthPageHeader({ title, description }) {
|
||||||
|
return (
|
||||||
|
<div className="text-center mb-6 flex flex-col gap-1">
|
||||||
|
<h1 className="text-[22px] font-bold text-neutral-900 dark:text-white">{title}</h1>
|
||||||
|
{description && (
|
||||||
|
<p className="text-sm text-neutral-600 dark:text-neutral-400">{description}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useState, useEffect, useRef } from 'react';
|
import { useState, useEffect, useRef } from 'react';
|
||||||
import { Card } from '@zen/core/shared/components';
|
import { Card } from '@zen/core/shared/components';
|
||||||
|
import AuthPageHeader from '../components/AuthPageHeader.js';
|
||||||
|
|
||||||
export default function ConfirmEmailPage({ onSubmit, onNavigate, email, token }) {
|
export default function ConfirmEmailPage({ onSubmit, onNavigate, email, token }) {
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
@@ -80,14 +81,7 @@ export default function ConfirmEmailPage({ onSubmit, onNavigate, email, token })
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
||||||
<div className="text-center mb-6">
|
<AuthPageHeader title="Vérification de l'e-mail" description="Nous vérifions votre adresse e-mail..." />
|
||||||
<h1 className="text-2xl font-bold text-neutral-900 dark:text-white mb-2">
|
|
||||||
Vérification de l'e-mail
|
|
||||||
</h1>
|
|
||||||
<p className="text-sm text-neutral-600 dark:text-neutral-400">
|
|
||||||
Nous vérifions votre adresse e-mail...
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{isLoading && (
|
{isLoading && (
|
||||||
<div className="flex flex-col items-center py-10">
|
<div className="flex flex-col items-center py-10">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { Card, Input, Button } from '@zen/core/shared/components';
|
import { Card, Input, Button } from '@zen/core/shared/components';
|
||||||
|
import AuthPageHeader from '../components/AuthPageHeader.js';
|
||||||
|
|
||||||
export default function ForgotPasswordPage({ onSubmit, onNavigate, currentUser = null }) {
|
export default function ForgotPasswordPage({ onSubmit, onNavigate, currentUser = null }) {
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
@@ -45,14 +46,7 @@ export default function ForgotPasswordPage({ onSubmit, onNavigate, currentUser =
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
||||||
<div className="text-center mb-6">
|
<AuthPageHeader title="Mot de passe oublié" description="Entrez votre adresse e-mail et nous vous enverrons un lien pour réinitialiser votre mot de passe." />
|
||||||
<h1 className="text-2xl font-bold text-neutral-900 dark:text-white mb-2">
|
|
||||||
Mot de passe oublié
|
|
||||||
</h1>
|
|
||||||
<p className="text-sm text-neutral-600 dark:text-neutral-400">
|
|
||||||
Entrez votre adresse e-mail et nous vous enverrons un lien pour réinitialiser votre mot de passe.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{currentUser && (
|
{currentUser && (
|
||||||
<div className="mb-4 p-3 bg-blue-50 border border-blue-200 rounded-lg dark:bg-blue-500/10 dark:border-blue-500/20">
|
<div className="mb-4 p-3 bg-blue-50 border border-blue-200 rounded-lg dark:bg-blue-500/10 dark:border-blue-500/20">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { Card, Input, Button } from '@zen/core/shared/components';
|
import { Card, Input, Button } from '@zen/core/shared/components';
|
||||||
|
import AuthPageHeader from '../components/AuthPageHeader.js';
|
||||||
|
|
||||||
export default function LoginPage({ onSubmit, onNavigate, onSetSessionCookie, redirectAfterLogin = '/', currentUser = null }) {
|
export default function LoginPage({ onSubmit, onNavigate, onSetSessionCookie, redirectAfterLogin = '/', currentUser = null }) {
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
@@ -67,14 +68,7 @@ export default function LoginPage({ onSubmit, onNavigate, onSetSessionCookie, re
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
||||||
<div className="text-center mb-6">
|
<AuthPageHeader title="Connexion" description="Veuillez vous connecter pour continuer." />
|
||||||
<h1 className="text-2xl font-bold text-neutral-900 dark:text-white mb-2">
|
|
||||||
Connexion
|
|
||||||
</h1>
|
|
||||||
<p className="text-sm text-neutral-600 dark:text-neutral-400">
|
|
||||||
Veuillez vous connecter pour continuer.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{currentUser && (
|
{currentUser && (
|
||||||
<div className="mb-4 p-3 bg-blue-50 border border-blue-200 rounded-lg dark:bg-blue-500/10 dark:border-blue-500/20">
|
<div className="mb-4 p-3 bg-blue-50 border border-blue-200 rounded-lg dark:bg-blue-500/10 dark:border-blue-500/20">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { Card, Button } from '@zen/core/shared/components';
|
import { Card, Button } from '@zen/core/shared/components';
|
||||||
|
import AuthPageHeader from '../components/AuthPageHeader.js';
|
||||||
|
|
||||||
export default function LogoutPage({ onLogout, onSetSessionCookie }) {
|
export default function LogoutPage({ onLogout, onSetSessionCookie }) {
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
@@ -42,14 +43,7 @@ export default function LogoutPage({ onLogout, onSetSessionCookie }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
||||||
<div className="text-center mb-6">
|
<AuthPageHeader title="Prêt à vous déconnecter ?" description="Cela mettra fin à votre session et vous déconnectera de votre compte." />
|
||||||
<h1 className="text-2xl font-bold text-neutral-900 dark:text-white mb-2">
|
|
||||||
Prêt à vous déconnecter ?
|
|
||||||
</h1>
|
|
||||||
<p className="text-sm text-neutral-600 dark:text-neutral-400">
|
|
||||||
Cela mettra fin à votre session et vous déconnectera de votre compte.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{success && (
|
{success && (
|
||||||
<div className="mb-4 p-3 bg-green-50 border border-green-200 rounded-lg dark:bg-green-500/10 dark:border-green-500/20">
|
<div className="mb-4 p-3 bg-green-50 border border-green-200 rounded-lg dark:bg-green-500/10 dark:border-green-500/20">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { Card, Input, Button, PasswordStrengthIndicator } from '@zen/core/shared/components';
|
import { Card, Input, Button, PasswordStrengthIndicator } from '@zen/core/shared/components';
|
||||||
|
import AuthPageHeader from '../components/AuthPageHeader.js';
|
||||||
|
|
||||||
export default function RegisterPage({ onSubmit, onNavigate, currentUser = null }) {
|
export default function RegisterPage({ onSubmit, onNavigate, currentUser = null }) {
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
@@ -97,14 +98,7 @@ export default function RegisterPage({ onSubmit, onNavigate, currentUser = null
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
||||||
<div className="text-center mb-6">
|
<AuthPageHeader title="Créer un compte" description="Inscrivez-vous pour commencer." />
|
||||||
<h1 className="text-2xl font-bold text-neutral-900 dark:text-white mb-2">
|
|
||||||
Créer un compte
|
|
||||||
</h1>
|
|
||||||
<p className="text-sm text-neutral-600 dark:text-neutral-400">
|
|
||||||
Inscrivez-vous pour commencer.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{currentUser && (
|
{currentUser && (
|
||||||
<div className="mb-4 p-3 bg-blue-50 border border-blue-200 rounded-lg dark:bg-blue-500/10 dark:border-blue-500/20">
|
<div className="mb-4 p-3 bg-blue-50 border border-blue-200 rounded-lg dark:bg-blue-500/10 dark:border-blue-500/20">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Card, Input, Button, PasswordStrengthIndicator } from '@zen/core/shared/components';
|
import { Card, Input, Button, PasswordStrengthIndicator } from '@zen/core/shared/components';
|
||||||
|
import AuthPageHeader from '../components/AuthPageHeader.js';
|
||||||
|
|
||||||
export default function ResetPasswordPage({ onSubmit, onNavigate, email, token }) {
|
export default function ResetPasswordPage({ onSubmit, onNavigate, email, token }) {
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
@@ -65,14 +66,7 @@ export default function ResetPasswordPage({ onSubmit, onNavigate, email, token }
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
<Card variant="default" padding="md" spacing="none" className="w-full max-w-md">
|
||||||
<div className="text-center mb-6">
|
<AuthPageHeader title="Réinitialiser le mot de passe" description="Saisissez votre nouveau mot de passe ci-dessous." />
|
||||||
<h1 className="text-2xl font-bold text-neutral-900 dark:text-white mb-2">
|
|
||||||
Réinitialiser le mot de passe
|
|
||||||
</h1>
|
|
||||||
<p className="text-sm text-neutral-600 dark:text-neutral-400">
|
|
||||||
Saisissez votre nouveau mot de passe ci-dessous.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{error && !success && (
|
{error && !success && (
|
||||||
<div className="mb-4 p-3 bg-red-50 border border-red-200 rounded-lg dark:bg-red-500/10 dark:border-red-500/20">
|
<div className="mb-4 p-3 bg-red-50 border border-red-200 rounded-lg dark:bg-red-500/10 dark:border-red-500/20">
|
||||||
|
|||||||
Reference in New Issue
Block a user