import { observer } from "mobx-react-lite";

// constants
import { DAYS_LIST } from "constants/calendar";

type Props = {
  isLoading: boolean;
  showWeekends: boolean;
};

export const CalendarWeekHeader: React.FC<Props> = observer((props) => {
  const { isLoading, showWeekends } = props;

  return (
    <div
      className={`relative grid divide-x-[0.5px] divide-neutral-border-medium text-sm font-medium ${
        showWeekends ? "grid-cols-7" : "grid-cols-5"
      }`}
    >
      {isLoading && (
        <div className="absolute h-[1.5px] w-3/4 animate-[bar-loader_2s_linear_infinite] bg-primary-solid" />
      )}
      {Object.values(DAYS_LIST).map((day) => {
        if (!showWeekends && ["Sat", "Sun"].includes(day.shortTitle)) return null;

        return (
          <div key={day.shortTitle} className="flex h-11 items-center bg-neutral-component-surface-light px-4">
            {day.shortTitle}
          </div>
        );
      })}
    </div>
  );
});
