All files / Rindu/components/SetList SetList.tsx

26.66% Statements 4/15
0% Branches 0/4
0% Functions 0/2
30.76% Lines 4/13

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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146    19x   19x 19x 19x                                                                                                                                                                                                                                                                                      
import { ReactElement } from "react";
 
import Link from "next/link";
 
import { Heading } from "components";
import { useTranslations } from "hooks";
import { conjuction, getMonth, Locale, SetLists } from "utils";
 
export default function SetList({
  setLists,
  artistId,
}: Readonly<{
  setLists: SetLists | null;
  artistId?: string | null;
}>): ReactElement | null {
  const { translations, locale } = useTranslations();
 
  Iif (!setLists || !artistId) return null;
  return (
    <div className="set-list">
      <div className="set-list-content">
        <Heading number={2}>{translations.pages.artist.concerts}</Heading>
        {setLists?.setlist?.map((set, i) => {
          Iif (i > 4) return null;
          const date = set.eventDate.split("-");
 
          const year = date[2];
          const month = date[1];
          const day = date[0];
 
          return (
            <Link
              href={`/concert/${artistId}.${set.id}`}
              key={set.id}
              className="set"
            >
              <div className="set-date">
                <span className="month">
                  {getMonth(Number(month) - 1, locale)}
                </span>
                <span className="day">{day}</span>
                <span className="year">{year}</span>
              </div>
              <div className="set-info">
                <Heading number={5} as="h4">
                  {set.venue?.name}
                </Heading>
                <span>
                  {conjuction(
                    [
                      set.venue?.city.name,
                      set.venue?.city.state,
                      set.venue?.city.country.code,
                    ],
                    Locale.EN,
                    { type: "unit" }
                  )}
                </span>
              </div>
            </Link>
          );
        })}
      </div>
      <style jsx>{`
        .set-info span,
        .about :global(a) {
          color: #ffffffb3;
        }
        .set-list-content :global(a) {
          display: flex;
          padding: 8px;
          cursor: pointer;
          width: 100%;
          text-decoration: none;
        }
        .set-list-content :global(a:hover) {
          border-radius: 3px;
          background: #c6ccd317;
        }
        .set-info {
          margin-left: 18px;
          display: flex;
          flex-direction: column;
        }
        .set-info span {
          margin: 0;
          font-size: 14px;
        }
        .set-list {
          margin-left: 20px;
          flex: 40%;
          display: flex;
          flex-direction: column;
          align-items: center;
          z-index: 999999;
        }
        .month {
          text-align: left;
          text-transform: uppercase;
          font-weight: bold;
          font-size: 12px;
        }
        .day {
          font-weight: normal;
          color: inherit;
          text-transform: none;
          text-align: left;
          font-size: 24px;
        }
        .year {
          font-weight: normal;
          color: inherit;
          text-transform: none;
          text-align: left;
          font-size: 12px;
        }
        .set-date {
          display: flex;
          flex-direction: column;
          align-items: center;
          line-height: 1;
          font-size: 16px;
          width: fit-content;
          color: #ffffff;
        }
 
        @media (max-width: 768px) {
          .set-list {
            flex-direction: row;
            margin: 0;
          }
          .set-info {
            align-self: center;
          }
          .set-info :global(h4) {
            padding: 0;
          }
          .set-list-content :global(a) {
            margin-left: 4px;
          }
        }
      `}</style>
    </div>
  );
}