All files / src/views/fallback NotFoundView.tsx

100% Statements 28/28
50% Branches 1/2
100% Functions 1/1
100% Lines 28/28

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 391x 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 NotFoundViewProps {
  title?: string;
  message?: string;
  actionText?: string;
  actionTo?: string;
}
 
export default function NotFoundView({
  title,
  message,
  actionText,
  actionTo = '/discover',
}: NotFoundViewProps) {
  const { t } = useTranslation();
  const resolvedHeading = title ?? t('fallback.not_found.heading');
  const resolvedMessage = message ?? t('fallback.not_found.body');
  const resolvedAction = actionText ?? t('fallback.not_found.back_discover');
  const isGeneric404 = title === undefined;
 
  return (
    <div className="fallback-page">
      <div className="fallback-content">
        <div className="fallback-icon">{isGeneric404 ? '404' : '👀'}</div>
        <h1 className="fallback-title">{resolvedHeading}</h1>
        <p className="fallback-desc">{resolvedMessage}</p>
        <div className="fallback-actions">
          <Link to={actionTo} className="fallback-btn-primary">
            {resolvedAction}
          </Link>
        </div>
      </div>
    </div>
  );
}