generated from csci5117s24/Project-2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
412261c
commit d9b6cc9
Showing
34 changed files
with
863 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Modal from 'react-bootstrap/Modal' | ||
import styles from "../css/QueueItem.module.css"; | ||
import ListGroup from 'react-bootstrap/ListGroup' | ||
import SearchResult from './SearchResultBootstrap'; | ||
import Layout from "../css/ItemPageLayout.module.css"; | ||
import AddButton from '../components/AddButton'; | ||
import { useEffect, useState } from 'react' | ||
import { ReactComponent as Enqueue } from '../assets/enqueue.svg' | ||
|
||
export default function AddRecipeQueuePopup({ addRecipe }) { | ||
const [show, setShow] = useState(false) | ||
const [recipes, setRecipes] = useState([]) | ||
|
||
async function setShowPopup(show) { | ||
if (show) { | ||
const res = await fetch("/api/recipes", { method: "GET" }) | ||
if (!res.ok) { | ||
console.log(res) | ||
window.alert("Error getting recipes!") | ||
return | ||
} | ||
console.log(res) | ||
const resJson = await res.json() | ||
console.log(resJson) | ||
setRecipes(resJson.recipes) | ||
} | ||
if (!show) setRecipes([]) | ||
setShow(show) | ||
} | ||
|
||
return <> | ||
<div className ={Layout.centerrow+" "+Layout.stickaddbutton} | ||
onClick={()=>setShowPopup(true)}> | ||
<AddButton/> | ||
</div> | ||
<Modal show={show} onHide={()=>setShowPopup(false)}> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Add Recipe to Queue</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<ListGroup className="list-group-flush"> | ||
{ recipes && recipes.length !== 0 ? | ||
recipes.map((e,i) => | ||
// using array index as keys here is fine so long as there is no way to add/remove elements from the array | ||
<div key={i} onClick={()=>{ | ||
addRecipe(e._id) | ||
setShow(false) | ||
}}> | ||
<SearchResult name={ e.name } image={e.image} | ||
buttonComp={ | ||
<button className={styles.enqueueButton} > | ||
<Enqueue className={styles.enqueue}/> | ||
</button>}></SearchResult> | ||
</div> | ||
) : <></> } | ||
</ListGroup> | ||
</Modal.Body> | ||
</Modal> | ||
</> | ||
} |
Oops, something went wrong.