import { CardCell } from './CardCell';
import { type WorkScheduleWeek } from './OfficesAtmsMapProps';

const getSubTextLunch = ({ lunchHour, hasLunch = false, status = false }: WorkScheduleWeek) => {
  if (!status) {
    return 'Не работает';
  }

  return lunchHour && hasLunch ? `Перерыв ${lunchHour}` : lunchHour;
};

export const renderDay = (
  { title, status, workTime, lunchHour, hasLunch }: WorkScheduleWeek,
  i: number,
) => (
  <CardCell
    key={String(i)}
    label={title}
    value={status && workTime ? workTime : ''}
    subText={getSubTextLunch({ lunchHour, hasLunch, status })}
    subColor={!status || hasLunch ? 'text-error' : 'text-green-dark'}
  />
);
