Pramod_Bug#80 #38
@ -24,7 +24,9 @@ const ManageEmployee = () => {
|
|||||||
error,
|
error,
|
||||||
loading: empLoading,
|
loading: empLoading,
|
||||||
} = useEmployeeProfile( employeeId );
|
} = useEmployeeProfile( employeeId );
|
||||||
|
|
||||||
dispatch( changeMaster( "Job Role" ) );
|
dispatch( changeMaster( "Job Role" ) );
|
||||||
|
|
||||||
const [disabledEmail, setDisabledEmail] = useState(false);
|
const [disabledEmail, setDisabledEmail] = useState(false);
|
||||||
const { data: job_role, loading } = useMaster();
|
const { data: job_role, loading } = useMaster();
|
||||||
const [isloading, setLoading] = useState(false);
|
const [isloading, setLoading] = useState(false);
|
||||||
@ -39,7 +41,7 @@ const ManageEmployee = () => {
|
|||||||
MiddleName: z.string().optional(),
|
MiddleName: z.string().optional(),
|
||||||
LastName: z.string().min(1, { message: "Last Name is required" }),
|
LastName: z.string().min(1, { message: "Last Name is required" }),
|
||||||
Email: z
|
Email: z
|
||||||
.string()
|
.string().max(225,"Email cannot exceed 255 characters")
|
||||||
.optional()
|
.optional()
|
||||||
.refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
|
.refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
|
||||||
message: "Invalid email format",
|
message: "Invalid email format",
|
||||||
@ -59,7 +61,7 @@ const ManageEmployee = () => {
|
|||||||
CurrentAddress: z
|
CurrentAddress: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, { message: "Current Address is required" })
|
.min(1, { message: "Current Address is required" })
|
||||||
.max(500, { message: "Address cannot exceed 250 characters" }),
|
.max(500, { message: "Address cannot exceed 500 characters" }),
|
||||||
BirthDate: z
|
BirthDate: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, { message: "Birth Date is required" })
|
.min(1, { message: "Birth Date is required" })
|
||||||
@ -111,7 +113,7 @@ const ManageEmployee = () => {
|
|||||||
PermanentAddress: z
|
PermanentAddress: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, { message: "Permanent Address is required" })
|
.min(1, { message: "Permanent Address is required" })
|
||||||
.max(500, { message: "Address cannot exceed 250 characters" }),
|
.max(500, { message: "Address cannot exceed 500 characters" }),
|
||||||
PhoneNumber: z
|
PhoneNumber: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, { message: "Phone Number is required" })
|
.min(1, { message: "Phone Number is required" })
|
||||||
@ -152,6 +154,7 @@ const ManageEmployee = () => {
|
|||||||
|
|
||||||
const AadharNumberValue = watch( "AadharNumber" ) || "";
|
const AadharNumberValue = watch( "AadharNumber" ) || "";
|
||||||
|
|
||||||
|
|
||||||
const onSubmit = (data) => {
|
const onSubmit = (data) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
@ -182,7 +185,10 @@ const ManageEmployee = () => {
|
|||||||
showToast("Employee details updated successfully.", "success");
|
showToast("Employee details updated successfully.", "success");
|
||||||
clearCacheKey("employeeListByProject");
|
clearCacheKey("employeeListByProject");
|
||||||
clearCacheKey( "allEmployeeList" );
|
clearCacheKey( "allEmployeeList" );
|
||||||
|
clearCacheKey("employeeProfile")
|
||||||
|
|
||||||
setLoading( false );
|
setLoading( false );
|
||||||
|
reset()
|
||||||
navigation("/employees");
|
navigation("/employees");
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@ -324,7 +330,7 @@ const ManageEmployee = () => {
|
|||||||
{...register("Email")}
|
{...register("Email")}
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
placeholder="example@domain.com"
|
placeholder="example@domain.com"
|
||||||
aria-label=""
|
maxLength={255}
|
||||||
aria-describedby="Email"
|
aria-describedby="Email"
|
||||||
disabled={!!currentEmployee?.email}
|
disabled={!!currentEmployee?.email}
|
||||||
/>
|
/>
|
||||||
@ -439,14 +445,15 @@ const ManageEmployee = () => {
|
|||||||
aria-label="Current Address"
|
aria-label="Current Address"
|
||||||
aria-describedby="basic-icon-default-message2"
|
aria-describedby="basic-icon-default-message2"
|
||||||
{...register( "CurrentAddress" )}
|
{...register( "CurrentAddress" )}
|
||||||
|
maxLength={500}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setCurrentAddressLength(e.target.value.length);
|
setCurrentAddressLength(e.target.value.length);
|
||||||
// let react-hook-form still handle it
|
// let react-hook-form still handle it
|
||||||
register("CurrentAddress").onChange(e);
|
register("CurrentAddress").onChange(e);
|
||||||
}}
|
}}
|
||||||
></textarea>
|
></textarea>
|
||||||
<div className="text-end small">
|
<div className="text-end muted">
|
||||||
{500 - currentAddressLength} characters left
|
<small> {500 - currentAddressLength} characters left</small>
|
||||||
</div>
|
</div>
|
||||||
{errors.CurrentAddress && (
|
{errors.CurrentAddress && (
|
||||||
<div
|
<div
|
||||||
@ -469,13 +476,14 @@ const ManageEmployee = () => {
|
|||||||
aria-label="Permanent Address"
|
aria-label="Permanent Address"
|
||||||
aria-describedby="basic-icon-default-message2"
|
aria-describedby="basic-icon-default-message2"
|
||||||
{...register( "PermanentAddress" )}
|
{...register( "PermanentAddress" )}
|
||||||
|
maxLength={500}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setPermanentAddressLength(e.target.value.length);
|
setPermanentAddressLength(e.target.value.length);
|
||||||
register("PermanentAddress").onChange(e);
|
register("PermanentAddress").onChange(e);
|
||||||
}}
|
}}
|
||||||
></textarea>
|
></textarea>
|
||||||
<div className="text-end small">
|
<div className="text-end muted">
|
||||||
{500 - permanentAddressLength} characters left
|
<small>{500 - permanentAddressLength} characters left</small>
|
||||||
</div>
|
</div>
|
||||||
{errors.PermanentAddress && (
|
{errors.PermanentAddress && (
|
||||||
<div
|
<div
|
||||||
|
Loading…
x
Reference in New Issue
Block a user