Skip to content

Commit

Permalink
layout
Browse files Browse the repository at this point in the history
  • Loading branch information
nadinestrella committed Jul 18, 2024
1 parent 70f4fed commit 558bfca
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/app/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<div className="actions">
<div className="actions__wrapper">
{currentStepIndex > 0 && currentStepIndex < steps.length ? (
<button
className="actions__button"
onClick={() => setCurrentStepIndex(currentStepIndex - 1)}
>
<i className="fa-solid fa-arrow-left"></i>
</button>
) : null}
</div>
<div className="actions__wrapper">
{currentStepIndex !== steps.length - 1 ? (
<button
className="actions__button"
onClick={() => {
setCurrentStepIndex(currentStepIndex + 1);
}}
>
<i className="fa-solid fa-arrow-right"></i>
</button>
) : null}
</div>
</div>
{children}
</>
);
}

0 comments on commit 558bfca

Please sign in to comment.