parsley/app/javascript/router.js

73 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-03-29 01:57:00 -05:00
import Vue from 'vue';
import Router from 'vue-router';
2018-03-30 14:31:09 -05:00
import RecipeEdit from './components/RecipeEdit';
import RecipeShow from './components/RecipeShow';
2018-03-29 01:57:00 -05:00
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-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: '/',
name: 'recipeList',
component: TheRecipeList
},
2018-03-30 14:31:09 -05:00
{
path: '/recipes/:id/edit',
name: 'edit_recipe',
component: RecipeEdit
},
{
path: '/recipe/:id',
name: 'recipe',
component: RecipeShow
},
{
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;