First Push

This commit is contained in:
2026-01-20 17:20:13 +01:00
commit 66f73c3523
24 changed files with 7560 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import { NextRequest, NextResponse } from 'next/server';
import { login, setSession } from '@/lib/auth';
export async function POST(request: NextRequest) {
try {
const { email, password } = await request.json();
if (!email || !password) {
return NextResponse.json(
{ error: 'Email et mot de passe requis' },
{ status: 400 }
);
}
const user = await login(email, password);
if (!user) {
return NextResponse.json(
{ error: 'Email ou mot de passe incorrect' },
{ status: 401 }
);
}
await setSession(user.id);
return NextResponse.json({
success: true,
user: {
id: user.id,
email: user.email,
name: user.name,
},
});
} catch (error) {
console.error('Login error:', error);
return NextResponse.json(
{ error: 'Une erreur est survenue' },
{ status: 500 }
);
}
}

View File

@@ -0,0 +1,7 @@
import { NextResponse } from 'next/server';
import { clearSession } from '@/lib/auth';
export async function POST() {
await clearSession();
return NextResponse.json({ success: true });
}

50
app/dashboard/page.tsx Normal file
View File

@@ -0,0 +1,50 @@
import { redirect } from 'next/navigation';
import { getCurrentUser } from '@/lib/auth';
import DashboardLayout from '@/components/DashboardLayout';
export default async function DashboardPage() {
const user = await getCurrentUser();
if (!user) {
redirect('/login');
}
return (
<DashboardLayout user={user}>
<div className="p-6">
<h1 className="text-3xl font-bold text-gray-900 dark:text-white mb-6">
Tableau de bord
</h1>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<div className="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
<h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-2">
Bienvenue
</h3>
<p className="text-gray-600 dark:text-gray-400">
{user.name || user.email}
</p>
</div>
<div className="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
<h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-2">
Statistiques
</h3>
<p className="text-gray-600 dark:text-gray-400">
Contenu à venir
</p>
</div>
<div className="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
<h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-2">
Activité récente
</h3>
<p className="text-gray-600 dark:text-gray-400">
Contenu à venir
</p>
</div>
</div>
</div>
</DashboardLayout>
);
}

27
app/globals.css Normal file
View File

@@ -0,0 +1,27 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
--background: #ffffff;
--foreground: #171717;
}
@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
}
body {
color: var(--foreground);
background: var(--background);
font-family: Arial, Helvetica, sans-serif;
}
@layer utilities {
.text-balance {
text-wrap: balance;
}
}

19
app/layout.tsx Normal file
View File

@@ -0,0 +1,19 @@
import type { Metadata } from "next";
import "./globals.css";
export const metadata: Metadata = {
title: "Platform SaaS",
description: "Plateforme SaaS",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="fr">
<body>{children}</body>
</html>
);
}

27
app/login/page.tsx Normal file
View File

@@ -0,0 +1,27 @@
import { redirect } from 'next/navigation';
import { getCurrentUser, login } from '@/lib/auth';
import LoginForm from '@/components/LoginForm';
export default async function LoginPage() {
const user = await getCurrentUser();
if (user) {
redirect('/dashboard');
}
return (
<div className="min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900">
<div className="max-w-md w-full space-y-8 p-8">
<div>
<h2 className="mt-6 text-center text-3xl font-extrabold text-gray-900 dark:text-white">
Connexion à votre compte
</h2>
<p className="mt-2 text-center text-sm text-gray-600 dark:text-gray-400">
Accédez à votre tableau de bord
</p>
</div>
<LoginForm />
</div>
</div>
);
}

5
app/page.tsx Normal file
View File

@@ -0,0 +1,5 @@
import { redirect } from "next/navigation";
export default function Home() {
redirect("/login");
}