// Auteur : Simon-Pierre Boucher — contact@spboucher.ai "use client"; import { useState } from "react"; import { ROLES } from "@/lib/roles"; export default function RolePicker({ current }: { current: string | null }) { const [busy, setBusy] = useState(null); const [error, setError] = useState(null); async function pick(role: string) { setBusy(role); setError(null); const res = await fetch("/api/profile/role", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ role }), }); if (res.ok) window.location.reload(); else { setError("Impossible d'enregistrer — réessayez."); setBusy(null); } } return (
{Object.entries(ROLES).map(([value, r]) => ( ))}
{error && (

{error}

)}
); }