Vaibhav_Task-#89 #29

Merged
vikas.nale merged 3 commits from Vaibhav_Task-#89 into Feature_Task_Management 2025-04-19 04:52:06 +00:00
2 changed files with 38 additions and 19 deletions
Showing only changes of commit 48d589d92c - Show all commits

View File

@ -21,8 +21,9 @@ const ManageProjectInfo = ( {project,handleSubmitForm, onClose} ) =>
const [CurrentProject,setCurrentProject] = useState() const [CurrentProject,setCurrentProject] = useState()
const [ isloading, setLoading ] = useState( false ) const [ isloading, setLoading ] = useState( false )
const [addressLength, setAddressLength] = useState(0);
const maxAddressLength = 500;
const projectSchema = z.object( { const projectSchema = z.object( {
...(project?.id ? { id: z.number().optional() } : {}), ...(project?.id ? { id: z.number().optional() } : {}),
name: z.string().min( 1, {message: "Project Name is required"} ), name: z.string().min( 1, {message: "Project Name is required"} ),
@ -79,7 +80,9 @@ const ManageProjectInfo = ( {project,handleSubmitForm, onClose} ) =>
projectStatusId: String(project.projectStatusId) || "0" , projectStatusId: String(project.projectStatusId) || "0" ,
} :{} } :{}
) )
setAddressLength(project?.projectAddress?.length || 0);
},[project,reset,]) },[project,reset,])
@ -205,16 +208,20 @@ const ManageProjectInfo = ( {project,handleSubmitForm, onClose} ) =>
</label> </label>
<div className="input-group"> <div className="input-group">
<textarea <textarea
type="text"
id="projectAddress" id="projectAddress"
name="projectAddress" name="projectAddress"
className="form-control" className="form-control"
{...register( "projectAddress" )} maxLength={maxAddressLength}
{...register("projectAddress")}
onChange={(e) => {
setAddressLength(e.target.value.length);
}}
/> />
</div> </div>
<div className="text-end" style={{ fontSize: "12px" }}>
{maxAddressLength - addressLength} characters remaining
</div>
{errors.projectAddress && <div className="danger-text text-start" style={{fontSize:"12px"}}>{errors.projectAddress.message}</div>} {errors.projectAddress && <div className="danger-text text-start" style={{fontSize:"12px"}}>{errors.projectAddress.message}</div>}
</div> </div>
<div className="col-12 text-center"> <div className="col-12 text-center">
<button type="submit" className="btn btn-sm btn-primary me-3" > <button type="submit" className="btn btn-sm btn-primary me-3" >

View File

@ -64,13 +64,17 @@ const EditJobRole = ({data,onClose}) => {
}; };
useEffect(()=>{ useEffect(() => {
reset({ reset({
role:data?.name, role: data?.name,
description:data?.description description: data?.description
}) });
setDescriptionLength(data?.description?.length || 0);
}, [data, reset]);
},[data,reset]) const [descriptionLength, setDescriptionLength] = useState(data?.description?.length || 0);
const maxDescriptionLength = 255;
return (<> return (<>
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}> <form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
@ -84,14 +88,22 @@ const EditJobRole = ({data,onClose}) => {
</div> </div>
<div className="col-12 col-md-12"> <div className="col-12 col-md-12">
<label className="form-label" htmlFor="description">Description</label> <label className="form-label" htmlFor="description">Description</label>
<textarea <textarea
rows="3" rows="3"
{...register("description")} {...register("description")}
className={`form-control ${errors.description ? 'is-invalids' : ''}`} className={`form-control ${errors.description ? 'is-invalids' : ''}`}
></textarea> onChange={(e) => {
{errors.description && ( setDescriptionLength(e.target.value.length);
<p className="text-danger">{errors.description.message}</p> register("description").onChange(e);
)} }}
></textarea>
<div className="text-end small text-muted">
{maxDescriptionLength - descriptionLength} characters left
</div>
{errors.description && (
<p className="text-danger">{errors.description.message}</p>
)}
</div> </div>
<div className="col-12 text-center"> <div className="col-12 text-center">