mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-11 09:07:12 -05:00
auto space creation and redirect to welcome page
This commit is contained in:
@@ -38,6 +38,9 @@ import HorizontalRecipeScroller from "@/components/display/HorizontalRecipeWindo
|
||||
import HorizontalMealPlanWindow from "@/components/display/HorizontalMealPlanWindow.vue"
|
||||
import SearchPage from "@/pages/SearchPage.vue";
|
||||
import {useUserPreferenceStore} from "@/stores/UserPreferenceStore";
|
||||
import {useRouter} from "vue-router";
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const totalRecipes = ref(-1)
|
||||
|
||||
@@ -47,6 +50,10 @@ onMounted(() => {
|
||||
api.apiRecipeList({pageSize: 1}).then((r) => {
|
||||
totalRecipes.value = r.count
|
||||
})
|
||||
|
||||
if (!useUserPreferenceStore().activeSpace.spaceSetupCompleted) {
|
||||
router.push({name: 'WelcomePage'})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
54
vue3/src/pages/WelcomePage.vue
Normal file
54
vue3/src/pages/WelcomePage.vue
Normal file
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<v-container>
|
||||
<v-card>
|
||||
<v-card-title>Welcome</v-card-title>
|
||||
<v-card-text v-if="space">
|
||||
Welcome to Tandoor
|
||||
|
||||
<v-text-field v-model="space.name" :label="$t('Name')"></v-text-field>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
|
||||
import {ApiApi, Space} from "@/openapi";
|
||||
import {onMounted, ref} from "vue";
|
||||
import {ErrorMessageType, PreparedMessage, useMessageStore} from "@/stores/MessageStore.ts";
|
||||
import {useUserPreferenceStore} from "@/stores/UserPreferenceStore.ts";
|
||||
|
||||
const space = ref<undefined | Space>(undefined)
|
||||
|
||||
onMounted(() => {
|
||||
loadSpace()
|
||||
})
|
||||
|
||||
function loadSpace() {
|
||||
let api = new ApiApi()
|
||||
|
||||
api.apiSpaceCurrentRetrieve().then(r => {
|
||||
space.value = r
|
||||
}).catch(err => {
|
||||
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
|
||||
})
|
||||
}
|
||||
|
||||
function updateSpace() {
|
||||
let api = new ApiApi()
|
||||
api.apiSpacePartialUpdate({id: space.value.id, patchedSpace: space.value}).then(r => {
|
||||
space.value = r
|
||||
useUserPreferenceStore().activeSpace = Object.assign({}, space.value)
|
||||
useMessageStore().addPreparedMessage(PreparedMessage.UPDATE_SUCCESS, space.value)
|
||||
}).catch(err => {
|
||||
useMessageStore().addError(ErrorMessageType.UPDATE_ERROR, err)
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user