import { ChevronLeft, ChevronRight } from "lucide-react";
import { Button } from "../ui/button";
import type { DateTime } from "luxon";
import DatePickerWithRange from "./date-picker";

export default function DayNavigation({
  startDate,
  setStartDate,
}: {
  startDate: DateTime;
  setStartDate: (date: DateTime) => void;
}) {
  const handlePreviousDay = () => {
    const previousDay = startDate.minus({ days: 1 });
    setStartDate(previousDay);
  };

  const handleNextDay = () => {
    const nextDay = startDate.plus({ days: 1 });
    setStartDate(nextDay);
  };

  return (
    <div className="mb-2">
      <div className="flex flex-row items-center justify-between gap-2">
        <Button variant="outline" size="sm" onClick={handlePreviousDay}>
          <ChevronLeft className="h-10 w-10" />
        </Button>
        <div className="flex-1">
          <DatePickerWithRange
            startDate={startDate}
            setStartDate={setStartDate}
          />
        </div>
        <Button variant="outline" size="sm" onClick={handleNextDay}>
          <ChevronRight className="h-10 w-10" />
        </Button>
      </div>
    </div>
  );
}
