Do not close the modal after creating an activity.
This commit is contained in:
		
							parent
							
								
									ff16baf0e2
								
							
						
					
					
						commit
						a5e7766a2f
					
				@ -80,7 +80,15 @@ const CreateActivity = ({ onClose }) => {
 | 
				
			|||||||
        cacheData("Activity", updatedData);
 | 
					        cacheData("Activity", updatedData);
 | 
				
			||||||
        showToast("Activity Successfully Added.", "success");
 | 
					        showToast("Activity Successfully Added.", "success");
 | 
				
			||||||
        setIsLoading(false);
 | 
					        setIsLoading(false);
 | 
				
			||||||
        handleClose();
 | 
					        reset({
 | 
				
			||||||
 | 
					          activityName: "",
 | 
				
			||||||
 | 
					          unitOfMeasurement: "",
 | 
				
			||||||
 | 
					          checkList: [],
 | 
				
			||||||
 | 
					          serviceId: "",
 | 
				
			||||||
 | 
					          actitvityGroupId: "",
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        setSelectedService(null)
 | 
				
			||||||
 | 
					        // handleClose();
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
      .catch((error) => {
 | 
					      .catch((error) => {
 | 
				
			||||||
        showToast(error.message, "error");
 | 
					        showToast(error.message, "error");
 | 
				
			||||||
@ -168,34 +176,6 @@ const CreateActivity = ({ onClose }) => {
 | 
				
			|||||||
    <form onSubmit={handleSubmit(onSubmit)}>
 | 
					    <form onSubmit={handleSubmit(onSubmit)}>
 | 
				
			||||||
      {/* <h6>Create Activity</h6> */}
 | 
					      {/* <h6>Create Activity</h6> */}
 | 
				
			||||||
      <div className="row">
 | 
					      <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 */}
 | 
					        {/* Services */}
 | 
				
			||||||
        <div className="col-12 col-md-12">
 | 
					        <div className="col-12 col-md-12">
 | 
				
			||||||
          <label className="form-label" htmlFor="serviceId">
 | 
					          <label className="form-label" htmlFor="serviceId">
 | 
				
			||||||
@ -228,8 +208,40 @@ const CreateActivity = ({ onClose }) => {
 | 
				
			|||||||
          )}
 | 
					          )}
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        {/* Actitvity Group */}
 | 
					 | 
				
			||||||
        {selectedService && (
 | 
					        {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">
 | 
					            <div className="col-12 col-md-12">
 | 
				
			||||||
              <label className="form-label" htmlFor="actitvityGroupId">
 | 
					              <label className="form-label" htmlFor="actitvityGroupId">
 | 
				
			||||||
                Select Activity Group
 | 
					                Select Activity Group
 | 
				
			||||||
@ -252,8 +264,9 @@ const CreateActivity = ({ onClose }) => {
 | 
				
			|||||||
                    </option>
 | 
					                    </option>
 | 
				
			||||||
                  ))}
 | 
					                  ))}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
              {activityGroupList?.filter((activityGroup) => activityGroup?.name)
 | 
					                {activityGroupList?.filter(
 | 
				
			||||||
                .length === 0 && (
 | 
					                  (activityGroup) => activityGroup?.name
 | 
				
			||||||
 | 
					                ).length === 0 && (
 | 
				
			||||||
                  <option disabled>No activity group found</option>
 | 
					                  <option disabled>No activity group found</option>
 | 
				
			||||||
                )}
 | 
					                )}
 | 
				
			||||||
              </select>
 | 
					              </select>
 | 
				
			||||||
@ -261,7 +274,6 @@ const CreateActivity = ({ onClose }) => {
 | 
				
			|||||||
                <p className="danger-text">{errors.actitvityGroupId.message}</p>
 | 
					                <p className="danger-text">{errors.actitvityGroupId.message}</p>
 | 
				
			||||||
              )}
 | 
					              )}
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
        )}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <div className="col-md-12 text-start mt-1">
 | 
					            <div className="col-md-12 text-start mt-1">
 | 
				
			||||||
              <p className="py-1 my-0">
 | 
					              <p className="py-1 my-0">
 | 
				
			||||||
@ -350,7 +362,7 @@ const CreateActivity = ({ onClose }) => {
 | 
				
			|||||||
              <button
 | 
					              <button
 | 
				
			||||||
                type="submit"
 | 
					                type="submit"
 | 
				
			||||||
                className="btn btn-sm btn-primary me-3"
 | 
					                className="btn btn-sm btn-primary me-3"
 | 
				
			||||||
            disabled={isLoading || (selectedService == null)}
 | 
					                disabled={isLoading || selectedService == null}
 | 
				
			||||||
              >
 | 
					              >
 | 
				
			||||||
                {isLoading ? "Please Wait" : "Submit"}
 | 
					                {isLoading ? "Please Wait" : "Submit"}
 | 
				
			||||||
              </button>
 | 
					              </button>
 | 
				
			||||||
@ -358,11 +370,13 @@ const CreateActivity = ({ onClose }) => {
 | 
				
			|||||||
                type="reset"
 | 
					                type="reset"
 | 
				
			||||||
                className="btn btn-sm btn-label-secondary"
 | 
					                className="btn btn-sm btn-label-secondary"
 | 
				
			||||||
                onClick={handleClose}
 | 
					                onClick={handleClose}
 | 
				
			||||||
            disabled={isLoading || (selectedService == null)}
 | 
					                disabled={isLoading || selectedService == null}
 | 
				
			||||||
              >
 | 
					              >
 | 
				
			||||||
                Cancel
 | 
					                Cancel
 | 
				
			||||||
              </button>
 | 
					              </button>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
					          </>
 | 
				
			||||||
 | 
					        )}
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </form>
 | 
					    </form>
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user