Exercise store, mark exercise 0.2 as solved on ticket buy
This commit is contained in:
@@ -9,9 +9,9 @@ import { ref } from "vue";
|
||||
import { SelectedSeatModel } from "../data/models/ordering/selectedSeatModel";
|
||||
import { calcPrice } from "@/scripts/concertScripts";
|
||||
import { BandModel } from "../data/models/acts/bandModel";
|
||||
import { ConcertModel } from "../data/models/acts/concertModel";
|
||||
import { useAccountStore } from "./account.store";
|
||||
import { createOrder } from "@/data/api/orderApi";
|
||||
import { useExerciseStore } from "./exercise.store";
|
||||
|
||||
export const useBasketStore = defineStore('basketStore', {
|
||||
state: () => ({
|
||||
@@ -97,6 +97,7 @@ export const useBasketStore = defineStore('basketStore', {
|
||||
async takeOrder() {
|
||||
const accountStore = useAccountStore()
|
||||
const feedbackStore = useFeedbackStore()
|
||||
const exerciseStore = useExerciseStore()
|
||||
|
||||
await createOrder(
|
||||
accountStore.userAccount.id,
|
||||
@@ -110,6 +111,9 @@ export const useBasketStore = defineStore('basketStore', {
|
||||
|
||||
this.itemsInBasket = []
|
||||
feedbackStore.changeBanner(BannerStateEnum.ORDERPLACESUCCESSFUL)
|
||||
|
||||
// Exercise 0.2 is solved
|
||||
exerciseStore.solveExercise(0, 2)
|
||||
} else {
|
||||
feedbackStore.changeBanner(BannerStateEnum.ERROR)
|
||||
}
|
||||
|
||||
34
software/src/stores/exercise.store.ts
Normal file
34
software/src/stores/exercise.store.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { fetchAllExerciseGroups, updateExercise } from "@/data/api/exerciseApi";
|
||||
import { ExerciseGroupApiModel } from "@/data/models/exercises/exerciseGroupApiModel";
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
|
||||
export const useExerciseStore = defineStore("exerciseStore", {
|
||||
state: () => ({
|
||||
exerciseGroups: ref<Array<ExerciseGroupApiModel>>([]),
|
||||
|
||||
/** Request to server sent, waiting for data response */
|
||||
fetchInProgress: ref(false)
|
||||
}),
|
||||
|
||||
actions: {
|
||||
getAllExercises() {
|
||||
this.fetchInProgress = true
|
||||
|
||||
fetchAllExerciseGroups()
|
||||
.then(result => {
|
||||
this.exerciseGroups = result.data
|
||||
this.fetchInProgress = false
|
||||
})
|
||||
},
|
||||
|
||||
solveExercise(exerciseGroupNr: number, exerciseNr: number) {
|
||||
this.fetchInProgress = true
|
||||
|
||||
updateExercise(exerciseGroupNr, exerciseNr, true)
|
||||
.then(result => {
|
||||
this.getAllExercises()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user