Support the read-only calendar role, show "Vorstand", fix link buttons
- 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>
This commit is contained in:
16 files changed
+155
-32
No files matched your search
+20
-13
@@ -6,6 +6,7 @@ import { toast } from "sonner";
|
||||
import { CalendarChips } from "@/components/admin/CalendarChips";
|
||||
import { EventList } from "@/components/admin/EventList";
|
||||
import { EventSheet, type SheetMode } from "@/components/admin/EventSheet";
|
||||
import { useCanEdit } from "@/components/admin/AdminSession";
|
||||
import { EventsToolbar } from "@/components/admin/EventsToolbar";
|
||||
import { PublishDialog } from "@/components/admin/PublishDialog";
|
||||
import { useEvents } from "@/components/admin/useEvents";
|
||||
@@ -32,6 +33,8 @@ export default function AdminPage() {
|
||||
|
||||
function EventsPage() {
|
||||
const [state, update] = useListState();
|
||||
// Read-only role: everything visible, no way to change it (the API refuses writes anyway).
|
||||
const canEdit = useCanEdit();
|
||||
const { events, loads, reload, refresh, upsertEvent, removeEvent } = useEvents();
|
||||
// Fixed per visit: "upcoming" should not reshuffle while someone is looking at it.
|
||||
const [now] = useState(() => new Date());
|
||||
@@ -138,10 +141,12 @@ function EventsPage() {
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<Button onClick={newEvent} className="hidden sm:inline-flex">
|
||||
<PlusIcon />
|
||||
Neuer Termin
|
||||
</Button>
|
||||
{canEdit && (
|
||||
<Button onClick={newEvent} className="hidden sm:inline-flex">
|
||||
<PlusIcon />
|
||||
Neuer Termin
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<EventsToolbar
|
||||
@@ -183,19 +188,21 @@ function EventsPage() {
|
||||
publishingId={publishingId}
|
||||
todayMarker={todayMarker}
|
||||
onOpen={(event) => openSheet({ kind: "edit", event })}
|
||||
onPublish={setConfirmPublish}
|
||||
onPublish={canEdit ? setConfirmPublish : undefined}
|
||||
onClearQuery={() => update({ query: "" })}
|
||||
/>
|
||||
|
||||
{/* Phones: a thumb-reach button instead of the header one. */}
|
||||
<Button
|
||||
onClick={newEvent}
|
||||
size="icon-lg"
|
||||
aria-label="Neuer Termin"
|
||||
className="fixed right-5 bottom-[calc(1.25rem+env(safe-area-inset-bottom))] z-20 size-14 rounded-full shadow-lg sm:hidden [&_svg:not([class*='size-'])]:size-6"
|
||||
>
|
||||
<PlusIcon />
|
||||
</Button>
|
||||
{canEdit && (
|
||||
<Button
|
||||
onClick={newEvent}
|
||||
size="icon-lg"
|
||||
aria-label="Neuer Termin"
|
||||
className="fixed right-5 bottom-[calc(1.25rem+env(safe-area-inset-bottom))] z-20 size-14 rounded-full shadow-lg sm:hidden [&_svg:not([class*='size-'])]:size-6"
|
||||
>
|
||||
<PlusIcon />
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<EventSheet
|
||||
key={sheet.key}
|
||||
|
||||
Reference in new issue
Block a user