-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Image displaying doesn't work yet, checkbox feature added that accura…
…tely marks which boxes are being checked, doesnt implement that within the filter though
- Loading branch information
1 parent
8e8d94e
commit 12a8d45
Showing
20 changed files
with
173 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"use client"; | ||
// AllergiesPage.tsx | ||
// AllergiesPage.tsx | ||
import React, { useState, useEffect } from "react"; | ||
|
||
const AllergiesPage: React.FC<{ updateCheckedAllergies: (allergies: { [key: string]: boolean }) => void }> = ({ updateCheckedAllergies }) => { | ||
const [allergies, setAllergies] = useState<string[]>([ | ||
"Egg", | ||
"Fish", | ||
"Gluten Friendly", | ||
"Milk", | ||
"Peanut", | ||
"Soy", | ||
"Tree Nut", | ||
"Alcohol", | ||
"Vegan", | ||
"Vegetarian", | ||
"Pork", | ||
"Beef", | ||
"Halal", | ||
"Shellfish", | ||
"Sesame", | ||
]); | ||
|
||
const [checkedAllergies, setCheckedAllergies] = useState<{ [key: string]: boolean }>(() => { | ||
const savedAllergies = localStorage.getItem("checkedAllergies"); | ||
return savedAllergies ? JSON.parse(savedAllergies) : {}; | ||
}); | ||
|
||
useEffect(() => { | ||
localStorage.setItem("checkedAllergies", JSON.stringify(checkedAllergies)); | ||
updateCheckedAllergies(checkedAllergies); // Update parent state | ||
}, [checkedAllergies]); | ||
|
||
const handleCheckboxChange = (allergy: string) => { | ||
setCheckedAllergies(prevState => ({ ...prevState, [allergy]: !prevState[allergy] })); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h1>Allergies</h1> | ||
<ul> | ||
{allergies.map((allergy) => ( | ||
<li key={allergy}> | ||
<label> | ||
<input | ||
type="checkbox" | ||
checked={checkedAllergies[allergy] || false} | ||
onChange={() => handleCheckboxChange(allergy)} | ||
/> | ||
{allergy} | ||
</label> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AllergiesPage; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.main-container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
.search-bar { | ||
display: flex; | ||
margin-top: 20px; | ||
} | ||
|
||
.filter-box { | ||
cursor: pointer; | ||
margin-top: 10px; | ||
border: 1px solid #000; | ||
padding: 10px; | ||
} | ||
|
||
.filter-window { | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
background-color: #fff; | ||
border: 1px solid #000; | ||
padding: 20px; | ||
} | ||
|
||
.filter-content { | ||
text-align: center; | ||
} | ||
|
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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.
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.
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