Преглед на файлове

update

tags/Baseline_30082024_FRONTEND_UAT
MSI\derek преди 1 година
родител
ревизия
2ed4bd49b2
променени са 3 файла, в които са добавени 8 реда и са изтрити 22 реда
  1. +1
    -1
      src/app/(main)/settings/staff/user/page.tsx
  2. +6
    -15
      src/components/EditUser/EditUser.tsx
  3. +1
    -6
      src/components/EditUser/UserDetail.tsx

+ 1
- 1
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<searchParamsProps> = async ({
searchParams


+ 6
- 15
src/components/EditUser/EditUser.tsx Целия файл

@@ -55,10 +55,9 @@ const EditUser: React.FC<Props> = 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<Props> = 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<UserResult>
) => {
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<Props> = 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<Props> = 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<Props> = 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<Props> = async ({
<Tab label={t("User Authority")} iconPosition="end" />
</Tabs>
</Stack>
{tabIndex == 0 && <UserDetail data={data!} />}
{tabIndex == 0 && <UserDetail />}
{tabIndex === 1 && <AuthAllocation auths={auths!}/>}
<Stack direction="row" justifyContent="flex-end" gap={1}>
<Button


+ 1
- 6
src/components/EditUser/UserDetail.tsx Целия файл

@@ -13,14 +13,9 @@ import {
import { useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";

interface Props {
data: UserResult
}


const UserDetail: React.FC<Props> = ({
data
}) => {
const UserDetail: React.FC = () => {
const { t } = useTranslation();
const {
register,


Зареждане…
Отказ
Запис