Skip to content

Commit

Permalink
randomise dishes on launch
Browse files Browse the repository at this point in the history
  • Loading branch information
mulundapm committed Jul 5, 2024
1 parent deca9ce commit ee93f26
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Components/HighlightedDish.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ import { Dishes } from '../API/Dishes';

function HighlightedDish() {

const [availableDishes, setAvailableDishes] = useState(Dishes)
const randomisedDishes = (dishes) => {
let currentIndex = dishes.length;
while (currentIndex !== 0 ){
let randomIndex = Math.floor(Math.random()* currentIndex);
currentIndex--;
[Dishes[currentIndex], Dishes[randomIndex]] = [Dishes[randomIndex],Dishes[currentIndex]]
}
return dishes
}

const [availableDishes, setAvailableDishes] = useState(randomisedDishes([...Dishes]))


const removeCard = () => {
setAvailableDishes((prev) =>{
Expand Down
12 changes: 12 additions & 0 deletions src/Contexts/Auth.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// import { useState } from "react";
// import a

// const AuthContext = React.createContext();

// export function AuthProvider({ children }){
// const [currentUser, setCurrentUser] = useState(null);
// const [userLoggedIn, setUserLoggedIn] = useState(false);
// const [loading, setLoading] = useState(true);


// }

0 comments on commit ee93f26

Please sign in to comment.