- Read-only role: /admin/me's permissions decide via canEditCalendar (lib/permissions.ts, mirrors the API's canWrite: only `access` writes). Read-only accounts see everything but get no "Neuer Termin", no "+", no "Veröffentlichen"; an event opens as "Termin ansehen" with locked fields. A "Nur lesen" badge in the header explains why. The API refuses their writes regardless. - The management calendar is labelled "Vorstand"; the slug stays `management` for the API, URLs and iCal links. - The subscription dialog's Apple/Google links are plain anchors styled with buttonVariants instead of Base UI Buttons rendering an <a>, which warned in dev and would have given them role="button". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
766 B
TypeScript
19 lines
766 B
TypeScript
import type { AdminUser } from "@/lib/types";
|
|
|
|
/**
|
|
* May this account change calendar events? Mirrors `canWrite` in the API's
|
|
* admin.schema.ts (docs/admin-roles.md there): only a grant with the role
|
|
* `access` allows changes; `read` ("Nur lesen") sees everything and changes
|
|
* nothing. The API refuses the writes regardless - this only decides which
|
|
* controls to show.
|
|
*
|
|
* An API that predates roles sends no `permissions`. Then every calendar user
|
|
* could write, so that is what this answers too.
|
|
*/
|
|
export const canEditCalendar = (user: Pick<AdminUser, "apps" | "permissions">): boolean => {
|
|
if (!user.permissions) {
|
|
return user.apps.includes("calendar");
|
|
}
|
|
return user.permissions.some((p) => p.app === "calendar" && p.role === "access");
|
|
};
|