diff --git a/src/app/components/Layout.tsx b/src/app/components/Layout.tsx new file mode 100644 index 0000000..00c4bac --- /dev/null +++ b/src/app/components/Layout.tsx @@ -0,0 +1,50 @@ +import { useState, useEffect } from 'react'; +import { useNavigate } from 'react-router-dom'; + +const steps = [ + '/', + '/kidswelcome', + '/categories', + '/listtoy', + '/selectedtoys', + '/finallist', +]; + +export default function Layout({ children }) { + const [currentStepIndex, setCurrentStepIndex] = useState(0); + const navigate = useNavigate(); + + useEffect(() => { + navigate(steps[currentStepIndex]); + }, [currentStepIndex]); + + return ( + <> +
+
+ {currentStepIndex > 0 && currentStepIndex < steps.length ? ( + + ) : null} +
+
+ {currentStepIndex !== steps.length - 1 ? ( + + ) : null} +
+
+ {children} + + ); +}