"use client";

import { Button } from "@mui/material";
import ItemAppointment from "./ItemAppointment";
import ArrowLeftD from "@/components/icons/ArrowLeftD";
import Link from "next/link";

function AppointmentList({ doctor, loading, doctorSlug }) {
  return (
    <>
      <ul className="hidden sticky top-[122px] sm:top-[150px] mt:top-[178px] lg:top-[206px] lg:flex w-[38%] flex-col justify-start items-center gap-8">
        {doctor && (
          <ItemAppointment loading={loading} turn={doctor} key={doctor.id} doctorSlug={doctorSlug} />
        )}
      </ul>
      <div
        className="fixed lg:hidden bg-[#FFF] border-t border-transparent border-t-[#D7D7D7] border-solid bottom-0 right-0 w-full p-4 flex items-center justify-between"
      >
        <p className="text-[#05BA58] text-[11px] font-normal">
          {doctor?.active === false || !doctor?.free_turn
            ? "نوبت‌دهی غیرفعال است"
            : `اولین نوبت آزاد: ${doctor.free_turn}`}
        </p>
        {doctor?.active === false ? (
          <Button
            variant="contained"
            className="!py-2 !px-4 gap-1 !text-[14px] !font-medium"
            disabled
          >
            نوبت‌دهی غیرفعال
          </Button>
        ) : (
          <Link href={`/appointment/${doctorSlug}`}>
            <Button
              variant="contained"
              className="!py-2 !px-4 gap-1 !text-[14px] !font-medium"
            >
              دریافت نوبت
              <div className="w-[20px] h-[20px]">
                <ArrowLeftD />
              </div>
            </Button>
          </Link>
        )}
      </div>
    </>
  );
}

export default AppointmentList;
