import React, { useState, useEffect } from 'react' export default function AdminUsers() { const [users, setUsers] = useState([]) const [msg, setMsg] = useState(null) useEffect(() => { fetch('/api/v1/admin/users', { credentials: 'include' }).then(r => r.json()).then(setUsers).catch(() => setUsers([])) }, []) function setRole(id, role) { fetch(`/api/v1/admin/users/${id}/role`, { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ role }) }) .then(r => r.json()).then(() => setMsg('Role updated')) .catch(() => setMsg('Failed')) } return (