Bläddra i källkod

Merge branch 'zzf-bug-change'

zhangzf 18 timmar sedan
förälder
incheckning
35da10311a

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

@@ -80,7 +80,7 @@ const HomeBestSellers = ({ bestSellerSection }: jinGangSectionProps) => {
           </div>
         ))}
       </div>
-      <div className="w-[186px] h-[32px] m-auto text-center text-sm leading-ly-32 mt-12 opacity-100 rounded-[29px] bg-white border border-solid">
+      <div className="w-[186px] h-[32px] m-auto text-center text-sm flex items-center justify-center mt-12 opacity-100 rounded-[29px] bg-white border border-solid">
         View More
       </div>
     </div>

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

@@ -76,7 +76,7 @@ const HomeNewArrival = ({ newArrivalSection }: newArrivalSectionProps) => {
           </div>
         ))}
       </div>
-      <div className="w-[186px] h-[32px] m-auto text-center text-sm leading-ly-32 mt-12 opacity-100 rounded-[29px] bg-white border border-solid">
+      <div className="w-[186px] h-[32px] m-auto text-center text-sm flex items-center justify-center mt-12 opacity-100 rounded-[29px] bg-white border border-solid">
         View More
       </div>
     </div>

+ 1 - 1
src/app/(public)/category/[slug]/_components/CategoryDesc.tsx

@@ -58,7 +58,7 @@ const CategoryDesc: FC<CategoryDescProps> = ({ title, description }) => {
       {showMore && (
         <button
           onClick={toggleExpand}
-          className="mt-2 text-lg underline font-medium flex items-center gap-1 ml-auto"
+          className="mt-2 text-sm underline font-medium flex items-center gap-1 ml-auto"
         >
           {isExpand ? "View less" : "View more"}
           {ArrowIcon}

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

@@ -16,6 +16,7 @@ import type{ CustomerProfileResult } from "@/types/customer/information/informat
 import {GET_CUSTOMER_PROFILE,UPDATE_CUSTOMER_PROFILE} from "@/graphql";
 import type{ UpdateCustomerProfileVars } from "@/types/customer/information/information";
 import { useCustomToast } from "@/utils/hooks/useToast";
+import { useRouter } from 'next/navigation';
 const AccountEditPage = () => {
   interface UserForm {
     firstname: string;
@@ -26,7 +27,14 @@ const AccountEditPage = () => {
     password: string;
     phone: string;
   }
+  const [isInvalid, setIsInvalid] = useState(false);
+  const [errorMsg, setErrorMsg] = useState("");
 
+  // 生日范围:1900-01-01 ~ 今年12-31
+  const minDate = new CalendarDate(1900, 1, 1);
+  const maxDate = new CalendarDate(new Date().getFullYear(), 12, 31);
+  // 组件内部先声明
+   const router = useRouter();
   const { showToast } = useCustomToast();
   const addressForm = useForm<UserForm>({
     mode: "onBlur",
@@ -110,6 +118,7 @@ const AccountEditPage = () => {
     if (result.success) {
       // 更新成功后的逻辑,提示、刷新表单等
       showToast(result.message, "success");
+      router.push('/customer/account/');
     }
   },
   onError: (err) => {
@@ -123,7 +132,22 @@ const AccountEditPage = () => {
   //   日期选择方法
   const handleDateChange = (dateValue: DateValue | null) => {
     if (!dateValue) return;
+       if (!dateValue) {
+      setIsInvalid(false);
+    
+      return;
+    }
+
+    const year = dateValue.year;
+    // 校验年份区间
+    if (year < 1900 || year > new Date().getFullYear()) {
+      setIsInvalid(true);
+      setErrorMsg("Please enter a valid birth year (1900 - current year)");
+      return;
+    }
 
+    setIsInvalid(false);
+    setErrorMsg("");
     // 把 CalendarDate 转成 标准字符串:YYYY-MM-DD
     const formattedDate = `${dateValue.year}-${String(dateValue.month).padStart(2, "0")}-${String(dateValue.day).padStart(2, "0")}`;
     return formattedDate
@@ -256,13 +280,18 @@ const AccountEditPage = () => {
                 
            
             }}
+              minValue={minDate}
+              maxValue={maxDate}
+              isInvalid={isInvalid}
+              errorMessage={errorMsg}
               radius="sm"
               className="bg-white"
               description={"This cannot be modified. Please fill in carefully."}
               labelPlacement={"outside"}
-              showMonthAndYearPickers={false}
+              showMonthAndYearPickers={true}
               aria-label="date picker"
             />
+            
               )}
       />
             {/* label={"Date of Birth"} */}

+ 10 - 3
src/components/layout/navbar/NavbarSearchIcon.tsx

@@ -1,11 +1,18 @@
 "use client";
 
-import { useState } from "react";
+import { useState,useEffect } from "react";
 import SearchPop from "./SearchPop";
-
+import { usePathname } from "next/navigation";
 export default function NavbarSearchIcon() {
   const [searchOpen, setSearchOpen] = useState(false);
-
+  const pathname = usePathname();
+  useEffect(() => {
+    if (searchOpen) {
+      queueMicrotask(() => {
+        setSearchOpen(false);
+      });
+    }
+  }, [pathname, searchOpen]);
   const handleClick = () => {
     setSearchOpen((prev) => !prev);
   };

+ 8 - 7
src/components/layout/navbar/SearchPop.tsx

@@ -7,6 +7,7 @@ import Grid from "@/components/theme/ui/grid/Grid";
 import HotSearch from "@/app/(public)/search/_components/HotSearch";
 import NewProductGridItems from "@components/catalog/product/NewProductGridItems";
 import Recommend from "@/app/(public)/product/_components/youmaylike/Recommend";
+// import { usePathname } from "next/navigation";
 // const ProductGridItems = dynamicImport(
 //   () => import("@/components/catalog/product/ProductGridItems"),
 // );
@@ -42,13 +43,8 @@ export default function SearchPop({
   const hasKeyword = keyword.trim().length > 0;
 
   const hasSearchResults = hasKeyword && products.length > 0;
+  // const pathname = usePathname();
 
-  /**
-   * 两种情况展示 You May Like:
-   *
-   * 1. 刚打开,还没有输入
-   * 2. 输入了,但是没有搜到产品
-   */
   const showYouMayLike = !hasKeyword || (hasKeyword && products.length === 0);
 
   // =========================
@@ -117,7 +113,12 @@ export default function SearchPop({
     setKeyword("");
     onClose();
   };
-
+  // useEffect(() => {
+  //   // 打开状态下,路由变化就关闭弹窗
+  //   if (open) {
+  //     handleClose();
+  //   }
+  // }, [pathname]);
   // =========================
   // placeholder 轮播
   // =========================