From 2ed4bd49b2f2efe3af59ea60420f77815ab5433b Mon Sep 17 00:00:00 2001 From: "MSI\\derek" Date: Mon, 20 May 2024 13:47:05 +0800 Subject: [PATCH] update --- src/app/(main)/settings/staff/user/page.tsx | 2 +- src/components/EditUser/EditUser.tsx | 21 ++++++--------------- src/components/EditUser/UserDetail.tsx | 7 +------ 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/app/(main)/settings/staff/user/page.tsx b/src/app/(main)/settings/staff/user/page.tsx index 2fbdf22..86373bb 100644 --- a/src/app/(main)/settings/staff/user/page.tsx +++ b/src/app/(main)/settings/staff/user/page.tsx @@ -4,8 +4,8 @@ import { I18nProvider, getServerI18n } from "@/i18n"; import EditUser from "@/components/EditUser"; import { Typography } from "@mui/material"; import { Suspense } from "react"; -import { searchParamsProps } from "../../skill/edit/page"; import { preloadUser } from "@/app/api/user"; +import { searchParamsProps } from "@/app/utils/fetchUtil"; const User: React.FC = async ({ searchParams diff --git a/src/components/EditUser/EditUser.tsx b/src/components/EditUser/EditUser.tsx index ea478c5..58067b9 100644 --- a/src/components/EditUser/EditUser.tsx +++ b/src/components/EditUser/EditUser.tsx @@ -55,10 +55,9 @@ const EditUser: React.FC = async ({ }, [] ); - console.log(rules); const errors = formProps.formState.errors; - +console.log("asdasd") const fetchUserDetail = async () => { try { // fetch user info @@ -87,22 +86,16 @@ const EditUser: React.FC = async ({ fetchUserDetail(); }, []); - // useEffect(() => { - // const thisUser = users.filter((item) => item.id === id) - // formProps.reset({ - // username: thisUser[0].username, - // email: thisUser[0].email, - // }); - // }, []); - const hasErrorsInTab = ( tabIndex: number, errors: FieldErrors ) => { switch (tabIndex) { case 0: + console.log("yolo") return Object.keys(errors).length > 0; default: + console.log("yolo") false; } }; @@ -115,7 +108,7 @@ const EditUser: React.FC = async ({ async (data) => { try { let haveError = false - let regex_pw = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/ + let regex_pw = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*])[A-Za-z\d!@#$%^&*]{8,20}$/ let pw = '' if (data.password && data.password.length > 0) { pw = data.password @@ -132,10 +125,8 @@ const EditUser: React.FC = async ({ formProps.setError("password", { message: "A combination of uppercase letters, lowercase letters, numbers, and symbols is required.", type: "required" }) } } - console.log(data); const userData = { name: data.name, - email: '', locked: false, addAuthIds: data.addAuthIds || [], removeAuthIds: data.removeAuthIds || [], @@ -145,10 +136,10 @@ const EditUser: React.FC = async ({ password: "", newPassword: pw } - console.log(userData); if (haveError) { return } + console.log("passed") await editUser(id, userData); if (data.password && data.password.length > 0) { await adminChangePassword(pwData); @@ -204,7 +195,7 @@ const EditUser: React.FC = async ({ - {tabIndex == 0 && } + {tabIndex == 0 && } {tabIndex === 1 && }