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): boolean => { if (!user.permissions) { return user.apps.includes("calendar"); } return user.permissions.some((p) => p.app === "calendar" && p.role === "access"); };