"use client";

import "./CreateReview.scss";
import { useState } from "react";
import Button from "@/Shared/UI/Button/Button";
import { createReviewAction } from "./actions";
import { StaticImageData } from "next/image";

interface ICreateReviewProps {
  endpoint: string;
  id: number | null | undefined;
}

const CreateReview: React.FC<ICreateReviewProps> = ({
  endpoint,
  id,
}: ICreateReviewProps) => {
  const [review, setReview] = useState<string>("");

  return (
    <div className="create-review">
      <h3>
        <span />
        Написать комментарий
      </h3>
      <div>
        <textarea
          onChange={(e) => setReview(e.target.value)}
          value={review}
          placeholder="Напишите комментарий"
        />
        <Button
          disabled={createReviewAction.isLoading}
          onClick={() => {
            setReview("");
            createReviewAction.createReview(endpoint, id, review);
          }}
        >
          Отправить
        </Button>
      </div>
    </div>
  );
};

export default CreateReview;
