-
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.
- Loading branch information
1 parent
bd19dae
commit 6356dfb
Showing
14 changed files
with
413 additions
and
65 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
This file was deleted.
Oops, something went wrong.
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
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
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,93 @@ | ||
import { Text } from "@rneui/base"; | ||
import axios from "axios"; | ||
import { useState, useEffect } from "react"; | ||
import { Button, View } from "react-native"; | ||
|
||
|
||
export function AddToMenu({ onMenuUpdated }) { | ||
|
||
|
||
|
||
const [recipes, setRecipes] = useState([]) | ||
|
||
async function loadRecipes() { | ||
const response = await axios.get('http://localhost:3000/recipes'); | ||
setRecipes(response.data); | ||
} | ||
|
||
useEffect(() => { | ||
loadRecipes() | ||
}, []) | ||
|
||
const [addToMenuForm, setAddToMenuForm] = useState({ | ||
date: '', | ||
main: '', | ||
type: '', | ||
}) | ||
|
||
async function addToMenu() { | ||
console.log(addToMenuForm) | ||
// const response = await axios.post('http://localhost:3000/menus', addToMenuForm); | ||
onMenuUpdated() | ||
setAddToMenuForm({ | ||
date: '', | ||
main: '', | ||
type: '', | ||
}) | ||
} | ||
|
||
function handleChange(e) { | ||
const { name, value } = e.target; | ||
setAddToMenuForm({ ...addToMenuForm, [name]: value }) | ||
} | ||
|
||
|
||
return ( | ||
<View> | ||
<Text>Add to Menu</Text> | ||
|
||
{/* <input | ||
onChange={(e) => { handleChange(e) }} | ||
type="date" | ||
name="date" | ||
value={addToMenuForm.date} | ||
required | ||
/> | ||
<select | ||
onChange={(e) => { handleChange(e) }} | ||
name="main" | ||
value={addToMenuForm.main} | ||
required | ||
> | ||
<option value="">Select...</option> | ||
{recipes.map(recipe => { | ||
return ( | ||
<option | ||
key={recipe._id} | ||
value={recipe._id} | ||
> | ||
{recipe.name} | ||
</option> | ||
) | ||
})} | ||
</select> | ||
<select | ||
name="type" | ||
onChange={(e) => { handleChange(e) }} | ||
value={addToMenuForm.type} | ||
required | ||
> | ||
<option value="">Select...</option> | ||
<option value="Breakfast">Breakfast</option> | ||
<option value="Lunch">Lunch</option> | ||
<option value="Dinner">Dinner</option> | ||
<option value="Snack">Snack</option> | ||
<option value="Dessert">Dessert</option> | ||
</select> */} | ||
|
||
<Button title="Add to Menu" onPress={addToMenu} type="submit" /> | ||
|
||
</View> | ||
) | ||
} |
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,31 @@ | ||
import { ScrollView, Text } from "react-native"; | ||
import { View } from "react-native"; | ||
import { MenuMeal } from "./MenuMeal"; | ||
|
||
export function MenuDay({ menuDay, onMealSelect, onSelectDay, mealsSelected }) { | ||
|
||
const mealids = menuDay.meals.map(meal => meal._id); | ||
|
||
|
||
const { date, meals } = menuDay; | ||
// const formattedDate = (new Date(date)).toISOString().split('T')[0]; | ||
const formattedDate = (new Date(date)).toUTCString().split(' ').slice(0, 4).join(' '); | ||
|
||
let daySelected = mealids.every(id => mealsSelected.includes(id)); | ||
|
||
|
||
|
||
return ( | ||
|
||
<View className="menu-day-row"> | ||
<View style={{ width: '20%', height: 200, backgroundColor: 'green', borderRadius: 10, padding: 5, flexDirection: "row" }} onClick={() => onSelectDay(mealids)} className={`menu-date-box ${daySelected ? 'selected' : ''}`}><Text>{formattedDate}</Text></View> | ||
|
||
<ScrollView horizontal style={{ flexDirection: "row" }}> | ||
{meals.map(meal => ( | ||
<MenuMeal key={meal._id} meal={meal} onSelect={onMealSelect} mealsSelected={mealsSelected} /> | ||
))} | ||
</ScrollView> | ||
</View> | ||
|
||
) | ||
} |
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,13 @@ | ||
import { Text, View } from 'react-native'; | ||
|
||
export function MenuMeal({ meal, onSelect, mealsSelected }) { | ||
|
||
const mealSelected = mealsSelected.includes(meal._id); | ||
|
||
return ( | ||
<View style={{backgroundColor:'red', borderRadius: 10, padding: 4, width: 150}} onClick={(e) => onSelect(e)} id={meal._id} key={meal._id} className={`menu-meal-box ${meal.type.toLowerCase()} ${mealSelected ? 'selected' : ''}`}> | ||
<Text >{meal.main.name} - {meal.type}</Text> | ||
</View> | ||
|
||
) | ||
} |
Oops, something went wrong.