All files / client/src/views/admin/components HiddenProgramItemsList.tsx

66.66% Statements 4/6
100% Branches 2/2
100% Functions 3/3
66.66% Lines 4/6

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                        356x     57x   57x                           3x                                
import { ReactElement } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router";
import { sortBy } from "remeda";
import { getWeekdayAndTime } from "shared/utils/timeFormatter";
import { ProgramItem } from "shared/types/models/programItem";
import { AppRoute } from "client/app/AppRoutes";
 
interface Props {
  hiddenProgramItems: readonly ProgramItem[];
}
 
export const HiddenProgramItemsList = ({
  hiddenProgramItems,
}: Props): ReactElement => {
  const { t } = useTranslation();
 
  const sortedProgramItems = sortBy(hiddenProgramItems, (hiddenProgramItem) =>
    hiddenProgramItem.title.toLowerCase(),
  );
 
  return (
    <div>
      <h3>{t("hiddenProgramItems")}</h3>
 
      <ul>
        {hiddenProgramItems.length === 0 && (
          <span>{t("noHiddenProgramItems")}</span>
        )}
 
        {sortedProgramItems.map((programItem) => (
          <li key={programItem.programItemId}>
            <Link to={`${AppRoute.PROGRAM_ITEM}/${programItem.programItemId}`}>
              {programItem.title}
            </Link>
 
            {" - "}
            {t(`programType.${programItem.programType}`)}
            {" - "}
 
            {getWeekdayAndTime(programItem.startTime)}
          </li>
        ))}
      </ul>
    </div>
  );
};