import { useState, useEffect, useRef } from "react"; import { RED, GREEN } from "../constants/index.js"; import { useApp } from "../context/AppContext.jsx"; const getToken = () => localStorage.getItem("vf_token"); const authHdrs = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${getToken()}` }); async function apiFetch(path, options = {}) { const res = await fetch(`/api${path}`, { ...options, headers: { ...authHdrs(), ...(options.headers || {}) } }); if (!res.ok) { const data = await res.json().catch(() => ({})); throw new Error(data.error || `HTTP ${res.status}`); } return res.json(); } function fmtDatum(iso) { if (!iso) return "—"; const d = new Date(iso); return `${d.getDate()}-${d.getMonth() + 1}-${d.getFullYear()}`; } function RolSelect({ value, onChange, opties, T, darkMode }) { const [open, setOpen] = useState(false); const ref = useRef(null); useEffect(() => { const handler = (e) => { if (ref.current && !ref.current.contains(e.target)) setOpen(false); }; document.addEventListener("mousedown", handler); return () => document.removeEventListener("mousedown", handler); }, []); return (
| Naam | Aangemaakt | Admin | ||
|---|---|---|---|---|
|
{initials}
{u.naam}
{isSelf && (
jij
)}
|
{u.email} | {fmtDatum(u.aangemaakt)} | {u.rol === "Admin" ? ⭐ : — } |
{!isSelf && (
<>
>
)}
|