Procházet zdrojové kódy

Merge branch 'zzf-bug-change'

zhangzf před 6 dny
rodič
revize
1cc99d28b5

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

@@ -52,7 +52,7 @@ const CategoryDesc: FC<CategoryDescProps> = ({ title, description }) => {
           isExpand ? "" : "line-clamp-2"
         }`}
       >
-        {description}
+       <div dangerouslySetInnerHTML={{ __html: description }} />
       </p>
 
       {showMore && (

+ 13 - 13
src/app/(public)/category/[slug]/_components/FaqList.tsx

@@ -42,17 +42,17 @@ function FaqAccordionItem({
   );
 
   // 点赞爱心SVG提取
-  const LikeIcon = (
-    <svg
-      xmlns="http://www.w3.org/2000/svg"
-      width="16"
-      height="16"
-      fill="currentColor"
-      viewBox="0 0 16 16"
-    >
-      <path d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z" />
-    </svg>
-  );
+  // const LikeIcon = (
+  //   <svg
+  //     xmlns="http://www.w3.org/2000/svg"
+  //     width="16"
+  //     height="16"
+  //     fill="currentColor"
+  //     viewBox="0 0 16 16"
+  //   >
+  //     <path d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z" />
+  //   </svg>
+  // );
 
   return (
     <div className="border border-gray-100 rounded-lg bg-[#F9F9F9] p-4 mb-3">
@@ -89,10 +89,10 @@ function FaqAccordionItem({
             </p>
           </div>
           {/* 点赞栏 */}
-          <div className="flex items-center justify-end gap-2 text-emerald-700 text-sm">
+          {/* <div className="flex items-center justify-end gap-2 text-emerald-700 text-sm">
             <span>{item.likeCount}</span>
             {LikeIcon}
-          </div>
+          </div> */}
         </div>
       )}
     </div>

+ 30 - 2
src/app/(public)/customer/account/edit/page.tsx

@@ -15,6 +15,7 @@ import { useMutation, useApolloClient } from "@apollo/client/react";
 import type{ CustomerProfileResult } from "@/types/customer/information/information";
 import {GET_CUSTOMER_PROFILE,UPDATE_CUSTOMER_PROFILE} from "@/graphql";
 import type{ UpdateCustomerProfileVars } from "@/types/customer/information/information";
+import { useRouter } from 'next/navigation';
 import { useCustomToast } from "@/utils/hooks/useToast";
 const AccountEditPage = () => {
   interface UserForm {
@@ -26,7 +27,13 @@ const AccountEditPage = () => {
     password: string;
     phone: string;
   }
-
+  const [isInvalid, setIsInvalid] = useState(false);
+  const [errorMsg, setErrorMsg] = useState("");
+    // 组件内部先声明
+  const router = useRouter();
+  // 生日范围:1900-01-01 ~ 今年12-31
+  const minDate = new CalendarDate(1900, 1, 1);
+  const maxDate = new CalendarDate(new Date().getFullYear(), 12, 31);
   const { showToast } = useCustomToast();
   const addressForm = useForm<UserForm>({
     mode: "onBlur",
@@ -110,6 +117,7 @@ const AccountEditPage = () => {
     if (result.success) {
       // 更新成功后的逻辑,提示、刷新表单等
       showToast(result.message, "success");
+      router.push('/customer/account/');
     }
   },
   onError: (err) => {
@@ -123,7 +131,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
@@ -237,6 +260,11 @@ const AccountEditPage = () => {
               size="md"
               label="Date Of Birth"
               isRequired={hasBirthDate}
+              minValue={minDate}
+              maxValue={maxDate}
+              isInvalid={isInvalid}
+              errorMessage={errorMsg}
+              
               onChange={(dateValue) => {
               // HeroUI DatePicker 返回 CalendarDate 对象,转成字符串 yyyy‑MM‑dd
               onChange(handleDateChange(dateValue) );
@@ -247,7 +275,7 @@ const AccountEditPage = () => {
               className="bg-white"
               description={"This cannot be modified. Please fill in carefully."}
               labelPlacement={"outside"}
-              showMonthAndYearPickers={false}
+              showMonthAndYearPickers={true}
               aria-label="date picker"
             />
               )}

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

@@ -1,8 +1,17 @@
 "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]);
   return (
     <>
       <div

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

@@ -6,6 +6,7 @@ import Grid from "@/components/theme/ui/grid/Grid";
 import HotSearch from "@/app/(public)/search/_components/HotSearch"
 import { useMediaQuery } from "@utils/hooks/useMediaQueryHook";
 import Link from "next/link";
+// import { usePathname } from "next/navigation";
 // const ProductGridItems = dynamicImport(
 //   () => import("@/components/catalog/product/ProductGridItems"),
 // );
@@ -24,7 +25,13 @@ export default function SearchPop({ open, onClose }: SearchPopProps) {
 
   const products = data?.edges?.map((e) => e.node) || [];
   const isDesktop = useMediaQuery("(min-width: 1024px)");
-
+  //   const pathname = usePathname();
+  // useEffect(() => {
+  //   // 打开状态下,路由变化就关闭弹窗
+  //   if (open) {
+  //     handleClose();
+  //   }
+  // }, [pathname]);
   // 执行搜索接口
   const triggerSearch = async (searchWord: string) => {
     if (!searchWord.trim()) return;