diff --git a/frontend/src/stores/plans.js b/frontend/src/stores/plans.js index 5d0f46b..8a7b9fa 100644 --- a/frontend/src/stores/plans.js +++ b/frontend/src/stores/plans.js @@ -1,6 +1,6 @@ import { defineStore } from 'pinia' import { ref, computed } from 'vue' -import { requestJSON, api } from '../composables/useApi' +import { api } from '../composables/useApi' export const usePlansStore = defineStore('plans', () => { const plans = ref([]) @@ -11,11 +11,13 @@ export const usePlansStore = defineStore('plans', () => { const pendingPlans = computed(() => plans.value.filter(p => p.status === 'pending')) async function loadPlans() { - plans.value = await requestJSON('/api/oil-plans') + const res = await api('/api/oil-plans') + if (res.ok) plans.value = await res.json() } async function loadTeachers() { - teachers.value = await requestJSON('/api/teachers') + const res = await api('/api/teachers') + if (res.ok) teachers.value = await res.json() } async function createPlan(healthDesc, teacherId) { @@ -50,7 +52,8 @@ export const usePlansStore = defineStore('plans', () => { } async function loadShoppingList(planId) { - shoppingList.value = await requestJSON(`/api/oil-plans/${planId}/shopping-list`) + const res = await api(`/api/oil-plans/${planId}/shopping-list`) + if (res.ok) shoppingList.value = await res.json() } return {