Campus-scoped staff: frontend and e2e
Admin -> Users 'Limit to campuses'; staff campus pickers, reports, dashboards and audience picker follow the scope (useMyCampuses); scoped people pick one of their campuses for new events, and church-wide / other campuses' events open read-only; 'You work with ...' note; warning before turning campuses off while staff are limited. e2e: scanner refusal naming the campus, scoped events list and read-only editor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { apiFetch } from "@/lib/api";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
|
||||
export type Campus = {
|
||||
id: string;
|
||||
@@ -53,3 +54,15 @@ export function useCampuses() {
|
||||
}, []);
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* The campuses the signed-in person works with: for campus-scoped staff only their own campuses
|
||||
* (`scoped` true — they can't set up events for all campuses), for everyone else every campus.
|
||||
* Staff dropdowns use this; the public site uses useCampuses.
|
||||
*/
|
||||
export function useMyCampuses() {
|
||||
const all = useCampuses();
|
||||
const { user } = useAuth();
|
||||
const scope = all.enabled ? user?.campusScope || null : null;
|
||||
return { ...all, scoped: !!scope, campuses: scope ? all.campuses.filter(c => scope.includes(c.id)) : all.campuses };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user