Explorar el Código

详情页删除评论相关无用代码

fogwind hace 3 días
padre
commit
13b0e23bb5

+ 0 - 318
src/app/(public)/product/_components/review/AddProductReview.tsx

@@ -1,318 +0,0 @@
-"use client";
-
-import { useState } from "react";
-import { Textarea } from "@heroui/input";
-import { AddRatingStar } from "./AddRatingStar";
-import { Button } from "@components/common/button/Button";
-import { useCustomToast } from "@utils/hooks/useToast";
-import { useProductReview } from "@utils/hooks/useProductReview";
-import Image from "next/image";
-
-import type { CreateProductReviewInput } from "@/types/review";
-import { AddUploadImage } from "@components/common/icons/AddUploadImage";
-
-interface UploadImgItem {
-  fileName: string;
-  preview: string;
-}
-export default function AddProductReview({
-  productId,
-  onClose,
-}: {
-  productId: string;
-  onClose: () => void;
-}) {
-  // const [imageFile, setImageFile] = useState<UploadImgItem[]>([]);
-  const [imgList, setImgList] = useState<UploadImgItem[]>([]);
-  const MAX_UPLOAD = 3;
-  // const [imagePreview, setImagePreview] = useState<string | null>(null);
-  const [errors, setErrors] = useState({
-    title: "",
-    comment: "",
-    rating: "",
-  });
-  const [reviewInfo, setReviewInfo] = useState({
-    title: "",
-    comment: "",
-    rating: 0,
-    attachments: null as string | null,
-  });
-  const { showToast } = useCustomToast();
-  const { createProductReview, isLoading } = useProductReview();
-
-  const handleImageUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
-    const file = e.target.files?.[0];
-    if (!file) return;
-
-    // 判断是否达到3张上限
-    if (imgList.length >= MAX_UPLOAD) {
-      showToast(`You can only upload up to ${MAX_UPLOAD} images`, "warning");
-      e.target.value = ""; // 清空input,防止重复选
-      return;
-    }
-
-    const reader = new FileReader();
-    reader.onloadend = () => {
-      const newItem: UploadImgItem = {
-        fileName: file.name,
-        preview: reader.result as string,
-      };
-      // 追加到图片数组
-      const newList = [...imgList, newItem];
-      setImgList(newList);
-      // 拼接所有文件名给表单附件
-      setReviewInfo((prev) => ({
-        ...prev,
-        attachments: newList.map((item) => item.fileName).join(","),
-      }));
-    };
-    reader.readAsDataURL(file);
-    // 清空input,允许重复选择同一张图片
-    e.target.value = "";
-  };
-  // 根据下标删除指定图片
-  const removeSingleImage = (targetIndex: number) => {
-    const newList = imgList.filter((_, idx) => idx !== targetIndex);
-    setImgList(newList);
-    // 重新拼接附件字符串
-    setReviewInfo((prev) => ({
-      ...prev,
-      attachments: newList.length
-        ? newList.map((item) => item.fileName).join(",")
-        : null,
-    }));
-  };
-  const handleSubmit = async (e: React.FormEvent) => {
-    e.preventDefault();
-
-    const newErrors = {
-      title: "",
-      comment: "",
-      rating: "",
-    };
-
-    if (!reviewInfo.title.trim()) {
-      newErrors.title = "Title is required";
-    }
-
-    if (!reviewInfo.comment.trim()) {
-      newErrors.comment = "Comment is required";
-    }
-
-    if (reviewInfo.rating === 0) {
-      newErrors.rating = "Please select a rating";
-    }
-
-    setErrors(newErrors);
-
-    // If there are errors, don't submit
-    if (newErrors.title || newErrors.comment || newErrors.rating) {
-      showToast("Please fill in all required fields", "danger");
-      return;
-    }
-
-    try {
-      const input: CreateProductReviewInput = {
-        productId: Number(productId.split("/").pop()),
-        title: reviewInfo.title,
-        comment: reviewInfo.comment,
-        rating: reviewInfo.rating,
-        name: "Guest User",
-        email: "guest@mail.com",
-        // 读取表单里拼接好的多图文件名,无图则为空字符串
-        attachments: reviewInfo.attachments ?? "",
-      };
-
-      await createProductReview(input);
-
-      setReviewInfo({
-        title: "",
-        comment: "",
-        rating: 0,
-        attachments: null,
-      });
-      setImgList([]); // 新增:清空多张图片数组
-      setErrors({
-        title: "",
-        comment: "",
-        rating: "",
-      });
-    } catch (error) {
-      console.error("Error submitting review:", error);
-      showToast("Failed to submit review. Please try again.", "danger");
-    }
-  };
-
-  return (
-    <form
-      onSubmit={handleSubmit}
-      className="w-full max-w-4xl mx-auto p-4 md:p-6 rounded-xl relative"
-    >
-      <div className="flex mb-4">
-        <h1 className="text-xl font-semibold">Write a review</h1>
-        <button
-          type="button"
-          onClick={onClose}
-          className="absolute top-4 right-4 z-50 p-2 rounded-full bg-gray-100 hover:bg-gray-200 dark:bg-neutral-300 dark:hover:bg-neutral-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-400 transition-colors"
-          aria-label="Close review form"
-        >
-          <svg
-            xmlns="http://www.w3.org/2000/svg"
-            className="h-5 w-5"
-            fill="none"
-            viewBox="0 0 24 24"
-            stroke="currentColor"
-          >
-            <path
-              strokeLinecap="round"
-              strokeLinejoin="round"
-              strokeWidth={2}
-              d="M6 18L18 6M6 6l12 12"
-            />
-          </svg>
-        </button>
-      </div>
-      <div className="flex flex-col gap-4">
-        <div className="space-y-4">
-          {/* 多张图片预览 横向排列 */}
-          <div className="flex flex-wrap gap-3 items-start">
-            {imgList.map((imgItem, idx) => (
-              <div
-                key={idx}
-                className="relative w-[120px] h-[120px] border-2 border-dashed border-gray-300 rounded-xl"
-              >
-                <Image
-                  src={imgItem.preview}
-                  alt="preview"
-                  width={120}
-                  height={120}
-                  className="w-full h-full object-cover rounded-lg"
-                />
-                {/* 单张删除按钮 */}
-                <button
-                  type="button"
-                  onClick={() => removeSingleImage(idx)}
-                  className="absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 hover:bg-red-600 transition-colors"
-                >
-                  <svg
-                    xmlns="http://www.w3.org/2000/svg"
-                    className="h-4 w-4"
-                    fill="none"
-                    viewBox="0 0 24 24"
-                    stroke="currentColor"
-                  >
-                    <path
-                      strokeLinecap="round"
-                      strokeLinejoin="round"
-                      strokeWidth={2}
-                      d="M6 18L18 6M6 6l12 12"
-                    />
-                  </svg>
-                </button>
-                {/* 图片文件名 */}
-                <p className="text-xs text-gray-500 truncate px-1 mt-1">
-                  {imgItem.fileName}
-                </p>
-              </div>
-            ))}
-
-            {/* 上传按钮:不足3张才显示 */}
-            {imgList.length < MAX_UPLOAD && (
-              <div className="border-2 border-dashed border-gray-300 w-32 h-32 rounded-xl p-6 text-center transition-colors hover:border-primary-500">
-                <label
-                  htmlFor="file-upload"
-                  className="mx-auto flex cursor-pointer flex-col items-center justify-center gap-2 h-full"
-                >
-                  <div className="mx-auto flex h-8 w-8 items-center justify-center rounded-full">
-                    <AddUploadImage />
-                  </div>
-                  <div className="text-sm text-center">
-                    <span className="font-medium">Add Image</span>
-                  </div>
-                  <input
-                    id="file-upload"
-                    name="file-upload"
-                    type="file"
-                    className="sr-only"
-                    accept="image/*"
-                    onChange={handleImageUpload}
-                  />
-                </label>
-              </div>
-            )}
-          </div>
-          {/* <p className="text-sm text-gray-400">
-            Max {MAX_UPLOAD} images allowed
-          </p> */}
-        </div>
-
-        <div className="flex flex-col gap-4">
-          <div>
-            <label className="block text-base font-semibold  mb-1">
-              Rating
-            </label>
-            <AddRatingStar
-              value={reviewInfo.rating}
-              onChange={(value) => {
-                setReviewInfo((prev) => ({ ...prev, rating: value }));
-                setErrors((prev) => ({ ...prev, rating: "" }));
-              }}
-              size="size-6"
-              className="mt-1"
-            />
-            {errors.rating && (
-              <p className="text-red-500 text-sm mt-1">{errors.rating}</p>
-            )}
-          </div>
-
-          <Textarea
-            label="Title"
-            placeholder="Title"
-            labelPlacement="outside"
-            value={reviewInfo.title}
-            onChange={(e) => {
-              setReviewInfo((prev) => ({ ...prev, title: e.target.value }));
-              setErrors((prev) => ({ ...prev, title: "" }));
-            }}
-            minRows={1}
-            maxRows={1}
-            variant="bordered"
-            isInvalid={!!errors.title}
-            errorMessage={errors.title}
-            classNames={{
-              input: "text-sm",
-              label: "px-2 text-base font-semibold",
-            }}
-          />
-
-          <Textarea
-            label="Comment"
-            placeholder="Comment"
-            labelPlacement="outside"
-            value={reviewInfo.comment}
-            onChange={(e) => {
-              setReviewInfo((prev) => ({ ...prev, comment: e.target.value }));
-              setErrors((prev) => ({ ...prev, comment: "" }));
-            }}
-            minRows={5}
-            variant="bordered"
-            isInvalid={!!errors.comment}
-            errorMessage={errors.comment}
-            classNames={{
-              input: "text-sm",
-              label: "px-2 text-base font-semibold",
-            }}
-          />
-          <div className="w-32">
-            <Button
-              title={isLoading ? "Submitting..." : "Submit"}
-              type="submit"
-              disabled={isLoading}
-              className="w-full mt-4 rounded-2xl"
-            />
-          </div>
-        </div>
-      </div>
-    </form>
-  );
-}

+ 6 - 7
src/app/(public)/product/_components/review/AddProductReviewForm.tsx

@@ -5,7 +5,6 @@ import { AddRatingStar } from "./AddRatingStar";
 import { Button } from "@components/common/button/Button";
 import ReviewImageUploader from "./ReviewImageUploader";
 import { useCustomToast } from "@utils/hooks/useToast";
-import { useProductReview } from "@utils/hooks/useProductReview";
 import type {
   UploadImgItem,
   ReviewFormData,
@@ -24,9 +23,7 @@ export default function AddProductReviewForm({
   onCloseForm,
 }: AddProductReviewFormProps) {
   const { showToast } = useCustomToast();
-  const { 
-    // createProductReview, 
-    isLoading } = useProductReview();
+  const [isSubmiting, setIsSubmiting] = useState(false);
 
   // 图片状态
   const [imgList, setImgList] = useState<UploadImgItem[]>([]);
@@ -100,6 +97,7 @@ export default function AddProductReviewForm({
         images: formData.attachments ?? "",
       };
       console.log('input----------------------------------------',input);
+      setIsSubmiting(true);
       const res = await clientFetch("/api/shop/reviews", {
             method: "POST",
             headers: {
@@ -110,7 +108,7 @@ export default function AddProductReviewForm({
           });
       // await createProductReview(input);
       console.log("评论提交res-------------------------------------------------",res);
-      
+      setIsSubmiting(false);
       showToast("Review submitted successfully!", "success");
       // 重置表单 + 关闭
       setFormData({
@@ -125,6 +123,7 @@ export default function AddProductReviewForm({
       setImgList([]);
       onCloseForm();
     } catch (err) {
+      setIsSubmiting(false);
       console.error(err);
       showToast("Failed to submit review, try again", "danger");
     }
@@ -251,9 +250,9 @@ export default function AddProductReviewForm({
           Cancel Review
         </button>
         <Button
-          title={isLoading ? "Submitting..." : "Submit Review"}
+          title={isSubmiting ? "Submitting..." : "Submit Review"}
           type="submit"
-          disabled={isLoading}
+          disabled={isSubmiting}
           className="relative  font-normal text-ly-14 leading-ly-24 text-[#1E3932FF] py-1 px-3.5  cursor-pointer   rounded-full bg-[#E1E8E6FF] p-4 tracking-wide  "
         />
       </div>

+ 0 - 278
src/components/catalog/review/AddProductReview.tsx

@@ -1,278 +0,0 @@
-"use client";
-
-import { useState } from "react";
-import { Textarea } from "@heroui/input";
-import { AddRatingStar } from "./AddRatingStar";
-import { Button } from "@components/common/button/Button";
-import { useCustomToast } from "@utils/hooks/useToast";
-import { useProductReview } from "@utils/hooks/useProductReview";
-import Image from "next/image";
-
-import type { CreateProductReviewInput } from "@/types/review";
-import { AddUploadImage } from "@components/common/icons/AddUploadImage";
-
-export default function AddProductReview({
-  productId,
-  onClose,
-}: {
-  productId: string;
-  onClose: () => void;
-}) {
-  const [imageFile, setImageFile] = useState<string | null>(null);
-  const [imagePreview, setImagePreview] = useState<string | null>(null);
-  const [errors, setErrors] = useState({
-    title: "",
-    comment: "",
-    rating: "",
-  });
-  const [reviewInfo, setReviewInfo] = useState({
-    title: "",
-    comment: "",
-    rating: 0,
-    attachments: null as string | null,
-  });
-  const { showToast } = useCustomToast();
-  const { createProductReview, isLoading } = useProductReview();
-
-  const handleImageUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
-    const file = e.target.files?.[0];
-    if (file) {
-      setImageFile(file.name);
-      setReviewInfo((prev) => ({ ...prev, attachments: file.name }));
-      const reader = new FileReader();
-      reader.onloadend = () => {
-        setImagePreview(reader.result as string);
-      };
-      reader.readAsDataURL(file);
-    }
-  };
-
-  const handleSubmit = async (e: React.FormEvent) => {
-    e.preventDefault();
-
-    const newErrors = {
-      title: "",
-      comment: "",
-      rating: "",
-    };
-
-    if (!reviewInfo.title.trim()) {
-      newErrors.title = "Title is required";
-    }
-
-    if (!reviewInfo.comment.trim()) {
-      newErrors.comment = "Comment is required";
-    }
-
-    if (reviewInfo.rating === 0) {
-      newErrors.rating = "Please select a rating";
-    }
-
-    setErrors(newErrors);
-
-    // If there are errors, don't submit
-    if (newErrors.title || newErrors.comment || newErrors.rating) {
-      showToast("Please fill in all required fields", "danger");
-      return;
-    }
-
-    try {
-      const input: CreateProductReviewInput = {
-        productId: Number(productId.split("/").pop()),
-        title: reviewInfo.title,
-        comment: reviewInfo.comment,
-        rating: reviewInfo.rating,
-        name: "Guest User",
-        email: "guest@mail.com",
-        attachments: "",
-      };
-
-      await createProductReview(input);
-
-      setReviewInfo({
-        title: "",
-        comment: "",
-        rating: 0,
-        attachments: null,
-      });
-      setImageFile(null);
-      setImagePreview(null);
-      setErrors({
-        title: "",
-        comment: "",
-        rating: "",
-      });
-    } catch (error) {
-      console.error("Error submitting review:", error);
-      showToast("Failed to submit review. Please try again.", "danger");
-    }
-  };
-
-  return (
-    <form
-      onSubmit={handleSubmit}
-      className="w-full max-w-4xl mx-auto p-4 md:p-6 rounded-xl relative"
-    >
-      <div className="flex mb-4">
-        <h1 className="text-xl font-semibold">Write a review</h1>
-        <button
-          type="button"
-          onClick={onClose}
-          className="absolute top-4 right-4 z-50 p-2 rounded-full bg-gray-100 hover:bg-gray-200 dark:bg-neutral-300 dark:hover:bg-neutral-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-400 transition-colors"
-          aria-label="Close review form"
-        >
-          <svg
-            xmlns="http://www.w3.org/2000/svg"
-            className="h-5 w-5"
-            fill="none"
-            viewBox="0 0 24 24"
-            stroke="currentColor"
-          >
-            <path
-              strokeLinecap="round"
-              strokeLinejoin="round"
-              strokeWidth={2}
-              d="M6 18L18 6M6 6l12 12"
-            />
-          </svg>
-        </button>
-      </div>
-      <div className="flex flex-col gap-4">
-        <div className="space-y-4">
-          {imagePreview ? (
-            <div className="border-2 w-[120px] h-auto max-h-[120px] border-dashed border-gray-300  rounded-xl text-center transition-colors hover:border-primary-500">
-              <div className="space-y-3">
-                <div className="relative mx-auto">
-                  <Image
-                    src={imagePreview}
-                    alt="Preview"
-                    width={120}
-                    height={120}
-                    className="w-full h-full object-cover rounded-lg"
-                  />
-                  <button
-                    type="button"
-                    onClick={() => {
-                      setImageFile(null);
-                      setImagePreview(null);
-                    }}
-                    className="absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 hover:bg-red-600 transition-colors"
-                  >
-                    <svg
-                      xmlns="http://www.w3.org/2000/svg"
-                      className="h-4 w-4"
-                      fill="none"
-                      viewBox="0 0 24 24"
-                      stroke="currentColor"
-                    >
-                      <path
-                        strokeLinecap="round"
-                        strokeLinejoin="round"
-                        strokeWidth={2}
-                        d="M6 18L18 6M6 6l12 12"
-                      />
-                    </svg>
-                  </button>
-                </div>
-              </div>
-            </div>
-          ) : (
-            <div className="border-2 border-dashed border-gray-300 w-32 h-32 rounded-xl p-6 text-center transition-colors hover:border-primary-500">
-              <div>
-                <label
-                  htmlFor="file-upload"
-                  className="mx-auto flex cursor-pointer flex-col items-center justify-center gap-2"
-                >
-                  <div className="mx-auto flex h-8 w-8 items-center justify-center rounded-full">
-                    <AddUploadImage />
-                  </div>
-
-                  <div className="text-sm text-center">
-                    <span className="font-medium">Add Image</span>
-                  </div>
-
-                  <input
-                    id="file-upload"
-                    name="file-upload"
-                    type="file"
-                    className="sr-only"
-                    accept="image/*"
-                    onChange={handleImageUpload}
-                  />
-                </label>
-              </div>
-            </div>
-          )}
-          {imageFile && <p className="text-sm">{imageFile}</p>}
-        </div>
-
-        <div className="flex flex-col gap-4">
-          <div>
-            <label className="block text-base font-semibold  mb-1">
-              Rating
-            </label>
-            <AddRatingStar
-              value={reviewInfo.rating}
-              onChange={(value) => {
-                setReviewInfo((prev) => ({ ...prev, rating: value }));
-                setErrors((prev) => ({ ...prev, rating: "" }));
-              }}
-              size="size-6"
-              className="mt-1"
-            />
-            {errors.rating && (
-              <p className="text-red-500 text-sm mt-1">{errors.rating}</p>
-            )}
-          </div>
-
-          <Textarea
-            label="Title"
-            placeholder="Title"
-            labelPlacement="outside"
-            value={reviewInfo.title}
-            onChange={(e) => {
-              setReviewInfo((prev) => ({ ...prev, title: e.target.value }));
-              setErrors((prev) => ({ ...prev, title: "" }));
-            }}
-            minRows={1}
-            maxRows={1}
-            variant="bordered"
-            isInvalid={!!errors.title}
-            errorMessage={errors.title}
-            classNames={{
-              input: "text-sm",
-              label: "px-2 text-base font-semibold",
-            }}
-          />
-
-          <Textarea
-            label="Comment"
-            placeholder="Comment"
-            labelPlacement="outside"
-            value={reviewInfo.comment}
-            onChange={(e) => {
-              setReviewInfo((prev) => ({ ...prev, comment: e.target.value }));
-              setErrors((prev) => ({ ...prev, comment: "" }));
-            }}
-            minRows={5}
-            variant="bordered"
-            isInvalid={!!errors.comment}
-            errorMessage={errors.comment}
-            classNames={{
-              input: "text-sm",
-              label: "px-2 text-base font-semibold",
-            }}
-          />
-          <div className="w-32">
-            <Button
-              title={isLoading ? "Submitting..." : "Submit"}
-              type="submit"
-              disabled={isLoading}
-              className="w-full mt-4 rounded-2xl"
-            />
-          </div>
-        </div>
-      </div>
-    </form>
-  );
-}

+ 0 - 68
src/components/catalog/review/AddRatingStar.tsx

@@ -1,68 +0,0 @@
-"use client";
-
-import { useState, useEffect } from "react";
-import clsx from "clsx";
-import { StarIcon } from "@heroicons/react/24/solid";
-import type { RatingTypes } from "../type";
-
-
-export const AddRatingStar = ({
-    length = 5,
-    value,
-    size = "size-6",
-    className,
-    onChange
-}: RatingTypes) => {
-
-    const [internalValue, setInternalValue] = useState(value ?? 0);
-    const [hovered, setHovered] = useState<number | null>(null);
-
-    useEffect(() => {
-        if (value !== undefined) {
-              // eslint-disable-next-line react-hooks/set-state-in-effect
-            setInternalValue(value);
-        }
-    }, [value]);
-
-    const currentValue = value ?? internalValue;
-
-    const getFillState = (index: number) => {
-        if (hovered !== null) return index <= hovered;
-        return index <= currentValue;
-    };
-
-    const handleClick = (index: number) => {
-        if (value === undefined) {
-               
-            setInternalValue(index);
-        }
-        onChange?.(index);
-    };
-
-
-    return (
-        <div className={clsx("flex items-center gap-x-1 cursor-pointer", className)}>
-            {Array.from({ length }).map((_, i) => {
-                const index = i + 1;
-                return (
-                    <StarIcon
-                        key={index}
-                        onClick={() => handleClick(index)}
-                        onMouseEnter={() => setHovered(index)}
-                        onMouseLeave={() => setHovered(null)}
-                        fill="currentColor"
-                        className={clsx(
-                            "fill-current",
-                            size || "size-6",
-                            getFillState(index)
-                                ? "text-yellow-500"
-                                : "text-gray-300",
-                            "transition-colors"
-                        )}
-                    />
-                );
-            })}
-        </div>
-    );
-};
-

+ 0 - 23
src/components/catalog/review/NoReview.tsx

@@ -1,23 +0,0 @@
-import { ReviewButton } from "@components/common/button/ReviewButton";
-import { NoReviewIcon } from "@components/common/icons/NoReviewsIcon";
-
-export const NoReview = ({
-  setShowForm,
-}: {
-  setShowForm: (show: boolean) => void;
-}) => {
-  return (
-    <div className="flex flex-col items-center gap-4 py-8">
-      <div className="flex flex-col items-center gap-4">
-        <NoReviewIcon />
-        <h2 className="font-outfit text-2xl font-semibold tracking-wide mt-4">
-          Ratings
-        </h2>
-        <p className="text-lg mt-2">
-          No reviews yet. Be the first to share your experience
-        </p>
-      </div>
-      <ReviewButton setShowForm={setShowForm} />
-    </div>
-  );
-};

+ 0 - 59
src/components/catalog/review/ReviewSection.tsx

@@ -1,59 +0,0 @@
-"use client";
-
-import { useState } from "react";
-import { Modal, ModalContent } from "@heroui/modal";
-import AddProductReview from "./AddProductReview";
-import { ReviewButton } from "@components/common/button/ReviewButton";
-import { NoReview } from "./NoReview";
-
-interface ReviewSectionProps {
-  productId: string;
-  className?: string;
-  totalReview: number;
-}
-
-export default function ReviewSection({
-  productId,
-  className,
-  totalReview,
-}: ReviewSectionProps) {
-  const [open, setOpen] = useState(false);
-
-  return (
-    <>
-      <div>
-        {totalReview > 0 ? (
-          <ReviewButton setShowForm={setOpen} className={className} />
-        ) : (
-          <NoReview setShowForm={setOpen} />
-        )}
-      </div>
-
-      <Modal
-        isOpen={open}
-        onOpenChange={setOpen}
-        backdrop="blur"
-        size="4xl"
-        hideCloseButton
-        scrollBehavior="inside"
-        placement="center"
-        classNames={{
-          wrapper: "z-[100] items-center justify-center",
-          backdrop: "z-[99]",
-          base: "bg-white/90 dark:bg-black/80 backdrop-blur-xl  rounded-xl mx-4",
-        }}
-      >
-        <ModalContent className="p-0 border-none">
-          {(onClose) => (
-            <AddProductReview
-              productId={productId}
-              onClose={onClose}
-            />
-          )}
-        </ModalContent>
-      </Modal>
-    </>
-  );
-}
-
-

+ 0 - 47
src/utils/hooks/useProductReview.ts

@@ -1,47 +0,0 @@
-"use client";
-
-import { useMutation } from "@apollo/client/react";
-import { CREATE_PRODUCT_REVIEW } from "@/graphql";
-import { useCustomToast } from "./useToast";
-import type { CreateProductReviewInput } from "@/types/review";
-import {handleApolloBusinessError} from "@/lib/ApolloErrorHandler";
-
-export function useProductReview() {
-    const { showToast } = useCustomToast();
-
-    const [mutateAsync, { loading: isLoading, error }] = useMutation(CREATE_PRODUCT_REVIEW, {
-        onCompleted: (response) => {
-            const responseData = response?.createProductReview;
-            if (responseData) {
-                showToast("Product review created successfully", "success");
-            }
-        },
-        onError: (error) => {
-            handleApolloBusinessError(error,(err) => {
-                showToast(err.message, "danger");
-            });
-        },
-    });
-
-    const createProductReview = async (input: CreateProductReviewInput) => {
-        return await mutateAsync({
-            variables: {
-                input: {
-                    productId: input.productId,
-                    title: input.title,
-                    comment: input.comment,
-                    rating: input.rating,
-                    name: input.name,
-                    email: input.email,
-                    attachments: input.attachments || "",
-                },
-            },
-        });
-    };
-
-    return {
-        createProductReview,
-        isLoading,
-        error
-    };
-}