Moved actions to relevant pages, made recipes page
This commit is contained in:
parent
52b7059827
commit
ca5f749042
9 changed files with 46 additions and 41 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
<p>
|
<p>
|
||||||
<ul class="nav">
|
<ul class="nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<router-link class="nav-link" to="/" active-class="active">Actions</router-link>
|
<router-link class="nav-link" to="/recipes" active-class="active">Recipes</router-link>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<router-link class="nav-link" to="/mealplan" active-class="active">Meal Plan</router-link>
|
<router-link class="nav-link" to="/mealplan" active-class="active">Meal Plan</router-link>
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<action-item title="Add to next shop" :image="require('@/assets/add-cart.svg')" @click="addToNextShop" />
|
|
||||||
<action-item title="Add Recipe" :image="require('@/assets/add-recipe.svg')" @click="addRecipe" />
|
|
||||||
<action-item title="Plan Meal" :image="require('@/assets/plan-meal.svg')" @click="planMeal" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import ActionItem from './ActionItem.vue'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ActionsPage',
|
|
||||||
components: {
|
|
||||||
ActionItem
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
addToNextShop() {
|
|
||||||
console.log('Add to next shop')
|
|
||||||
},
|
|
||||||
addRecipe() {
|
|
||||||
console.log('Add Recipe')
|
|
||||||
this.$router.push('/recipes/add')
|
|
||||||
},
|
|
||||||
planMeal() {
|
|
||||||
console.log('Plan Meal')
|
|
||||||
this.$router.push('/meals/add')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
@ -180,7 +180,7 @@ export default {
|
||||||
async deleteRecipe() {
|
async deleteRecipe() {
|
||||||
if (confirm('Are you sure you want to delete this recipe?')) {
|
if (confirm('Are you sure you want to delete this recipe?')) {
|
||||||
await data.deleteRecipe(this.recipe.id);
|
await data.deleteRecipe(this.recipe.id);
|
||||||
this.$router.push('/');
|
this.$router.push('/recipes');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
<ul v-if="!meals.length">
|
<ul v-if="!meals.length">
|
||||||
<li>No meals planned</li>
|
<li>No meals planned</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<action-item title="Plan Meal" :image="require('@/assets/plan-meal.svg')" @click="() => this.$router.push('/meals/add')" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -76,14 +77,13 @@ ul.actions {
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import ActionItem from './ActionItem.vue'
|
||||||
import MealCard from './MealCard.vue'
|
import MealCard from './MealCard.vue'
|
||||||
import data from '@/data.js'
|
import data from '@/data.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'MealPlanPage',
|
name: 'MealPlanPage',
|
||||||
components: {
|
components: { MealCard, ActionItem },
|
||||||
MealCard
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
const from = new Date();
|
const from = new Date();
|
||||||
from.setTime(0);
|
from.setTime(0);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="recipe-search-box" @focusout="recipes = []">
|
<div class="recipe-search-box" @focusout="recipes = []">
|
||||||
<input type="text" v-model="searchTerm" @keyup.enter="search" @keyup.exit="clear" @focusin="search"
|
<input type="text" v-model="searchTerm" @keyup.enter="search" @keyup.exit="clear" @focusin="search"
|
||||||
placeholder="Add a recipe..." />
|
:placeholder="placeholder" />
|
||||||
<ul v-if="recipes?.length" class="dropdown">
|
<ul v-if="recipes?.length" class="dropdown">
|
||||||
<li class="recipe" v-for="recipe in recipes" :key="recipe.id" @mousedown="selectRecipe(recipe)">
|
<li class="recipe" v-for="recipe in recipes" :key="recipe.id" @mousedown="selectRecipe(recipe)">
|
||||||
<recipe-card :recipe="recipe" />
|
<recipe-card :recipe="recipe" />
|
||||||
|
|
@ -17,6 +17,9 @@ import RecipeCard from './RecipeCard.vue';
|
||||||
export default {
|
export default {
|
||||||
name: 'RecipeSearchBox',
|
name: 'RecipeSearchBox',
|
||||||
components: { RecipeCard },
|
components: { RecipeCard },
|
||||||
|
props: {
|
||||||
|
placeholder: { type: String, default: 'Add a recipe...' }
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
searchTerm: '',
|
searchTerm: '',
|
||||||
|
|
|
||||||
18
src/components/RecipesPage.vue
Normal file
18
src/components/RecipesPage.vue
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<recipe-search-box placeholder="Search for a recipe..." @select-recipe="(r) => this.$router.push(`/recipes/${r.id}`)"/>
|
||||||
|
<action-item title="Add new Recipe" :image="require('@/assets/add-recipe.svg')" @click="() => this.$router.push('/recipes/add')" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import ActionItem from './ActionItem.vue'
|
||||||
|
import RecipeSearchBox from './RecipeSearchBox.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'ActionsPage',
|
||||||
|
components: {
|
||||||
|
ActionItem,
|
||||||
|
RecipeSearchBox
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -1,5 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
Shopping
|
Shopping <br>
|
||||||
|
<action-item title="Add to next shop" :image="require('@/assets/add-cart.svg')" @click="() => this.$router.push('/')" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ActionItem from './ActionItem.vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'ShoppingPage',
|
||||||
|
components: {
|
||||||
|
ActionItem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -119,6 +119,7 @@ export default {
|
||||||
async deleteRecipe(id) {
|
async deleteRecipe(id) {
|
||||||
var response = await fetch(BASE_URL + `/recipes/${encodeURIComponent(id)}`, {
|
var response = await fetch(BASE_URL + `/recipes/${encodeURIComponent(id)}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
|
credentials: "include",
|
||||||
});
|
});
|
||||||
return await response.json();
|
return await response.json();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { createRouter, createWebHashHistory } from 'vue-router'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
|
|
||||||
import LoginPage from './components/LoginPage.vue'
|
import LoginPage from './components/LoginPage.vue'
|
||||||
import ActionsPage from './components/ActionsPage.vue'
|
import RecipesPage from './components/RecipesPage.vue'
|
||||||
import MealPlanPage from './components/MealPlanPage.vue'
|
import MealPlanPage from './components/MealPlanPage.vue'
|
||||||
import ShoppingPage from './components/ShoppingPage.vue'
|
import ShoppingPage from './components/ShoppingPage.vue'
|
||||||
import EditMealPage from './components/EditMealPage.vue'
|
import EditMealPage from './components/EditMealPage.vue'
|
||||||
|
|
@ -14,10 +14,11 @@ import EditRecipePage from './components/EditRecipePage.vue'
|
||||||
// Each route should map to a component.
|
// Each route should map to a component.
|
||||||
// We'll talk about nested routes later.
|
// We'll talk about nested routes later.
|
||||||
const routes = [
|
const routes = [
|
||||||
{ path: '/', component: ActionsPage },
|
{ path: '/', component: MealPlanPage },
|
||||||
{ path: '/login', component: LoginPage },
|
|
||||||
{ path: '/mealplan', component: MealPlanPage },
|
{ path: '/mealplan', component: MealPlanPage },
|
||||||
|
{ path: '/login', component: LoginPage },
|
||||||
{ path: '/shopping', component: ShoppingPage },
|
{ path: '/shopping', component: ShoppingPage },
|
||||||
|
{ path: '/recipes', component: RecipesPage },
|
||||||
{ path: '/recipes/add', component: EditRecipePage },
|
{ path: '/recipes/add', component: EditRecipePage },
|
||||||
{ path: '/recipes/:id', component: EditRecipePage, props: true },
|
{ path: '/recipes/:id', component: EditRecipePage, props: true },
|
||||||
{ path: '/meals/add', component: EditMealPage },
|
{ path: '/meals/add', component: EditMealPage },
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue