Initial commit: EduBox V2 platform

This commit is contained in:
root
2026-06-06 19:55:41 +00:00
commit 0a73a70820
69 changed files with 5634 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
"use client";
import { useState } from "react";
import { signIn } from "next-auth/react";
import { useRouter } from "next/navigation";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
export default function LoginForm() {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [error, setError] = useState("");
const [loading, setLoading] = useState(false);
const router = useRouter();
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
setLoading(true);
setError("");
const res = await signIn("credentials", { email, password, redirect: false });
setLoading(false);
if (res?.error) {
setError("Email ou mot de passe invalide");
} else {
router.push("/dashboard");
router.refresh();
}
}
return (
<form onSubmit={handleSubmit} className="space-y-4">
{error && <div className="text-sm text-destructive text-center">{error}</div>}
<div>
<label className="block text-sm font-medium mb-1">Email</label>
<Input type="email" value={email} onChange={(e) => setEmail(e.target.value)} required />
</div>
<div>
<label className="block text-sm font-medium mb-1">Mot de passe</label>
<Input type="password" value={password} onChange={(e) => setPassword(e.target.value)} required />
</div>
<Button type="submit" className="w-full" disabled={loading}>
{loading ? "Connexion..." : "Se connecter"}
</Button>
</form>
);
}
+15
View File
@@ -0,0 +1,15 @@
import LoginForm from "./LoginForm";
export const dynamic = "force-dynamic";
export default function LoginPage() {
return (
<div className="flex min-h-screen items-center justify-center bg-gray-50">
<div className="w-full max-w-md p-8 space-y-6 bg-white rounded-lg shadow-md">
<h1 className="text-2xl font-bold text-center text-gray-900">EduBox V2</h1>
<p className="text-center text-muted-foreground">Connexion à la plateforme</p>
<LoginForm />
</div>
</div>
);
}