|
@@ -17,6 +17,7 @@ import ReviewModal from "./ReviewModal";
|
|
|
// import { ReviewTabType } from "@/types/products/review";
|
|
// import { ReviewTabType } from "@/types/products/review";
|
|
|
import { useCustomToast } from "@utils/hooks/useToast";
|
|
import { useCustomToast } from "@utils/hooks/useToast";
|
|
|
import { clientFetch } from "@/lib/restApiClient";
|
|
import { clientFetch } from "@/lib/restApiClient";
|
|
|
|
|
+import { getUuId } from "@/utils/helper";
|
|
|
interface ProductReviewEdge {
|
|
interface ProductReviewEdge {
|
|
|
__typename: "ProductReviewEdge";
|
|
__typename: "ProductReviewEdge";
|
|
|
node: ProductReviewNode;
|
|
node: ProductReviewNode;
|
|
@@ -31,7 +32,6 @@ interface ReviewDetailProps {
|
|
|
activeTab: string;
|
|
activeTab: string;
|
|
|
onChangeTab: (tabKey: string) => void;
|
|
onChangeTab: (tabKey: string) => void;
|
|
|
onOpenBaseModal: () => void;
|
|
onOpenBaseModal: () => void;
|
|
|
- uuid:string;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const ReviewDetail: FC<ReviewDetailProps> = ({
|
|
const ReviewDetail: FC<ReviewDetailProps> = ({
|
|
@@ -43,7 +43,6 @@ const ReviewDetail: FC<ReviewDetailProps> = ({
|
|
|
activeTab,
|
|
activeTab,
|
|
|
onChangeTab,
|
|
onChangeTab,
|
|
|
onOpenBaseModal,
|
|
onOpenBaseModal,
|
|
|
- uuid,
|
|
|
|
|
}) => {
|
|
}) => {
|
|
|
|
|
|
|
|
const [visibleCount, setVisibleCount] = useState(5);
|
|
const [visibleCount, setVisibleCount] = useState(5);
|
|
@@ -65,10 +64,7 @@ const ReviewDetail: FC<ReviewDetailProps> = ({
|
|
|
|
|
|
|
|
const visibleReviews = reviewDetails.slice(0, visibleCount);
|
|
const visibleReviews = reviewDetails.slice(0, visibleCount);
|
|
|
console.log("visibleReviews-------------------:", visibleReviews);
|
|
console.log("visibleReviews-------------------:", visibleReviews);
|
|
|
- // useEffect(() => {
|
|
|
|
|
- // const uuid = getGuestUUID();
|
|
|
|
|
- // if (uuid) setGuestId(uuid);
|
|
|
|
|
- // }, []);
|
|
|
|
|
|
|
+
|
|
|
const handleLikeClick = async (item: any) => {
|
|
const handleLikeClick = async (item: any) => {
|
|
|
// id直接从item拿
|
|
// id直接从item拿
|
|
|
const id = item.id;
|
|
const id = item.id;
|
|
@@ -90,6 +86,7 @@ const ReviewDetail: FC<ReviewDetailProps> = ({
|
|
|
},
|
|
},
|
|
|
}));
|
|
}));
|
|
|
try {
|
|
try {
|
|
|
|
|
+ const uuid = getUuId();
|
|
|
const res = await clientFetch(`/api/shop/reviews/${id}/like`, {
|
|
const res = await clientFetch(`/api/shop/reviews/${id}/like`, {
|
|
|
method: "POST",
|
|
method: "POST",
|
|
|
headers: {
|
|
headers: {
|
|
@@ -368,7 +365,6 @@ const ReviewDetail: FC<ReviewDetailProps> = ({
|
|
|
productId={productId}
|
|
productId={productId}
|
|
|
onChangeTab={onChangeTab}
|
|
onChangeTab={onChangeTab}
|
|
|
activeTab={activeTab}
|
|
activeTab={activeTab}
|
|
|
- guestId={uuid}
|
|
|
|
|
/>
|
|
/>
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|