mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-07 15:18:20 -05:00
playing with vueform
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {defineStore} from "pinia"
|
||||
import {acceptHMRUpdate, defineStore} from "pinia"
|
||||
import {ApiApi, MealPlan} from "@/openapi";
|
||||
import {computed, ref} from "vue";
|
||||
import {DateTime} from "luxon";
|
||||
@@ -60,12 +60,21 @@ export const useMealPlanStore = defineStore(_STORE_ID, () => {
|
||||
currently_updating.value = [new Date(0), new Date(0)]
|
||||
})
|
||||
}
|
||||
return new Promise(() => {})
|
||||
return new Promise(() => {
|
||||
})
|
||||
}
|
||||
|
||||
function createOrUpdate(object: MealPlan) {
|
||||
if(object.id == undefined){
|
||||
return createObject(object)
|
||||
} else {
|
||||
return updateObject(object)
|
||||
}
|
||||
}
|
||||
|
||||
function createObject(object: MealPlan) {
|
||||
const api = new ApiApi()
|
||||
return api.apiMealPlanCreate({mealPlan: object}).then((r) => {
|
||||
return api.apiMealPlanCreate({mealPlanRequest: object}).then((r) => {
|
||||
//StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_CREATE)
|
||||
plans.value.set(r.id, r)
|
||||
return r
|
||||
@@ -76,7 +85,7 @@ export const useMealPlanStore = defineStore(_STORE_ID, () => {
|
||||
|
||||
function updateObject(object: MealPlan) {
|
||||
const api = new ApiApi()
|
||||
return api.apiMealPlanUpdate({id: object.id, mealPlan: object}).then((r) => {
|
||||
return api.apiMealPlanUpdate({id: object.id, mealPlanRequest: object}).then((r) => {
|
||||
//StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_UPDATE)
|
||||
plans.value.set(r.id, r)
|
||||
}).catch((err) => {
|
||||
@@ -112,5 +121,10 @@ export const useMealPlanStore = defineStore(_STORE_ID, () => {
|
||||
// return JSON.parse(s)
|
||||
// }
|
||||
// }
|
||||
return {plans, currently_updating, plan_list, refreshFromAPI, createObject, updateObject, deleteObject}
|
||||
return {plans, currently_updating, plan_list, refreshFromAPI, createObject, updateObject, deleteObject, createOrUpdate}
|
||||
})
|
||||
|
||||
// enable hot reload for store
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useMealPlanStore, import.meta.hot))
|
||||
}
|
||||
Reference in New Issue
Block a user