2021-01-08 17:09:03 -09:00
|
|
|
import HomePage from "./pages/HomePage";
|
|
|
|
|
import Page404 from "./pages/404Page";
|
2021-01-17 22:22:54 -09:00
|
|
|
import SearchPage from "./pages/SearchPage";
|
2021-01-08 17:09:03 -09:00
|
|
|
import RecipePage from "./pages/RecipePage";
|
|
|
|
|
import RecipeNewPage from "./pages/RecipeNewPage";
|
|
|
|
|
import SettingsPage from "./pages/SettingsPage";
|
|
|
|
|
import MeaplPlanPage from "./pages/MealPlanPage";
|
|
|
|
|
import MealPlanThisWeekPage from "./pages/MealPlanThisWeekPage";
|
2020-12-24 16:37:38 -09:00
|
|
|
import api from "./api";
|
|
|
|
|
|
|
|
|
|
export const routes = [
|
2021-01-08 17:09:03 -09:00
|
|
|
{ path: "/", component: HomePage },
|
|
|
|
|
{ path: "/mealie", component: HomePage },
|
2021-01-17 22:22:54 -09:00
|
|
|
{ path: "/search", component: SearchPage },
|
2021-01-08 17:09:03 -09:00
|
|
|
{ path: "/recipe/:recipe", component: RecipePage },
|
|
|
|
|
{ path: "/new/", component: RecipeNewPage },
|
|
|
|
|
{ path: "/settings/site", component: SettingsPage },
|
|
|
|
|
{ path: "/meal-plan/planner", component: MeaplPlanPage },
|
|
|
|
|
{ path: "/meal-plan/this-week", component: MealPlanThisWeekPage },
|
2020-12-24 16:37:38 -09:00
|
|
|
{
|
|
|
|
|
path: "/meal-plan/today",
|
2021-01-08 17:09:03 -09:00
|
|
|
beforeEnter: async (_to, _from, next) => {
|
2020-12-24 16:37:38 -09:00
|
|
|
await todaysMealRoute().then((redirect) => {
|
|
|
|
|
next(redirect);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ path: "*", component: Page404 },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
async function todaysMealRoute() {
|
|
|
|
|
const response = await api.mealPlans.today();
|
|
|
|
|
return "/recipe/" + response.data;
|
|
|
|
|
}
|