diff --git a/package-lock.json b/package-lock.json index 82e0894..a6231f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,7 @@ "@types/react-dom": "^19", "eslint": "^9", "eslint-config-next": "15.5.28", + "playwright": "^1.64.1", "tailwindcss": "^4", "tsx": "^4.23.15", "typescript": "^5", @@ -6808,6 +6809,35 @@ "integrity": "sha512-cKUSoKa8YxFZZSmraVi7onONx3amu77ngK3kGpsYHDH7drPwCRkQE1RYMPlLRrMtnciRj274XNRxcHxnKmDSnA==", "license": "MIT" }, + "node_modules/playwright": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.1.tgz", + "integrity": "sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.64.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/playwright-core": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz", + "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/possible-typed-array-names": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", diff --git a/package.json b/package.json index dbcc969..aa4546c 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "@types/react-dom": "^19", "eslint": "^9", "eslint-config-next": "15.5.28", + "playwright": "^1.64.1", "tailwindcss": "^4", "tsx": "^4.23.15", "typescript": "^5", diff --git a/public/file.svg b/public/file.svg deleted file mode 100644 index 004145c..0000000 --- a/public/file.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/globe.svg b/public/globe.svg deleted file mode 100644 index 567f17b..0000000 --- a/public/globe.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/next.svg b/public/next.svg deleted file mode 100644 index 5174b28..0000000 --- a/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/vercel.svg b/public/vercel.svg deleted file mode 100644 index 7705396..0000000 --- a/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/window.svg b/public/window.svg deleted file mode 100644 index b2b2a44..0000000 --- a/public/window.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/scripts/reset-password.ts b/scripts/reset-password.ts new file mode 100644 index 0000000..3c4688c --- /dev/null +++ b/scripts/reset-password.ts @@ -0,0 +1,26 @@ +// Réinitialise le mot de passe d'un compte : node dist/reset-password.js +import bcrypt from "bcryptjs"; +import { PrismaClient } from "@prisma/client"; + +async function main() { + const [login, password] = process.argv.slice(2); + if (!login || !password || password.length < 8) { + console.error("Usage : reset-password "); + process.exit(1); + } + const prisma = new PrismaClient(); + try { + const user = await prisma.user.update({ + where: { login: login.toLowerCase() }, + data: { passwordHash: await bcrypt.hash(password, 10) }, + }); + console.log(`Mot de passe de ${user.firstName} (${user.login}) mis à jour.`); + } catch { + console.error(`Aucun compte avec l'identifiant « ${login} ».`); + process.exitCode = 1; + } finally { + await prisma.$disconnect(); + } +} + +main(); diff --git a/src/app/(app)/page.tsx b/src/app/(app)/page.tsx new file mode 100644 index 0000000..9d9a93c --- /dev/null +++ b/src/app/(app)/page.tsx @@ -0,0 +1,12 @@ +import { requireUser } from "@/server/auth"; +import { logoutAction } from "@/server/actions/auth"; + +export default async function DashboardPage() { + const user = await requireUser(); + return ( +
+

Bonjour {user.firstName}

+
+
+ ); +} diff --git a/src/app/(public)/layout.tsx b/src/app/(public)/layout.tsx new file mode 100644 index 0000000..fcaa132 --- /dev/null +++ b/src/app/(public)/layout.tsx @@ -0,0 +1,12 @@ +import { Logo } from "@/components/Logo"; + +export default function PublicLayout({ children }: { children: React.ReactNode }) { + return ( +
+
+ +
+ {children} +
+ ); +} diff --git a/src/app/(public)/login/LoginForm.tsx b/src/app/(public)/login/LoginForm.tsx new file mode 100644 index 0000000..eb5e703 --- /dev/null +++ b/src/app/(public)/login/LoginForm.tsx @@ -0,0 +1,28 @@ +"use client"; + +import { useActionState } from "react"; +import { loginAction } from "@/server/actions/auth"; +import { Button } from "@/components/ui/Button"; +import { Card } from "@/components/ui/Card"; +import { Field, FormError, Input } from "@/components/ui/Field"; + +export function LoginForm() { + const [state, action, pending] = useActionState(loginAction, { error: null }); + return ( + +

Connexion

+
+ + + + + + + + + +
+ ); +} diff --git a/src/app/(public)/login/page.tsx b/src/app/(public)/login/page.tsx new file mode 100644 index 0000000..3c49a8c --- /dev/null +++ b/src/app/(public)/login/page.tsx @@ -0,0 +1,10 @@ +import { redirect } from "next/navigation"; +import { isSetupDone } from "@/server/auth"; +import { LoginForm } from "./LoginForm"; + +export const dynamic = "force-dynamic"; + +export default async function LoginPage() { + if (!(await isSetupDone())) redirect("/setup"); + return ; +} diff --git a/src/app/(public)/setup/SetupForm.tsx b/src/app/(public)/setup/SetupForm.tsx new file mode 100644 index 0000000..2160a0c --- /dev/null +++ b/src/app/(public)/setup/SetupForm.tsx @@ -0,0 +1,82 @@ +"use client"; + +import { useActionState, useState } from "react"; +import { setupAction } from "@/server/actions/auth"; +import { Button } from "@/components/ui/Button"; +import { Card, CardLabel } from "@/components/ui/Card"; +import { Field, FormError, Input, Select } from "@/components/ui/Field"; + +function PersonBlock({ i, defaultColor, title, values }: { i: number; defaultColor: string; title: string; values?: Record }) { + return ( +
+ {title} +
+ + + + + + +
+ + + + + + + + + +
+ ); +} + +export function SetupForm() { + const [state, action, pending] = useActionState(setupAction, { error: null }); + const [percent, setPercent] = useState("50"); + return ( + +

Bienvenue 👋

+

Créons vos deux comptes. Tout reste modifiable ensuite dans les Réglages.

+
+
+ + +
+ +
+ Répartition par défaut des dépenses +
+ setPercent(e.target.value)} + inputMode="decimal" + className="w-24" + /> + + % pour la personne 1, {Math.max(0, 100 - (Number(percent.replace(",", ".")) || 0))} % pour la personne 2 + +
+
+ +
+ Solde d'ouverture (facultatif) +

Si l'un doit déjà de l'argent à l'autre au démarrage.

+
+ + +
+
+ + + + +
+ ); +} diff --git a/src/app/(public)/setup/page.tsx b/src/app/(public)/setup/page.tsx new file mode 100644 index 0000000..9cb9e35 --- /dev/null +++ b/src/app/(public)/setup/page.tsx @@ -0,0 +1,10 @@ +import { redirect } from "next/navigation"; +import { isSetupDone } from "@/server/auth"; +import { SetupForm } from "./SetupForm"; + +export const dynamic = "force-dynamic"; + +export default async function SetupPage() { + if (await isSetupDone()) redirect("/login"); + return ; +} diff --git a/src/app/globals.css b/src/app/globals.css index a2dc41e..8f81c59 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -1,26 +1,32 @@ @import "tailwindcss"; -:root { - --background: #ffffff; - --foreground: #171717; -} - -@theme inline { - --color-background: var(--background); - --color-foreground: var(--foreground); - --font-sans: var(--font-geist-sans); - --font-mono: var(--font-geist-mono); -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } +/* Langage visuel de la maquette validée (dashboard-v2.html). */ +@theme { + --font-sans: var(--font-inter), system-ui, sans-serif; + --color-page: #f5f6fa; + --color-card: #ffffff; + --color-line: #e5e7eb; + --color-line-soft: #f1f2f5; + --color-ink: #111827; + --color-muted: #6b7280; + --color-accent: #4f46e5; + --color-accent-soft: #eef2ff; + --color-pos: #059669; + --color-pos-soft: #ecfdf5; + --color-neg: #dc2626; + --color-neg-soft: #fef2f2; + --color-warn: #d97706; + --color-warn-soft: #fffbeb; + --color-warn-line: #fde68a; + --radius-card: 14px; } body { - background: var(--background); - color: var(--foreground); - font-family: Arial, Helvetica, sans-serif; + background: var(--color-page); + color: var(--color-ink); + font-size: 14px; +} + +.tabular { + font-variant-numeric: tabular-nums; } diff --git a/src/app/layout.tsx b/src/app/layout.tsx index f7fa87e..b77ca4e 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,34 +1,20 @@ -import type { Metadata } from "next"; -import { Geist, Geist_Mono } from "next/font/google"; +import type { Metadata, Viewport } from "next"; +import { Inter } from "next/font/google"; import "./globals.css"; -const geistSans = Geist({ - variable: "--font-geist-sans", - subsets: ["latin"], -}); - -const geistMono = Geist_Mono({ - variable: "--font-geist-mono", - subsets: ["latin"], -}); +const inter = Inter({ variable: "--font-inter", subsets: ["latin"] }); export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", + title: "Finances du foyer", + description: "Suivi des entrées, dépenses et charges partagées du foyer", }; -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { +export const viewport: Viewport = { width: "device-width", initialScale: 1, themeColor: "#f5f6fa" }; + +export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) { return ( - - - {children} - + + {children} ); } diff --git a/src/app/page.tsx b/src/app/page.tsx deleted file mode 100644 index a932894..0000000 --- a/src/app/page.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import Image from "next/image"; - -export default function Home() { - return ( -
-
- Next.js logo -
    -
  1. - Get started by editing{" "} - - src/app/page.tsx - - . -
  2. -
  3. - Save and see your changes instantly. -
  4. -
- - -
- -
- ); -} diff --git a/src/components/Logo.tsx b/src/components/Logo.tsx new file mode 100644 index 0000000..53ec5d1 --- /dev/null +++ b/src/components/Logo.tsx @@ -0,0 +1,8 @@ +export function Logo() { + return ( +
+ € + Finances +
+ ); +} diff --git a/src/components/ui/Button.tsx b/src/components/ui/Button.tsx new file mode 100644 index 0000000..80ab4d9 --- /dev/null +++ b/src/components/ui/Button.tsx @@ -0,0 +1,23 @@ +import type { ButtonHTMLAttributes } from "react"; + +type Variant = "primary" | "ghost" | "danger" | "subtle"; + +const VARIANTS: Record = { + primary: "bg-accent text-white hover:bg-indigo-700", + ghost: "border border-line bg-white text-ink hover:bg-gray-50", + danger: "border border-red-200 bg-white text-neg hover:bg-neg-soft", + subtle: "text-accent hover:bg-accent-soft", +}; + +export function Button({ + variant = "primary", + className = "", + ...props +}: ButtonHTMLAttributes & { variant?: Variant }) { + return ( +