All files / app/resources CouchersLogo.tsx

100% Statements 13/13
100% Branches 4/4
100% Functions 4/4
100% Lines 12/12

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 433x 3x 3x 3x   3x   28x                         15x 28x   28x 14x       28x             84x              
import { styled, SvgIcon } from "@mui/material";
import Link from "next/link";
import { useEffect, useState } from "react";
import { baseRoute, dashboardRoute } from "routes";
 
import { COUCHERS_LOGO_PATHS, COUCHERS_LOGO_VIEWBOX } from "./couchersLogoPaths";
 
const Logo = styled(SvgIcon)(({ theme }) => ({
  fill: "var(--mui-palette-secondary-main)",
  height: theme.typography.pxToRem(40),
  width: theme.typography.pxToRem(40),
  display: "flex",
  position: "relative",
}));
 
interface CouchersLogoProps {
  className?: string;
  isLoggedIn?: boolean;
}
 
export default function CouchersLogo({ className, isLoggedIn }: CouchersLogoProps) {
  const [isMounted, setIsMounted] = useState(false);
 
  useEffect(() => {
    setIsMounted(true);
  }, []);
 
  // During SSR and before hydration, always use baseRoute to prevent mismatch
  const href = isMounted ? (isLoggedIn ? dashboardRoute : baseRoute) : baseRoute;
 
  return (
    <Link href={href}>
      <Logo className={className} xmlns="http://www.w3.org/2000/svg" viewBox={COUCHERS_LOGO_VIEWBOX}>
        <g>
          {COUCHERS_LOGO_PATHS.map((d) => (
            <path key={d} d={d} />
          ))}
        </g>
      </Logo>
    </Link>
  );
}