1
0
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:
vabene1111
2025-09-10 22:18:09 +02:00
parent c2533d9ea2
commit f2191f79dd
43 changed files with 184 additions and 9 deletions

View File

@@ -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>

View 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>