Scaffold full-stack volunteer scheduling application
Go backend with domain-based packages (volunteer, schedule, timeoff, checkin, notification), SQLite storage, JWT auth, and chi router. React TypeScript frontend with routing, auth context, and pages for all core features. Multi-stage Dockerfile and docker-compose included. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
57
web/src/pages/Volunteers.tsx
Normal file
57
web/src/pages/Volunteers.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { api, Volunteer } from '../api';
|
||||
|
||||
export default function Volunteers() {
|
||||
const [volunteers, setVolunteers] = useState<Volunteer[]>([]);
|
||||
const [error, setError] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
api.listVolunteers().then(setVolunteers).catch(() => setError('Could not load volunteers.'));
|
||||
}, []);
|
||||
|
||||
async function handleToggleActive(v: Volunteer) {
|
||||
try {
|
||||
const updated = await api.updateVolunteer(v.id, { active: !v.active });
|
||||
setVolunteers(prev => prev.map(vol => vol.id === v.id ? updated : vol));
|
||||
} catch (err: any) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<h2>Volunteers</h2>
|
||||
{error && <p className="error">{error}</p>}
|
||||
{volunteers.length === 0 ? (
|
||||
<p>No volunteers found.</p>
|
||||
) : (
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Role</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{volunteers.map(v => (
|
||||
<tr key={v.id}>
|
||||
<td>{v.name}</td>
|
||||
<td>{v.email}</td>
|
||||
<td>{v.role}</td>
|
||||
<td>{v.active ? 'Active' : 'Inactive'}</td>
|
||||
<td>
|
||||
<button className="btn-small" onClick={() => handleToggleActive(v)}>
|
||||
{v.active ? 'Deactivate' : 'Activate'}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user