♻️ Add email pattern and refactor in frontend (#1138)
This commit is contained in:
@@ -21,6 +21,7 @@ import { useMutation, useQueryClient } from "react-query"
|
||||
import { type UserCreate, UsersService } from "../../client"
|
||||
import type { ApiError } from "../../client/core/ApiError"
|
||||
import useCustomToast from "../../hooks/useCustomToast"
|
||||
import { emailPattern } from "../../utils"
|
||||
|
||||
interface AddUserProps {
|
||||
isOpen: boolean
|
||||
@@ -95,10 +96,7 @@ const AddUser: React.FC<AddUserProps> = ({ isOpen, onClose }) => {
|
||||
id="email"
|
||||
{...register("email", {
|
||||
required: "Email is required",
|
||||
pattern: {
|
||||
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
|
||||
message: "Invalid email address",
|
||||
},
|
||||
pattern: emailPattern,
|
||||
})}
|
||||
placeholder="Email"
|
||||
type="email"
|
||||
|
@@ -25,6 +25,7 @@ import {
|
||||
UsersService,
|
||||
} from "../../client"
|
||||
import useCustomToast from "../../hooks/useCustomToast"
|
||||
import { emailPattern } from "../../utils"
|
||||
|
||||
interface EditUserProps {
|
||||
user: UserOut
|
||||
@@ -101,10 +102,7 @@ const EditUser: React.FC<EditUserProps> = ({ user, isOpen, onClose }) => {
|
||||
id="email"
|
||||
{...register("email", {
|
||||
required: "Email is required",
|
||||
pattern: {
|
||||
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
|
||||
message: "Invalid email address",
|
||||
},
|
||||
pattern: emailPattern,
|
||||
})}
|
||||
placeholder="Email"
|
||||
type="email"
|
||||
|
Reference in New Issue
Block a user