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

const currentWeekDayIdx = new Date().getDay();

//TODO: Add logic time https://github.com/redneckz/wildless-cms-uni-blocks/pull/1549
export const renderCurrentDaySchedule = (workScheduleWeek?: WorkScheduleWeek[]) => {
  const [currentWeekDay] = workScheduleWeek?.slice(currentWeekDayIdx - 1) ?? [];

  if (!currentWeekDay) {
    return null;
  }

  const { lunchHour, status, workTime, hasLunch } = currentWeekDay;

  return status ? (
    <div className="flex gap-s items-start whitespace-nowrap">
      {workTime ? <Badge color="green">{workTime}</Badge> : null}
      {lunchHour && hasLunch ? <Badge color="yellow">{`перерыв: ${lunchHour}`}</Badge> : null}
    </div>
  ) : (
    <Badge color="red">Выходной</Badge>
  );
};
