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
+11
-1
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { LogOutIcon, RefreshCwIcon } from "lucide-react";
|
||||
import { EyeIcon, LogOutIcon, RefreshCwIcon } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
@@ -11,6 +11,7 @@ import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Toaster } from "@/components/ui/sonner";
|
||||
import { goToAdminLogin, signOut } from "@/lib/admin-auth";
|
||||
import { api, ApiError } from "@/lib/api";
|
||||
import { canEditCalendar } from "@/lib/permissions";
|
||||
import type { AdminUser } from "@/lib/types";
|
||||
|
||||
type Failure = "denied" | "unavailable";
|
||||
@@ -82,6 +83,15 @@ export default function AdminLayout({ children }: { children: React.ReactNode })
|
||||
) : (
|
||||
<Skeleton className="hidden h-4 w-24 sm:block" />
|
||||
)}
|
||||
{me && !canEditCalendar(me) && (
|
||||
<span
|
||||
className="inline-flex h-6 items-center gap-1 rounded-full bg-muted px-2 text-xs font-medium text-muted-foreground"
|
||||
title="Dein Konto darf den Kalender ansehen, aber nichts ändern."
|
||||
>
|
||||
<EyeIcon aria-hidden className="size-3.5" />
|
||||
Nur lesen
|
||||
</span>
|
||||
)}
|
||||
{me && <SubscriptionsDialog />}
|
||||
<Button variant="ghost" size="sm" onClick={() => void signOut()} aria-label="Abmelden">
|
||||
<LogOutIcon />
|
||||
|
||||
Reference in new issue
Block a user