All files / src/views/fallback AccessDeniedView.tsx

97.22% Statements 35/36
25% Branches 1/4
50% Functions 1/2
97.22% Lines 35/36

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 491x 1x 1x                   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x   1x  
import { Link } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import '@/styles/fallback.css';
 
interface AccessDeniedViewProps {
  title?: string;
  message?: string;
  actionText?: string;
  actionTo?: string;
  isPrivateEvent?: boolean;
}
 
export default function AccessDeniedView({
  title,
  message,
  actionText,
  actionTo = '/discover',
  isPrivateEvent = false,
}: AccessDeniedViewProps) {
  const { t } = useTranslation();
  const resolvedTitle = title ?? t('fallback.access_denied.heading');
  const displayMessage = isPrivateEvent
    ? t('fallback.access_denied.private_event_body')
    : (message ?? t('fallback.access_denied.body'));
  const resolvedAction = actionText ?? t('fallback.access_denied.back_discover');
 
  return (
    <div className="fallback-page">
      <div className="fallback-content">
        <div className="fallback-icon">🔒</div>
        <h1 className="fallback-title">{resolvedTitle}</h1>
        <p className="fallback-desc">{displayMessage}</p>
        <div className="fallback-actions">
          <Link to={actionTo} className="fallback-btn-primary">
            {resolvedAction}
          </Link>
          <button
            type="button"
            className="fallback-btn-secondary"
            onClick={() => window.history.back()}
          >
            {t('fallback.access_denied.go_back')}
          </button>
        </div>
      </div>
    </div>
  );
}