import CalndarD from "@/components/icons/CalndarD";
import { Rating } from "@mui/material";
import Image from "next/image";
import ModalDeleteComment from "./modal";
import CircularLoading from "@/app/component/loading/Circular";
import TextLoading from "@/app/component/loading/Text";
import CustomLoading from "@/app/component/loading/Custom";
import MultilineLoading from "@/app/component/loading/Multiline";

function Comment({ data, loading, idx, length }) {
  return (
    <li className="flex flex-col gap-[8px] w-full">
      <div className="flex items-start justify-between w-full">
        <div className="flex items-center justify-start gap-[8px] md:gap-[12px] lg:gap-[16px]">
          <CircularLoading loading={loading} width={87} height={87}>
            <Image
              className="w-[48px] sm:w-[61px] md:w-[75px] lg:w-[88px] h-[48px] sm:h-[61px] md:h-[75px] lg:h-[88px]"
              src={data.profile}
              alt="profile"
              height={87}
              width={87}
            />
          </CircularLoading>
          <div className="flex flex-col items-start justify-center gap-[8px] md:gap-[12px] lg:gap-[16px]">
            <TextLoading loading={loading} width={105} height={18}>
              <p className="text-[#3B3B3B] text-[12px] md:text-[14px] lg:text-[16px] font-bold">
                {data.name_doctor}
              </p>
            </TextLoading>
            <TextLoading loading={loading} width={65} height={18}>
              <p className="text-[#525252] text-[12px] md:text-[14px] font-medium">
                تخصص: {data.expertise}
              </p>
            </TextLoading>
          </div>
        </div>
        <CustomLoading loading={loading} width={90} height={30}>
          <ModalDeleteComment />
        </CustomLoading>
      </div>
      <CustomLoading loading={loading} width={130} height={18}>
        <Rating
          dir="ltr"
          value={data.stars.value}
          className="!mt-[4px] md:!mt-[6px] lg:!mt-[8px]"
          sx={{
            "& .MuiSvgIcon-root": {
              width: "16px",
              height: "16px",
            },
          }}
        />
      </CustomLoading>
      <MultilineLoading loading={loading} width="full" height={18} line={2}>
        <p className="text-[#525252] mt-[4px] md:mt-[2px] lg:mt-0 text-[14px] font-normal leading-[28px] md:leading-[30px] lg:leading-[33px]">
          {data.comment}
        </p>
      </MultilineLoading>
      <div className="flex items-center justify-start gap-[8px]">
        <div className="w-[20px] h-[20px] sm:w-[22px] sm:h-[22px] lg:w-[24px] lg:h-[24px]">
          <CalndarD />
        </div>
        <TextLoading width={90} height={18} loading={loading}>
          <p className="text-[#7E7E7E] text-[12px] font-normal">{data.date}</p>
        </TextLoading>
      </div>
      {length > idx + 1 && (
        <span className="w-full block h-px bg-[#EFEFEF] mt-0 md:mt-[4px] lg:mt-[8px]"></span>
      )}
    </li>
  );
}

export default Comment;
