mirror of
https://github.com/R0m1k3/PleinR.git
synced 2026-10-22 22:58:04 +02:00
Logo annuaire + modals devenir membre & contact
- Logo en haut a gauche de la page Annuaire (prop logo sur SiteHeader) - Modal "Devenir adherent" sur les CTA accueil + annuaire : cree une demande d'adhesion (membership_requests) et alerte les admins via le journal d'activite (compteur tableau de bord deja cable) - Formulaire de contact (modal depuis le pied de page) : nouvelle table contact_messages + alerte admin - Composant Modal partage, server actions publiques (sans auth) - Migration drizzle 0002 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
e2cf03c9f3
commit
141acffc1c
12 files changed
+1057
-17
No files matched your search
@@ -0,0 +1,116 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Modal } from "./Modal";
|
||||
import { submitMembershipRequest } from "@/app/actions/public";
|
||||
|
||||
export function MembershipModalButton({
|
||||
label,
|
||||
className,
|
||||
style,
|
||||
}: {
|
||||
label: string;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [pending, setPending] = useState(false);
|
||||
const [done, setDone] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
function close() {
|
||||
setOpen(false);
|
||||
// Réinitialise après la fermeture (laisse l'animation finir).
|
||||
setTimeout(() => {
|
||||
setDone(false);
|
||||
setError(null);
|
||||
}, 200);
|
||||
}
|
||||
|
||||
async function onSubmit(e: React.FormEvent<HTMLFormElement>) {
|
||||
e.preventDefault();
|
||||
setPending(true);
|
||||
setError(null);
|
||||
const res = await submitMembershipRequest(new FormData(e.currentTarget));
|
||||
setPending(false);
|
||||
if (res.ok) setDone(true);
|
||||
else setError(res.error ?? "Une erreur est survenue.");
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<button type="button" className={className} style={{ cursor: "pointer", ...style }} onClick={() => setOpen(true)}>
|
||||
{label}
|
||||
</button>
|
||||
|
||||
<Modal open={open} onClose={close} title="Devenir adhérent">
|
||||
{done ? (
|
||||
<div style={{ textAlign: "center", padding: "10px 0 6px" }}>
|
||||
<div style={{ fontSize: 40, marginBottom: 8 }}>✓</div>
|
||||
<p style={{ margin: "0 0 18px", fontSize: 15, color: "#4a4030" }}>
|
||||
Demande envoyée ! L'équipe Plein R vous recontactera rapidement.
|
||||
</p>
|
||||
<button type="button" className="lift-cta" onClick={close} style={primaryBtn}>
|
||||
Fermer
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<form onSubmit={onSubmit}>
|
||||
<p style={{ margin: "0 0 18px", fontSize: 14, color: "#6c6150" }}>
|
||||
Laissez vos coordonnées : nous revenons vers vous pour finaliser votre adhésion.
|
||||
</p>
|
||||
|
||||
<Field label="Nom / Raison sociale *">
|
||||
<input name="name" required maxLength={200} className="field" placeholder="Votre nom ou entreprise" />
|
||||
</Field>
|
||||
<Field label="E-mail">
|
||||
<input name="email" type="email" maxLength={200} className="field" placeholder="vous@exemple.fr" />
|
||||
</Field>
|
||||
<Field label="Téléphone">
|
||||
<input name="phone" maxLength={40} className="field" placeholder="06 12 34 56 78" />
|
||||
</Field>
|
||||
<Field label="Message">
|
||||
<textarea name="message" rows={4} maxLength={2000} className="field" placeholder="Votre activité, vos questions…" style={{ resize: "vertical" }} />
|
||||
</Field>
|
||||
|
||||
{error && <div style={errorBox}>{error}</div>}
|
||||
|
||||
<button type="submit" className="lift-cta" disabled={pending} style={{ ...primaryBtn, opacity: pending ? 0.6 : 1 }}>
|
||||
{pending ? "Envoi…" : "Envoyer ma demande"}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Field({ label, children }: { label: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<div style={{ marginBottom: 14 }}>
|
||||
<label className="field-label">{label}</label>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const primaryBtn: React.CSSProperties = {
|
||||
width: "100%",
|
||||
border: "none",
|
||||
background: "#9a6638",
|
||||
color: "#fff",
|
||||
fontWeight: 700,
|
||||
fontSize: 15,
|
||||
padding: "13px 18px",
|
||||
borderRadius: 12,
|
||||
cursor: "pointer",
|
||||
};
|
||||
|
||||
const errorBox: React.CSSProperties = {
|
||||
background: "#fbe8e6",
|
||||
color: "#a3372e",
|
||||
fontSize: 13,
|
||||
padding: "10px 12px",
|
||||
borderRadius: 10,
|
||||
marginBottom: 14,
|
||||
};
|
||||
Reference in new issue
Block a user