Files
punimtag/viewer-frontend/components/SignInRequiredDialog.tsx
T
ilia 0b4162de5f
CI / skip-ci-check (pull_request) Successful in 30s
CI / python-lint (pull_request) Successful in 31s
CI / docker-ci (pull_request) Successful in 33s
CI / secret-scan (pull_request) Successful in 35s
CI / viewer-unit (pull_request) Successful in 2m53s
CI / e2e (pull_request) Failing after 3m4s
CI / admin-unit (pull_request) Successful in 3m7s
Fix favorite sign-in copy and pale text-secondary contrast.
Logged-out favorite/report share a reason-aware SignInRequiredDialog so
favorites no longer show report messaging. Replace misplaced text-secondary
(light wash token) with foreground/primary on labels, auth, and menus.
2026-08-05 10:33:29 -04:00

86 lines
2.1 KiB
TypeScript

'use client';
import { Button } from '@/components/ui/button';
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog';
export type SignInRequiredReason = 'favorite' | 'report';
const COPY: Record<
SignInRequiredReason,
{ description: string; detail: string }
> = {
favorite: {
description:
'You need to be signed in to save favorites. Favorites stay with your account so you can find them later.',
detail: 'Please sign in or create an account to favorite photos.',
},
report: {
description:
'You need to be signed in to report photos. Your reports will be reviewed by administrators.',
detail: 'Please sign in or create an account to continue.',
},
};
type SignInRequiredDialogProps = {
open: boolean;
reason: SignInRequiredReason;
onOpenChange: (open: boolean) => void;
onSignIn: () => void;
onRegister: () => void;
};
export function SignInRequiredDialog({
open,
reason,
onOpenChange,
onSignIn,
onRegister,
}: SignInRequiredDialogProps) {
const copy = COPY[reason];
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-[500px]">
<DialogHeader>
<DialogTitle>Sign In Required</DialogTitle>
<DialogDescription>{copy.description}</DialogDescription>
</DialogHeader>
<div className="py-4">
<p className="mb-4 text-sm text-muted-foreground">{copy.detail}</p>
<div className="flex gap-2">
<Button
onClick={() => {
onSignIn();
}}
className="flex-1"
>
Sign in
</Button>
<Button
variant="outline"
onClick={() => {
onRegister();
}}
className="flex-1"
>
Register
</Button>
</div>
</div>
<DialogFooter>
<Button variant="outline" onClick={() => onOpenChange(false)}>
Cancel
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}