Jelajahi Sumber

根据build提示下修改报错

zhangzf 5 hari lalu
induk
melakukan
eb05abc7a8

+ 1 - 1
src/app/(public)/_components/Trending.tsx

@@ -149,7 +149,7 @@ const Trending = ({ trending }: trendingProps) => {
                     />
                     {/* 居中圆形播放按钮 */}
                     <button
-                      onClick={() => handlePlayClick("/video/hair-demo-1.mp4"||item.videoUrl)}
+                      onClick={() => handlePlayClick(item.videoUrl||"/video/hair-demo-1.mp4" )}
                       className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2
                       w-24 h-24 rounded-full bg-white/60 backdrop-blur-sm
                       flex items-center justify-center transition hover:bg-white/80"

+ 0 - 177
src/app/(public)/category copy/[collection]/page.tsx

@@ -1,177 +0,0 @@
-import { Metadata } from "next";
-import { notFound } from "next/navigation";
-import { isArray } from "@/utils/type-guards";
-import Grid from "@components/theme/ui/grid/Grid";
-import FilterList from "@components/theme/filters/FilterList";
-import SortOrder from "@components/theme/filters/SortOrder";
-import MobileFilter from "@components/theme/filters/MobileFilter";
-import ProductGridItems from "@components/catalog/product/ProductGridItems";
-import Pagination from "@components/catalog/Pagination";
-import {
-  ProductsResponse,
-} from "@components/catalog/type";
-import {
-  GET_FILTER_PRODUCTS,
-  GET_TREE_CATEGORIES,
-} from "@/graphql";
-import { cachedGraphQLRequest, cachedCategoryRequest, getFilterAttributes } from "@/utils/hooks/useCache";
-import { SortByFields } from "@utils/constants";
-import { CategoryDetail } from "@components/theme/search/CategoryDetail";
-import { Suspense } from "react";
-import FilterListSkeleton from "@components/common/skeleton/FilterSkeleton";
-import { TreeCategoriesResponse } from "@/types/theme/category-tree";
-import { MobileSearchBar } from "@components/layout/navbar/MobileSearch";
-import { extractNumericId, findCategoryBySlug, buildProductFilters } from "@utils/helper";
-
-/**列表页 */
-export async function generateMetadata({
-  params,
-}: {
-  params: Promise<{ collection: string }>;
-}): Promise<Metadata> {
-  const { collection: categorySlug } = await params;
-
-  const {data:treeData} = await cachedGraphQLRequest<TreeCategoriesResponse>(
-    "category",
-    GET_TREE_CATEGORIES,
-    { parentId: 1 }
-  );
-
-  const categories = treeData?.treeCategories || [];
-  const categoryItem = findCategoryBySlug(categories, categorySlug);
-
-  if (!categoryItem) return notFound();
-
-  const translation = categoryItem.translation;
-
-  return {
-    title: translation?.metaTitle || translation?.name,
-    description: translation?.description || `${translation?.name} products`,
-  };
-}
-
-export default async function CategoryPage({
-  searchParams,
-  params,
-}: {
-  params: Promise<{ collection: string }>;
-  searchParams?: Promise<{ [key: string]: string | string[] | undefined }>;
-}) {
-  const { collection: categorySlug } = await params;
-  const resolvedParams = await searchParams;
-
-  const [{data:treeData}, filterAttributes] = await Promise.all([
-    cachedGraphQLRequest<TreeCategoriesResponse>(
-      "category",
-      GET_TREE_CATEGORIES,
-      { parentId: 1 }
-    ),
-    getFilterAttributes(),
-  ]);
-
-  const categories = treeData?.treeCategories || [];
-  const categoryItem = findCategoryBySlug(categories, categorySlug);
-
-  if (!categoryItem) return notFound();
-
-  const numericId = extractNumericId(categoryItem.id);
-
-  const {
-    q: searchValue,
-    page,
-    cursor,
-    before,
-  } = (resolvedParams || {}) as {
-    [key: string]: string;
-  };
-
-  const itemsPerPage = 12;
-  const currentPage = page ? parseInt(page) - 1 : 0;
-  const sortValue = resolvedParams?.sort || "name-asc";
-  const selectedSort =
-    SortByFields.find((s) => s.key === sortValue) || SortByFields[0];
-
-  const { filterObject: baseFilterObject } = buildProductFilters(resolvedParams || {});
-
-  const filterObject: Record<string, string> = {
-    ...baseFilterObject,
-  };
-
-  if (numericId) {
-    filterObject.category_id = numericId;
-  }
-
-  const filterInput = JSON.stringify(filterObject);
-  
-  const [{data}] = await Promise.all([
-    cachedCategoryRequest<ProductsResponse>(
-      categorySlug,
-      GET_FILTER_PRODUCTS,
-      {
-        query: searchValue || "",
-        filter: filterInput,
-        ...(before
-          ? { last: itemsPerPage, before: before }
-          : { first: itemsPerPage, after: cursor }),
-        sortKey: selectedSort.sortKey,
-        reverse: selectedSort.reverse,
-      }
-    ),
-  ]);
-
-  const products = data?.products?.edges?.map((e) => e.node) || [];
-  const pageInfo = data?.products?.pageInfo;
-  const totalCount = data?.products?.totalCount || 0;
-  const translation = categoryItem.translation;
-
-  return (
-    <>
-      <MobileSearchBar />
-      <section>
-        <Suspense fallback={<FilterListSkeleton />}>
-          <CategoryDetail
-            categoryItem={{ description: translation?.description ?? "", name: translation?.name ?? "" }}
-
-          />
-        </Suspense>
-        <div className="my-10 hidden gap-4 md:flex md:items-baseline md:justify-between w-full max-w-screen-2xl mx-auto px-4">
-          <FilterList filterAttributes={filterAttributes} />
-          <SortOrder sortOrders={SortByFields} title="Sort by" />
-        </div>
-        <div className="flex items-center justify-between gap-4 py-8 md:hidden w-full max-w-screen-2xl mx-auto px-4">
-          <MobileFilter filterAttributes={filterAttributes} />
-          <SortOrder sortOrders={SortByFields} title="Sort by" />
-        </div>
-
-        {isArray(products) && products.length > 0 ? (
-         <Grid
-                   className="grid grid-flow-row grid-cols-2 gap-5 lg:gap-11.5 w-full max-w-screen-2xl mx-auto md:grid-cols-3 lg:grid-cols-4 px-4 xss:px-7.5"
-                 >
-            <ProductGridItems products={products} />
-          </Grid>
-        ) : (
-          <div className="px-4">
-            <div className="flex h-40 items-center justify-center rounded-lg border border-dashed border-neutral-300">
-              <p className="text-neutral-500">No products found in this category.</p>
-            </div>
-          </div>
-        )}
-
-        {isArray(products) && (totalCount > itemsPerPage || pageInfo?.hasNextPage) && (
-          <nav
-            aria-label="Collection pagination"
-            className="my-10 block items-center sm:flex"
-          >
-            <Pagination
-              itemsPerPage={itemsPerPage}
-              itemsTotal={totalCount || 0}
-              currentPage={currentPage}
-              nextCursor={pageInfo?.endCursor}
-              prevCursor={pageInfo?.startCursor}
-            />
-          </nav>
-        )}
-      </section>
-    </>
-  );
-}

+ 1 - 1
src/app/(public)/customer/order/history/_components/OrderHistory.tsx

@@ -271,7 +271,7 @@ export default function OrderHistory() {
 
                 {/* 订单商品列表 */}
                 <div className="mb-4 space-y-3">
-                  {order.items.map((item, idx) => (
+                  {order.items.map((item:any, idx:any) => (
                     <div key={idx} className="flex gap-3">
                       {/* 商品图片(有则显示,无则占位) */}
                       {item.image ? (

+ 1 - 1
src/app/(public)/product/[...urlProduct]/page.tsx

@@ -138,7 +138,7 @@ console.log("res----------------------",allReviews);
           />
 
           <SwitchButton
-            productId={"3792" || String(product._id)}
+            productId={"3792"} //|| String(product._id)
             reviewList={allReviews}
             reviewTotal={allReviews.length}
             questionTotal={questionTotal}

+ 3 - 3
src/app/(public)/product/_components/ProductInformation.tsx

@@ -178,9 +178,9 @@ export function ProductInformation({
 
     return {
       variant,
-      totalLinePrice: 170 || totalLinePrice,
-      totalNowPrice: 119 || totalNowPrice,
-      save: 51 || save,
+      totalLinePrice:   totalLinePrice || 170,
+      totalNowPrice:   totalNowPrice ||119,
+      save:  save ||  51,
       displayDayPrice: displayDayPrice,
     };
   }, [selected, flexibleVariants, productQty]);

+ 4 - 2
src/app/(public)/product/_components/popup/VipPlusModal.tsx

@@ -1,7 +1,9 @@
 "use client";
-import { BaseModalProps } from "@/types/modal";
 import { useEffect } from "react";
-
+interface BaseModalProps {
+  isOpen: boolean;
+  onClose: () => void;
+}
 export default function VipPlusModal({ isOpen, onClose }: BaseModalProps) {
   // 弹窗打开时锁定页面滚动
   useEffect(() => {

+ 3 - 3
src/app/(public)/product/_components/question/ComponentsQuestionModal.tsx

@@ -90,13 +90,13 @@ export default function ComponentsQuestionModal({
               </div>
               <div>
                 <p className="text-emerald-700 font-medium text-base">
-                  {questionData.question}
+                  {questionData?.question}
                 </p>
               </div>
             </div>
 
             {/* Answer 多条循环 */}
-            {questionData.answers.map((answer, ind) => (
+            {questionData?.answers.map((answer, ind) => (
               <div key={ind} className="flex gap-3 ">
                 <div className="w-8 h-8 rounded-full border border-gray-400 flex items-center justify-center shrink-0">
                   <span>A</span>
@@ -106,7 +106,7 @@ export default function ComponentsQuestionModal({
                   <div className="flex justify-between mt-2 text-sm text-gray-500">
                     <span>{questionData.answers.length} answer(s)</span>
                     <button
-                      onClick={() => toggleAnswerLike(qa.id, 0)}
+                      onClick={() =>(console.log("点赞"))} // toggleAnswerLike(qa.id, 0)
                       className="flex items-center gap-1"
                     >
                       <LikeIcon active={answer.isLiked} />

+ 4 - 2
src/app/(public)/product/_components/review/AddProductReviewForm.tsx

@@ -5,7 +5,7 @@ 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 { useProductReview } from "@utils/hooks/useProductReview";
 import type {
   UploadImgItem,
   ReviewFormData,
@@ -24,7 +24,9 @@ export default function AddProductReviewForm({
   onCloseForm,
 }: AddProductReviewFormProps) {
   const { showToast } = useCustomToast();
-  // const { createProductReview, isLoading } = useProductReview();
+  const { 
+    // createProductReview, 
+    isLoading } = useProductReview();
 
   // 图片状态
   const [imgList, setImgList] = useState<UploadImgItem[]>([]);

+ 1 - 1
src/app/(public)/product/_components/review/ReviewImageUploader.tsx

@@ -8,7 +8,7 @@ import type { UploadImgItem } from "@/types/products/review";
 interface ReviewImageUploaderProps {
   imgList: UploadImgItem[];
   setImgList: (list: UploadImgItem[]) => void;
-  setAttachments: (val: string | null) => void;
+  setAttachments: (val: string[]) => void;
   MAX_UPLOAD: number;
 }
 

+ 5 - 5
src/app/(public)/product/_components/review/ReviewModal.tsx

@@ -194,8 +194,8 @@ const ReviewModal: React.FC<ReviewModalProps> = React.memo(
     // 生成图库一维图片数组
     const buildGalleryList = useCallback((): GalleryItem[] => {
       const allGallery: GalleryItem[] = [];
-      filterReviewList().forEach((edge, reviewIdx) => {
-        edge.attachments.forEach((imgUrl) => {
+      filterReviewList().forEach((edge:any, reviewIdx) => {
+        edge.attachments.forEach((imgUrl:any) => {
           allGallery.push({
             reviewIndex: reviewIdx,
             imageUrl: imgUrl,
@@ -231,7 +231,7 @@ const ReviewModal: React.FC<ReviewModalProps> = React.memo(
       );
 
       const galleryAll = buildGalleryList();
-      const targetReview = filterReviewList()[clickReviewIndex];
+      const targetReview:any = filterReviewList()[clickReviewIndex];
       const targetImg = targetReview.attachments[clickImgIndex];
       const targetSlide = galleryAll.findIndex(
         (g) => g.reviewIndex === clickReviewIndex && g.imageUrl === targetImg,
@@ -300,7 +300,7 @@ const ReviewModal: React.FC<ReviewModalProps> = React.memo(
               ) : displayList.length === 0 ? (
                 <p className="text-center text-gray-500 py-10">No reviews</p>
               ) : (
-                displayList.map((item, reviewIdx) => {
+                displayList.map((item:any, reviewIdx) => {
                   // const item = edge.node;
                   return (
                     <div
@@ -398,7 +398,7 @@ const ReviewModal: React.FC<ReviewModalProps> = React.memo(
                       {/* 评论图片,点击打开图库 */}
                       {item.attachments.length > 0 && (
                         <div className="flex gap-2 mt-3">
-                          {item.attachments.map((img, imgIdx) => (
+                          {item.attachments.map((img:any, imgIdx:any) => (
                             <button
                               key={imgIdx}
                               onClick={() =>

+ 1 - 2
src/app/api/home/route.ts

@@ -2,8 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
 import { restApiFetch } from "@/utils/bagisto";
 import { isBagistoError } from "@/utils/type-guards";
 import { getAuthToken } from "@/utils/helper";
-type Params = Promise<{ id: string }>;
-export async function GET(req: NextRequest, {  }: { params: Params }) {
+export async function GET(req: NextRequest) {
   try {
     //  const { id } = await params; // 解包拿到订单ID
     const guestToken = getAuthToken(req);

+ 2 - 2
src/components/common/button/ReviewButton.tsx

@@ -2,14 +2,14 @@
 import { getIsGuest } from "@utils/cookie-tools";
 import { useRouter } from "next/navigation";
 
-export const ReviewButton = ({ setShowForm, className }: { setShowForm: () => void, className?: string }) => {
+export const ReviewButton = ({ setShowForm, className }: { setShowForm: (show: boolean) => void, className?: string }) => {
     const IsGuest = getIsGuest();
     const router = useRouter();
     const handleAddReview = () => {
         if (IsGuest) {
             router.push("/customer/login");
         } else {
-            setShowForm();
+            setShowForm(true);
         }
     };
 

+ 1 - 0
src/types/home/type.ts

@@ -18,6 +18,7 @@ export type HomeProduct = {
   is_new: boolean;
   is_featured: boolean;
   short_description: string;
+  videoUrl: string;
 };
 type HomeSection = {
   id: number;