|
|
@@ -20,11 +20,10 @@ import {
|
|
|
/**
|
|
|
* ForbiddenView (RHL-021)
|
|
|
*
|
|
|
- * A reusable UI block for "you are authenticated, but not allowed here".
|
|
|
+ * Reusable UI block for "authenticated, but not allowed here".
|
|
|
*
|
|
|
- * It relies on AuthContext when available to render the best CTA:
|
|
|
- * - branch users -> link to their own branch root
|
|
|
- * - admin/dev -> link to home (later: could link to a branch list)
|
|
|
+ * UX rule:
|
|
|
+ * - All user-facing text must be German.
|
|
|
*/
|
|
|
export default function ForbiddenView({ attemptedBranch = null }) {
|
|
|
const { status, user } = useAuth();
|
|
|
@@ -32,42 +31,51 @@ export default function ForbiddenView({ attemptedBranch = null }) {
|
|
|
const isAuthed = status === "authenticated" && user;
|
|
|
const isBranchUser = isAuthed && user.role === "branch" && user.branchId;
|
|
|
|
|
|
- const primaryHref = isBranchUser ? branchPath(user.branchId) : homePath();
|
|
|
- const primaryLabel = isBranchUser ? "Go to my branch" : "Go to home";
|
|
|
+ const overviewHref = homePath();
|
|
|
+
|
|
|
+ const primaryHref = isBranchUser ? branchPath(user.branchId) : overviewHref;
|
|
|
+ const primaryLabel = isBranchUser
|
|
|
+ ? "Zu meiner Niederlassung"
|
|
|
+ : "Zur Übersicht";
|
|
|
+
|
|
|
+ const showSecondaryOverview = isBranchUser;
|
|
|
|
|
|
return (
|
|
|
<Card>
|
|
|
<CardHeader>
|
|
|
- <CardTitle>Access denied</CardTitle>
|
|
|
+ <CardTitle>Zugriff verweigert</CardTitle>
|
|
|
<CardDescription>
|
|
|
- You are not allowed to access this resource.
|
|
|
+ Sie haben keine Berechtigung, diese Ressource zu öffnen.
|
|
|
</CardDescription>
|
|
|
</CardHeader>
|
|
|
|
|
|
<CardContent className="space-y-4">
|
|
|
<Alert variant="destructive">
|
|
|
- <AlertTitle>Forbidden</AlertTitle>
|
|
|
+ <AlertTitle>Keine Berechtigung</AlertTitle>
|
|
|
<AlertDescription>
|
|
|
{attemptedBranch ? (
|
|
|
<span>
|
|
|
- Your account is not permitted to access branch{" "}
|
|
|
- <strong>{attemptedBranch}</strong>.
|
|
|
+ Ihr Konto darf die Niederlassung{" "}
|
|
|
+ <strong>{attemptedBranch}</strong> nicht öffnen.
|
|
|
</span>
|
|
|
) : (
|
|
|
- <span>Your account is not permitted to access this page.</span>
|
|
|
+ <span>Ihr Konto darf diese Seite nicht öffnen.</span>
|
|
|
)}
|
|
|
</AlertDescription>
|
|
|
</Alert>
|
|
|
|
|
|
<p className="text-sm text-muted-foreground">
|
|
|
- If you believe this is a mistake, please contact your administrator.
|
|
|
+ Wenn Sie glauben, dass das ein Fehler ist, wenden Sie sich an Ihren
|
|
|
+ Administrator.
|
|
|
</p>
|
|
|
</CardContent>
|
|
|
|
|
|
<CardFooter className="flex flex-col gap-2 sm:flex-row sm:justify-end">
|
|
|
- <Button variant="outline" asChild>
|
|
|
- <Link href={homePath()}>Home</Link>
|
|
|
- </Button>
|
|
|
+ {showSecondaryOverview ? (
|
|
|
+ <Button variant="outline" asChild>
|
|
|
+ <Link href={overviewHref}>Zur Übersicht</Link>
|
|
|
+ </Button>
|
|
|
+ ) : null}
|
|
|
|
|
|
<Button asChild>
|
|
|
<Link href={primaryHref}>{primaryLabel}</Link>
|