Explorar el Código

根据eslint调整代码

zhangzf hace 2 días
padre
commit
37e29d0fae

+ 1 - 1
src/app/(public)/customer/(has-dashboard)/account/_components/AccountHeader.tsx

@@ -19,7 +19,7 @@ export default function AccountHeader({
   user,
   points,
   coupon_count,
-  wishlist_count,
+  // wishlist_count,
 }: AccountHeaderProps) {
   return (
     <div className="relative h-[154px] ">

+ 1 - 1
src/app/(public)/customer/(has-dashboard)/account/edit/page.tsx

@@ -7,7 +7,7 @@ import {
   CalendarDate,
   type DateValue
 } from "@internationalized/date";
-import Link from "next/link";
+// import Link from "next/link";
 import { DatePicker } from "@heroui/date-picker";
 import CustomerAddressPhone from "../../address/new/_components/CustomerAddressPhone";
 import { useForm, FormProvider,Controller } from "react-hook-form";

+ 1 - 1
src/app/(public)/customer/(has-dashboard)/account/mycoupon/_components/CouponList.tsx

@@ -34,7 +34,7 @@ const CouponList = () => {
     },
   ]);
 
-  const [hasMore, setHasMore] = useState(true);
+  const [hasMore,] = useState(true);
 
   const loadMoreCoupons = async () => {
     return;

+ 11 - 11
src/app/(public)/customer/(has-dashboard)/account/mycoupon/_components/GiftCardList.tsx

@@ -16,23 +16,23 @@ const GiftCardList: React.FC = () => {
   //     status: "Unused",
   //     valid: "Valid:6/2/2026-12/31/2026",
   //   },
- const data = {
-    expirationdate: "2026-07-04",
-    formatted_remaining_giftcard_amount: "$30.00",
-    giftcard_amount: "30.00",
-    giftcard_number: "CFVG-RYUD-AOXF-GSLE",
-    giftcard_status: "1",
-    id: 7,
-    remaining_giftcard_amount: "30.00",
-    used_giftcard_amount: "0.00",
-  }
+//  const data = {
+//     expirationdate: "2026-07-04",
+//     formatted_remaining_giftcard_amount: "$30.00",
+//     giftcard_amount: "30.00",
+//     giftcard_number: "CFVG-RYUD-AOXF-GSLE",
+//     giftcard_status: "1",
+//     id: 7,
+//     remaining_giftcard_amount: "30.00",
+//     used_giftcard_amount: "0.00",
+//   }
   const [giftCards, setGiftCards] = useState<GiftCardItem[]>([]);
   const [hasMore, setHasMore] = useState(true);
 
   useEffect(() => {
     const load = async () => {
       const resp = await clientFetch("/api/gift/my-gift-cards");
-      const dataObj =[data] // resp.data||;
+      const dataObj =[resp.data]  // resp.data||;
       setGiftCards((prev) => [...prev, ...dataObj]);
       console.log("完整返回:", dataObj);
     };

+ 1 - 1
src/app/(public)/customer/(has-dashboard)/account/mycoupon/page.tsx

@@ -1,4 +1,4 @@
-import Link from "next/link";
+// import Link from "next/link";
 import CouponGiftCard from "./_components/CouponGiftCard"
 const CouponsPage: React.FC = () => {
   return (

+ 5 - 7
src/app/(public)/customer/(has-dashboard)/account/mypoints/page.tsx

@@ -1,11 +1,9 @@
-import Image from "next/image";
+// import Image from "next/image";
 import Link from "next/link";
 // import PointsRule from "./_components/PointsRule"
-import GetPoints from "./_components/GetPoints"
+// import GetPoints from "./_components/GetPoints"
 import { restApiFetch } from "@utils/bagisto/index";
-import PointList, {
-  type PointListItem,
-} from "./_components/PointList";
+import PointList from "./_components/PointList";
 
 const AccountPointsPage = async() => {
   const resp = await restApiFetch({
@@ -14,7 +12,7 @@ const AccountPointsPage = async() => {
   });
   console.log("resp--------------------------aaaaa",resp);
   
-   const currentPoints =
+   const userPoints =
     resp?.body.data?.current_points ?? 0;
 
   const history =
@@ -25,7 +23,7 @@ const AccountPointsPage = async() => {
       const hasMore =
     resp?.body.pagination?.has_more ?? false;
   // 模拟用户积分数据
-  const userPoints = 100009;
+  // const userPoints = 100009;
   // const hrefitems = [
   //   {
   //     title: "GiftCard",

+ 1 - 1
src/app/(public)/customer/(has-dashboard)/address/eidt/[id]/page.tsx

@@ -1,7 +1,7 @@
 "use client";
 import { useState, useEffect, useMemo } from "react";
 import { useParams } from "next/navigation";
-import Link from "next/link";
+// import Link from "next/link";
 import { clientFetch } from "@/lib/restApiClient";
 import Select from "@/components/theme/ui/Select";
 import { useForm, FormProvider, Controller } from "react-hook-form";

+ 28 - 28
src/app/(public)/customer/(has-dashboard)/address/page.tsx

@@ -3,34 +3,34 @@ import Link from "next/link";
 import DefaultAddress from "./_components/DefaultAddress";
 const CustomerAddressPage = async () => {
   // 模拟地址数据(可根据实际需求替换)
-  const addressData = {
-    billing: {
-      name: "zhang xxxx",
-      first_name: "zhang",
-      last_name: "aaaaa",
-      line1: "ddddd",
-      line2: "aaaaaaaa",
-      cityStateZip: "cscsc, Alabama, 90605",
-      address: "address",
-      city: "city",
-      postcode: "90603",
-      country: "United States",
-      phone: "2123165641",
-    },
-    shipping: {
-      name: "zhang xxxx",
-      first_name: "zhang",
-      last_name: "aaaaa",
-      line1: "ddddd",
-      line2: "aaaaaaaa",
-      cityStateZip: "cscsc, Alabama, 90605",
-      address: "address",
-      city: "city",
-      postcode: "90603",
-      country: "United States",
-      phone: "2123165641",
-    },
-  };
+  // const addressData = {
+  //   billing: {
+  //     name: "zhang xxxx",
+  //     first_name: "zhang",
+  //     last_name: "aaaaa",
+  //     line1: "ddddd",
+  //     line2: "aaaaaaaa",
+  //     cityStateZip: "cscsc, Alabama, 90605",
+  //     address: "address",
+  //     city: "city",
+  //     postcode: "90603",
+  //     country: "United States",
+  //     phone: "2123165641",
+  //   },
+  //   shipping: {
+  //     name: "zhang xxxx",
+  //     first_name: "zhang",
+  //     last_name: "aaaaa",
+  //     line1: "ddddd",
+  //     line2: "aaaaaaaa",
+  //     cityStateZip: "cscsc, Alabama, 90605",
+  //     address: "address",
+  //     city: "city",
+  //     postcode: "90603",
+  //     country: "United States",
+  //     phone: "2123165641",
+  //   },
+  // };
 
   return (
     <div className="w-full min-h-screen bg-white  h-full">

+ 11 - 13
src/app/(public)/customer/_components/CustomerSidebar.tsx

@@ -1,7 +1,7 @@
 "use client";
 
 import Link from "next/link";
-import { useEffect, useState } from "react";
+import { useMemo, useState } from "react";
 import { usePathname } from "next/navigation";
 import { logoutAction } from "@/actions";
 import { signOut } from "next-auth/react";
@@ -124,19 +124,17 @@ export default function CustomerSidebar() {
   /**
    * 进入二级页面时,自动展开对应父菜单
    */
-  useEffect(() => {
-    setOpenMenus((prev) => {
-      const next = { ...prev };
+  const autoOpenMenus = useMemo(() => {
+  const next: Record<string, boolean> = {};
 
-      menus.forEach((item) => {
-        if (item.children && hasActiveChild(item)) {
-          next[item.name] = true;
-        }
-      });
+  menus.forEach((item) => {
+    if (item.children && hasActiveChild(item)) {
+      next[item.name] = true;
+    }
+  });
 
-      return next;
-    });
-  }, [pathname]);
+  return next;
+}, [pathname, menus]);
 
   const toggleMenu = (name: string) => {
     setOpenMenus((prev) => ({
@@ -191,7 +189,7 @@ export default function CustomerSidebar() {
          * =========================
          */
         if (item.children?.length) {
-          const open = !!openMenus[item.name];
+          const open = openMenus[item.name] ??autoOpenMenus[item.name];
           const childActive = hasActiveChild(item);
 
           return (