Rescoped colead role and revised session handling.
This commit is contained in:
parent
da5f3524fa
commit
7dbcd05262
12 changed files with 376 additions and 50 deletions
|
|
@ -84,7 +84,6 @@
|
|||
|
||||
const path = $derived(route || '/')
|
||||
const roles = $derived(session?.user?.roles ?? [])
|
||||
function hasRole(...allowed) { return roles.some(r => allowed.includes(r)) }
|
||||
</script>
|
||||
|
||||
{#if updateAvailable}
|
||||
|
|
@ -125,7 +124,7 @@
|
|||
{#if roles.length === 1 && roles[0] === 'colead'}
|
||||
<ScheduleBoard {session} />
|
||||
{:else}
|
||||
<Dashboard {session} />
|
||||
<Dashboard {session} {navigate} />
|
||||
{/if}
|
||||
{:else if path.startsWith('/participants')}
|
||||
<Participants {session} />
|
||||
|
|
|
|||
|
|
@ -80,6 +80,18 @@ export async function saveSession(token, user) {
|
|||
}
|
||||
|
||||
export async function clearSession() {
|
||||
await db.session.clear()
|
||||
await db.meta.clear()
|
||||
await db.transaction('rw',
|
||||
[db.session, db.meta, db.event, db.participants, db.tickets, db.departments, db.volunteers, db.shifts, db.volunteer_shifts],
|
||||
async () => {
|
||||
await db.session.clear()
|
||||
await db.meta.clear()
|
||||
await db.event.clear()
|
||||
await db.participants.clear()
|
||||
await db.tickets.clear()
|
||||
await db.departments.clear()
|
||||
await db.volunteers.clear()
|
||||
await db.shifts.clear()
|
||||
await db.volunteer_shifts.clear()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import { liveQuery } from 'dexie'
|
||||
import { db } from '../db.js'
|
||||
|
||||
let { session } = $props()
|
||||
let { session, navigate } = $props()
|
||||
|
||||
const roles = $derived(session?.user?.roles ?? [])
|
||||
function hasRole(...allowed) { return roles.some(r => allowed.includes(r)) }
|
||||
|
|
@ -147,14 +147,14 @@
|
|||
<!-- Quick actions -->
|
||||
{#if isAdmin}
|
||||
<div class="dash-actions">
|
||||
<a href="/import" class="btn btn-ghost btn-sm">Import CSV</a>
|
||||
<a href="/participants" class="btn btn-ghost btn-sm">Manage Participants</a>
|
||||
<a href="/settings" class="btn btn-ghost btn-sm">Settings</a>
|
||||
<a href="/import" class="btn btn-ghost btn-sm" onclick={(e) => { e.preventDefault(); navigate('/import') }}>Import CSV</a>
|
||||
<a href="/participants" class="btn btn-ghost btn-sm" onclick={(e) => { e.preventDefault(); navigate('/participants') }}>Manage Participants</a>
|
||||
<a href="/settings" class="btn btn-ghost btn-sm" onclick={(e) => { e.preventDefault(); navigate('/settings') }}>Settings</a>
|
||||
</div>
|
||||
{:else if isStaffing || isColead}
|
||||
<div class="dash-actions">
|
||||
<a href="/schedule" class="btn btn-ghost btn-sm">View Schedule</a>
|
||||
<a href="/volunteers" class="btn btn-ghost btn-sm">Manage Volunteers</a>
|
||||
<a href="/schedule" class="btn btn-ghost btn-sm" onclick={(e) => { e.preventDefault(); navigate('/schedule') }}>View Schedule</a>
|
||||
<a href="/volunteers" class="btn btn-ghost btn-sm" onclick={(e) => { e.preventDefault(); navigate('/volunteers') }}>Manage Volunteers</a>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
|
|
|||
|
|
@ -135,11 +135,13 @@
|
|||
|
||||
try {
|
||||
const res = await api.shifts.reorder(positions)
|
||||
if (res && !res.ok) throw new Error()
|
||||
for (const p of positions) {
|
||||
const s = await db.shifts.get(p.id)
|
||||
if (s) await db.shifts.put({ ...s, position: p.position })
|
||||
}
|
||||
if (res && !res.ok) throw new Error('Reorder failed')
|
||||
await db.transaction('rw', db.shifts, async () => {
|
||||
for (const p of positions) {
|
||||
const s = await db.shifts.get(p.id)
|
||||
if (s) await db.shifts.put({ ...s, position: p.position })
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
error = err.message
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ async function checkBuildChanged() {
|
|||
await db.volunteers.clear()
|
||||
await db.shifts.clear()
|
||||
await db.volunteer_shifts.clear()
|
||||
await db.meta.put({ key: 'build', value: build })
|
||||
}
|
||||
)
|
||||
}
|
||||
await db.meta.put({ key: 'build', value: build })
|
||||
} catch {}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue