2018-03-29 01:57:00 -05:00
|
|
|
import Vue from 'vue';
|
|
|
|
import Router from 'vue-router';
|
|
|
|
|
|
|
|
import The404Page from './components/The404Page';
|
2018-03-30 14:31:09 -05:00
|
|
|
import TheAboutPage from './components/TheAboutPage';
|
|
|
|
import TheCalculator from './components/TheCalculator';
|
|
|
|
import TheIngredientList from './components/TheIngredientList';
|
|
|
|
import TheNotesList from './components/TheNotesList';
|
2018-04-01 21:43:23 -05:00
|
|
|
import TheRecipe from './components/TheRecipe';
|
|
|
|
import TheRecipeEditor from './components/TheRecipeEditor';
|
|
|
|
import TheRecipeCreator from './components/TheRecipeCreator';
|
2018-03-29 01:57:00 -05:00
|
|
|
import TheRecipeList from './components/TheRecipeList';
|
|
|
|
|
|
|
|
Vue.use(Router);
|
|
|
|
|
2018-04-01 12:17:54 -05:00
|
|
|
const router = new Router({
|
|
|
|
routes: []
|
|
|
|
});
|
|
|
|
|
|
|
|
router.addRoutes(
|
|
|
|
[
|
2018-03-29 01:57:00 -05:00
|
|
|
{
|
|
|
|
path: '/',
|
2018-04-01 21:43:23 -05:00
|
|
|
redirect: '/recipes'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/recipes',
|
2018-03-29 01:57:00 -05:00
|
|
|
name: 'recipeList',
|
|
|
|
component: TheRecipeList
|
|
|
|
},
|
2018-04-01 21:43:23 -05:00
|
|
|
{
|
|
|
|
path: '/recipes/new',
|
|
|
|
name: 'new_recipe',
|
|
|
|
component: TheRecipeCreator
|
|
|
|
},
|
2018-03-30 14:31:09 -05:00
|
|
|
{
|
|
|
|
path: '/recipes/:id/edit',
|
|
|
|
name: 'edit_recipe',
|
2018-04-01 21:43:23 -05:00
|
|
|
component: TheRecipeEditor
|
2018-03-30 14:31:09 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/recipe/:id',
|
|
|
|
name: 'recipe',
|
2018-04-01 21:43:23 -05:00
|
|
|
component: TheRecipe
|
2018-03-30 14:31:09 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/about",
|
|
|
|
name: "about",
|
|
|
|
component: TheAboutPage
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/calculator",
|
|
|
|
name: "calculator",
|
|
|
|
component: TheCalculator
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/ingredients",
|
|
|
|
name: "ingredients",
|
|
|
|
component: TheIngredientList
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/notes",
|
|
|
|
name: "notes",
|
|
|
|
component: TheNotesList
|
|
|
|
},
|
2018-04-01 12:17:54 -05:00
|
|
|
{
|
|
|
|
path: "/logout",
|
|
|
|
name: "logout",
|
|
|
|
beforeEnter: (to, from, next) => {
|
|
|
|
const $store = router.app.$store;
|
|
|
|
$store.dispatch("logout")
|
|
|
|
.then(() => next("/"));
|
|
|
|
}
|
|
|
|
},
|
2018-03-29 01:57:00 -05:00
|
|
|
{
|
|
|
|
path: '*',
|
|
|
|
component: The404Page
|
|
|
|
}
|
|
|
|
]
|
2018-04-01 12:17:54 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
export default router;
|