Do not close the modal after creating an activity.

This commit is contained in:
ashutosh.nehete 2025-06-27 17:53:44 +05:30
parent ff16baf0e2
commit a5e7766a2f

View File

@ -80,7 +80,15 @@ const CreateActivity = ({ onClose }) => {
cacheData("Activity", updatedData);
showToast("Activity Successfully Added.", "success");
setIsLoading(false);
handleClose();
reset({
activityName: "",
unitOfMeasurement: "",
checkList: [],
serviceId: "",
actitvityGroupId: "",
});
setSelectedService(null)
// handleClose();
})
.catch((error) => {
showToast(error.message, "error");
@ -168,34 +176,6 @@ const CreateActivity = ({ onClose }) => {
<form onSubmit={handleSubmit(onSubmit)}>
{/* <h6>Create Activity</h6> */}
<div className="row">
<div className="col-6">
<label className="form-label">Activity</label>
<input
type="text"
{...register("activityName")}
className={`form-control form-control-sm ${
errors.activityName ? "is-invalid" : ""
}`}
/>
{errors.activityName && (
<p className="danger-text">{errors.activityName.message}</p>
)}
</div>
<div className="col-6">
<label className="form-label">Measurement</label>
<input
type="text"
{...register("unitOfMeasurement")}
className={`form-control form-control-sm ${
errors.unitOfMeasurement ? "is-invalid" : ""
}`}
/>
{errors.unitOfMeasurement && (
<p className="danger-text">{errors.unitOfMeasurement.message}</p>
)}
</div>
{/* Services */}
<div className="col-12 col-md-12">
<label className="form-label" htmlFor="serviceId">
@ -228,8 +208,40 @@ const CreateActivity = ({ onClose }) => {
)}
</div>
{/* Actitvity Group */}
{selectedService && (
<>
{/* Actitvity Name */}
<div className="col-6">
<label className="form-label">Activity</label>
<input
type="text"
{...register("activityName")}
className={`form-control form-control-sm ${
errors.activityName ? "is-invalid" : ""
}`}
/>
{errors.activityName && (
<p className="danger-text">{errors.activityName.message}</p>
)}
</div>
{/* Unit of Mesurement */}
<div className="col-6">
<label className="form-label">Unit of Measurement</label>
<input
type="text"
{...register("unitOfMeasurement")}
className={`form-control form-control-sm ${
errors.unitOfMeasurement ? "is-invalid" : ""
}`}
/>
{errors.unitOfMeasurement && (
<p className="danger-text">
{errors.unitOfMeasurement.message}
</p>
)}
</div>
{/* Actitvity Group */}
<div className="col-12 col-md-12">
<label className="form-label" htmlFor="actitvityGroupId">
Select Activity Group
@ -252,8 +264,9 @@ const CreateActivity = ({ onClose }) => {
</option>
))}
{activityGroupList?.filter((activityGroup) => activityGroup?.name)
.length === 0 && (
{activityGroupList?.filter(
(activityGroup) => activityGroup?.name
).length === 0 && (
<option disabled>No activity group found</option>
)}
</select>
@ -261,7 +274,6 @@ const CreateActivity = ({ onClose }) => {
<p className="danger-text">{errors.actitvityGroupId.message}</p>
)}
</div>
)}
<div className="col-md-12 text-start mt-1">
<p className="py-1 my-0">
@ -350,7 +362,7 @@ const CreateActivity = ({ onClose }) => {
<button
type="submit"
className="btn btn-sm btn-primary me-3"
disabled={isLoading || (selectedService == null)}
disabled={isLoading || selectedService == null}
>
{isLoading ? "Please Wait" : "Submit"}
</button>
@ -358,11 +370,13 @@ const CreateActivity = ({ onClose }) => {
type="reset"
className="btn btn-sm btn-label-secondary"
onClick={handleClose}
disabled={isLoading || (selectedService == null)}
disabled={isLoading || selectedService == null}
>
Cancel
</button>
</div>
</>
)}
</div>
</form>
);