@@ -2,19 +2,22 @@ import React, { useContext } from "react";
22import Button from "../Button/Button" ;
33import { StepContext } from "../../context/StepContext" ;
44import { UserContext } from "../../context/UserContext" ;
5- import { Link } from "react-router-dom" ;
5+ import { Link , useHistory } from "react-router-dom" ;
66
77export default function Navbar ( ) {
88
99 const [ step , setStep ] = useContext ( StepContext ) ;
1010 const [ user , setUser ] = useContext ( UserContext ) ;
11+ let history = useHistory ( ) ;
1112
1213 /**
1314 * Skips the step without any checks on the inputs
1415 */
1516 const skipStep = ( ) => {
1617 if ( step < 3 ) {
1718 setStep ( step + 1 ) ;
19+ // go to the next page
20+ history . push ( '/step' + ( step + 1 ) )
1821 }
1922 }
2023
@@ -33,25 +36,8 @@ export default function Navbar() {
3336 < Button typeClass = "link" text = "Back to the homepage" arrow = "right" handleClick = { backToHome } />
3437 </ Link >
3538 < div className = "flex" >
36- { ( step === 1 ) &&
37- < Link to = "/step2" >
38- < Button typeClass = "btn btn__skip pad" text = "Skip for now" handleClick = { skipStep } />
39- </ Link >
40- }
41- { ( step === 2 ) &&
42- < Link to = "/step3" >
43- < Button typeClass = "btn btn__skip pad" text = "Skip for now" handleClick = { skipStep } />
44- </ Link >
45- }
46- { ( step === 3 ) &&
47- < Link to = "/step3" >
48- < Button typeClass = "btn btn__skip pad" text = "Skip for now" handleClick = { skipStep } />
49- </ Link >
50- }
51- {
52- step === 3 ? < Button typeClass = "btn btn__next" text = "Finish" form = "form-id" />
53- : < Button typeClass = "btn btn__next" text = "Next Step" arrow = "left" form = "form-id" />
54- }
39+ < Button typeClass = "btn btn__skip pad" text = "Skip for now" handleClick = { skipStep } />
40+ < Button typeClass = "btn btn__next" text = { step === 3 ? "Finish" : "Next Step" } arrow = { step !== 3 && "left" } form = "form-id" />
5541 </ div >
5642 </ div >
5743 )
0 commit comments