Skip to content

Commit 0eace5f

Browse files
committed
add redirection after updating
1 parent ed854d3 commit 0eace5f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/pages/updateTrainee/traineUpdate.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useAppSelector, useAppDispatch } from "../../hooks/hooks";
99
import { toast } from "react-hot-toast";
1010
import NavBar from "../../components/sidebar/navHeader";
1111
import { useParams } from "react-router";
12+
import { useNavigate } from "react-router-dom";
1213
import options from "./traineeInputs";
1314
import { Link } from "react-router-dom";
1415
import { ThreeDots } from "react-loader-spinner";
@@ -21,6 +22,7 @@ const TraineeUpdate = (props: any) => {
2122
const params = useParams();
2223
const [ID, setId] = useState(params.traineeId);
2324
const dispatch = useAppDispatch();
25+
const navigate = useNavigate();
2426
const traineeData = useAppSelector(
2527
(state: any) => state.getOneTraineeReducer?.data
2628
);
@@ -201,6 +203,13 @@ const TraineeUpdate = (props: any) => {
201203
await dispatch(updateTraine(inputTrainee));
202204
await dispatch(updateTraineeAttributes(inputAttributes));
203205
toast.success("Trainee updated successfully");
206+
207+
const timer = setTimeout(() => {
208+
navigate("/admin/Trainee-applicants");
209+
}, 4000);
210+
211+
return () => clearTimeout(timer);
212+
204213
} catch (err) {
205214
console.log(err);
206215
toast.error("Updating trainee failed");

0 commit comments

Comments
 (0)