Refactored volunteer check_in as ready status.
This commit is contained in:
parent
e722ef055e
commit
40ebaf07bf
7 changed files with 48 additions and 28 deletions
|
|
@ -78,7 +78,7 @@ export const api = {
|
|||
create: (data) => apiJSON('/api/volunteers', { method: 'POST', body: JSON.stringify(data) }),
|
||||
update: (id, data) => apiJSON(`/api/volunteers/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
||||
delete: (id) => apiFetch(`/api/volunteers/${id}`, { method: 'DELETE' }),
|
||||
checkIn: (id) => apiJSON(`/api/volunteers/${id}/checkin`, { method: 'POST' }),
|
||||
markReady: (id) => apiJSON(`/api/volunteers/${id}/ready`, { method: 'POST' }),
|
||||
confirm: (id) => apiJSON(`/api/volunteers/${id}/confirm`, { method: 'POST' }),
|
||||
assignShift: (id, shiftId) => apiFetch(`/api/volunteers/${id}/shifts`, { method: 'POST', body: JSON.stringify({ shift_id: shiftId }) }),
|
||||
unassignShift: (id, shiftId) => apiFetch(`/api/volunteers/${id}/shifts/${shiftId}`, { method: 'DELETE' }),
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@
|
|||
</script>
|
||||
|
||||
<button class="btn btn-success btn-sm" onclick={handle} disabled={loading}>
|
||||
{loading ? '…' : '✓ Ready'}
|
||||
{loading ? '…' : 'Mark ready'}
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
return vols
|
||||
})
|
||||
const volTotal = $derived(volunteers.length)
|
||||
const volCheckedIn = $derived(volunteers.filter(v => v.checked_in).length)
|
||||
const volCheckedIn = $derived(volunteers.filter(v => v.ready).length)
|
||||
const volLeads = $derived(volunteers.filter(v => v.is_lead).length)
|
||||
|
||||
// Shift stats (scoped for colead)
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@
|
|||
if (filterDept && v.department_id !== parseInt(filterDept)) return false
|
||||
if (filterStatus === 'unconfirmed' && v.email_confirmed) return false
|
||||
if (filterStatus === 'registered' && (!v.email_confirmed || v.confirmed)) return false
|
||||
if (filterStatus === 'confirmed' && (!v.confirmed || v.checked_in)) return false
|
||||
if (filterStatus === 'ready' && !v.checked_in) return false
|
||||
if (filterStatus === 'confirmed' && (!v.confirmed || v.ready)) return false
|
||||
if (filterStatus === 'ready' && !v.ready) return false
|
||||
if (s && !v.name.toLowerCase().includes(s) &&
|
||||
!(v.email || '').toLowerCase().includes(s)) return false
|
||||
return true
|
||||
|
|
@ -63,9 +63,9 @@
|
|||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
})
|
||||
|
||||
async function checkIn(v) {
|
||||
async function markReady(v) {
|
||||
try {
|
||||
const updated = await api.volunteers.checkIn(v.id)
|
||||
const updated = await api.volunteers.markReady(v.id)
|
||||
await db.volunteers.put(updated)
|
||||
} catch (err) {
|
||||
error = err.message
|
||||
|
|
@ -314,7 +314,7 @@
|
|||
{/if}
|
||||
</td>
|
||||
<td class="td-status">
|
||||
{#if v.checked_in}
|
||||
{#if v.ready}
|
||||
<span class="badge badge-checked">Ready</span>
|
||||
{:else if v.confirmed}
|
||||
<span class="badge badge-confirmed">Confirmed</span>
|
||||
|
|
@ -323,15 +323,15 @@
|
|||
{:else}
|
||||
<span class="badge badge-unchecked">Unconfirmed</span>
|
||||
{/if}
|
||||
{#if v.checked_in_at}
|
||||
{#if v.ready_at}
|
||||
<div class="text-muted" style="font-size:0.75rem">
|
||||
{new Date(v.checked_in_at).toLocaleTimeString()}
|
||||
{new Date(v.ready_at).toLocaleTimeString()}
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
<td class="td-ready">
|
||||
{#if !v.checked_in}
|
||||
<CheckInButton onclick={() => checkIn(v)} />
|
||||
{#if v.confirmed && !v.ready}
|
||||
<CheckInButton onclick={() => markReady(v)} />
|
||||
{/if}
|
||||
</td>
|
||||
{#if canManage}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue