feat: migrate showcase to Next.js and overhaul CRM UI

- rebuild the public site on the Next.js App Router with static export,
  per-section SEO pages, metadata, sitemap, robots and a generated OG image
- add full-screen scroll-snap regions, staged scroll reveals, a hash-free
  tab navigation with a sliding indicator and region-by-region menu scrolling
- replace the theme text toggle with animated sun/moon icons
- restructure the CRM API into config, middleware, models, routes, services
  and utils layers
- redesign the CRM shell with a single surface, tab rail, full-width blurred
  DataTable, record dialogs and mask-based icons
- update Docker/Nginx publishing, Makefile targets, shared UI polish and docs
This commit is contained in:
2026-11-16 00:52:29 +01:00
parent ab4cde1ce2
commit 09cf07d79b
113 changed files with 6427 additions and 2364 deletions
+15
View File
@@ -0,0 +1,15 @@
/** Erreurs de contrainte MariaDB, reconnues par leur code numérique. */
const errnoOf = (error: unknown): number | undefined =>
typeof error === "object" && error !== null && "errno" in error
? ((error as { errno?: number }).errno ?? undefined)
: undefined;
/** 1062 : violation d'index unique. */
export const isDuplicateEntry = (error: unknown): boolean => errnoOf(error) === 1062;
/** 1452 : la ligne référencée par une clé étrangère n'existe pas. */
export const isForeignKeyViolation = (error: unknown): boolean => errnoOf(error) === 1452;
/** 1451 : la ligne est encore référencée, suppression impossible. */
export const isReferencedRow = (error: unknown): boolean => errnoOf(error) === 1451;
+15
View File
@@ -0,0 +1,15 @@
/** Normalisations de texte partagées par les services. */
/** Slug lisible : sans accent, sans ponctuation, séparé par des tirets. */
export const slugify = (value: string): string =>
value
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "")
.slice(0, 255);
/** Un e-mail absent ne doit pas heurter l'index unique : NULL passe partout. */
export const normalizeEmail = (value: string | null | undefined): string | null =>
value ? value.toLowerCase() : null;
+22
View File
@@ -0,0 +1,22 @@
import { DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE } from "../config/app.js";
export interface Pagination {
page: number;
limit: number;
offset: number;
}
const positiveInt = (raw: string | undefined, fallback: number): number => {
const value = Number(raw ?? fallback);
return Number.isFinite(value) && value >= 1 ? Math.floor(value) : fallback;
};
/** Lit `page`/`limit` depuis la query string et borne les valeurs. */
export const parsePagination = (
pageRaw: string | undefined,
limitRaw: string | undefined,
): Pagination => {
const page = Math.max(1, positiveInt(pageRaw, 1));
const limit = Math.min(MAX_PAGE_SIZE, Math.max(1, positiveInt(limitRaw, DEFAULT_PAGE_SIZE)));
return { page, limit, offset: (page - 1) * limit };
};
+33
View File
@@ -0,0 +1,33 @@
export interface RateLimitOptions {
/** Fenêtre glissante, en millisecondes. */
windowMs: number;
/** Nombre d'essais autorisés dans la fenêtre. */
max: number;
}
export interface RateLimiter {
/** Enregistre une tentative et indique si elle est autorisée. */
isAllowed: (key: string) => boolean;
}
/**
* Rate-limit en mémoire, suffisant pour une instance CRM unique. Derrière
* nginx/Cloudflare, la clé vient de l'IP transmise par `x-forwarded-for`.
*/
export const createRateLimiter = ({ windowMs, max }: RateLimitOptions): RateLimiter => {
const attempts = new Map<string, number[]>();
return {
isAllowed: (key) => {
const now = Date.now();
const recent = (attempts.get(key) ?? []).filter((time) => now - time < windowMs);
if (recent.length >= max) {
attempts.set(key, recent);
return false;
}
recent.push(now);
attempts.set(key, recent);
return true;
},
};
};
+22
View File
@@ -0,0 +1,22 @@
/** Construction des `UPDATE` partiels, sans jamais concaténer de valeurs. */
export interface Assignments {
clause: string;
values: unknown[];
}
/**
* Transforme `{ city: "Lyon", phone: undefined }` en `city = ?`.
* `null` reste une valeur explicite : elle efface la colonne.
* Retourne `null` quand aucune colonne n'est fournie.
*/
export const buildAssignments = (
columns: Record<string, unknown>,
): Assignments | null => {
const keys = Object.keys(columns).filter((key) => columns[key] !== undefined);
if (keys.length === 0) return null;
return {
clause: keys.map((key) => `${key} = ?`).join(", "),
values: keys.map((key) => columns[key]),
};
};
+20
View File
@@ -0,0 +1,20 @@
import { z } from "zod";
import { AppError } from "@cohaise/server";
/** Identifiant UUID v4 tel que stocké par les tables du CRM. */
export const uuidSchema = z
.string()
.regex(
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
"Identifiant invalide.",
);
/** Erreur 400 homogène pour un corps JSON invalide. */
export const invalidBody = (error: z.ZodError): AppError => {
const issue = error.issues[0];
return AppError.badRequest(
issue
? `${issue.path.join(".") || "corps"} : ${issue.message}`
: "Corps invalide.",
);
};