Bugfix order process/account update

This commit is contained in:
2024-11-15 11:36:17 +01:00
parent 86acedc8aa
commit 70e508ce7a
9 changed files with 194 additions and 206 deletions

View File

@@ -154,7 +154,8 @@ account.patch("/", verifyToken, (req: Request, res: Response) => {
} }
// Status: 200 OK // Status: 200 OK
res.status(200).json(account) let accountData = await Account.findByPk(req.body.id, { include: [ Payment, AccountRole, Address ]})
res.status(200).json(accountData)
}) })
.catch(error => { .catch(error => {
// Status: 400 Bad request // Status: 400 Bad request

View File

@@ -33,8 +33,7 @@ exerciseStore.getAllExercises()
</div> </div>
<v-btn <v-btn
v-if="accountStore.userAccountToken != '' && v-if="accountStore.adminPanelVisible"
accountStore.userAccount.accountRole.privilegeAdminPanel"
variant="plain" variant="plain"
icon="mdi-table-cog" icon="mdi-table-cog"
to="/admin" to="/admin"

View File

@@ -25,6 +25,13 @@ export async function createOrder(
} }
} }
console.log({
accountId: accountId,
tickets: tickets,
paymentId: paymentId,
addressId: addressId
})
return axios.post(BASE_URL, { return axios.post(BASE_URL, {
accountId: accountId, accountId: accountId,
tickets: tickets, tickets: tickets,

View File

@@ -6,5 +6,5 @@ import { PaymentModel } from "./paymentModel"
export class AccountApiModel extends AccountModel { export class AccountApiModel extends AccountModel {
addresses: Array<AddressModel> addresses: Array<AddressModel>
payments: Array<PaymentModel> payments: Array<PaymentModel>
accountRole: AccountRole accountRole: AccountRole = new AccountRole()
} }

View File

@@ -4,6 +4,8 @@ import { useBasketStore } from '@/stores/basket.store';
import outlinedButton from '@/components/basics/outlinedButton.vue'; import outlinedButton from '@/components/basics/outlinedButton.vue';
import { ModelRef, ref } from 'vue'; import { ModelRef, ref } from 'vue';
import { useAccountStore } from '@/stores/account.store'; import { useAccountStore } from '@/stores/account.store';
import { AddressModel } from '@/data/models/user/addressModel';
import { PaymentModel } from '@/data/models/user/paymentModel';
const basketStore = useBasketStore() const basketStore = useBasketStore()
const accountStore = useAccountStore() const accountStore = useAccountStore()
@@ -32,6 +34,20 @@ async function doOrder() {
orderingInProgress.value = false orderingInProgress.value = false
} }
function addressItemProps(item: AddressModel) {
return {
title: item.street + " " + item.houseNumber,
subtitle: item.postalCode + " " + item.city
}
}
function paymentItemProps(item: PaymentModel) {
return {
title: item.bankName,
subtitle: item.iban
}
}
</script> </script>
<template> <template>
@@ -42,64 +58,33 @@ async function doOrder() {
max-width="800" max-width="800"
persistent persistent
> >
<v-radio-group class="pa-0" v-model="basketStore.usedAddress"> <v-container>
<v-list-subheader> <v-row>
{{ $t('account.userData.address', accountStore.userAccount.addresses.length) }} <v-col>
</v-list-subheader> <v-select
<v-list-item
v-for="address in accountStore.userAccount.addresses"
>
<v-list-item-title>
<v-radio :label="address.street + '' + address.houseNumber" />
</v-list-item-title>
<v-list-item-subtitle>
{{ address.postalCode }} {{ address.city }}
</v-list-item-subtitle>
<!-- <v-radio-group
v-model="basketStore.usedAddress" v-model="basketStore.usedAddress"
:error="addressError" :items="accountStore.userAccount.addresses"
> :item-props="addressItemProps"
<v-radio :label="$t('account.userData.address')"
v-for="address in accountStore.userAccount.addresses" variant="outlined"
:value="address" hide-details
:label="address.street + ' ' + address.houseNumber + ', ' + address.postalCode + ' ' + address.city"
/> />
</v-radio-group> --> </v-col>
</v-list-item> </v-row>
</v-radio-group>
<v-list> <v-row>
<v-list-subheader> <v-col>
{{ $t('account.userData.payment', accountStore.userAccount.payments.length) }} <v-select
</v-list-subheader>
<v-list-item v-for="payment in accountStore.userAccount.payments">
<template #prepend="{ isActive }">
<v-list-item-action start>
<v-radio :model-value="isActive" />
</v-list-item-action>
</template>
<v-list-item-title>{{ payment.bankName }}</v-list-item-title>
<v-list-item-subtitle>{{ payment.iban }}</v-list-item-subtitle>
<!-- <v-radio-group
v-model="basketStore.usedPayment" v-model="basketStore.usedPayment"
> :items="accountStore.userAccount.payments"
<v-radio :item-props="paymentItemProps"
:label="$t('account.userData.payment')"
:value="payment" variant="outlined"
:label="payment.bankName + ': ' + payment.iban" hide-details
:error="paymentError"
/> />
</v-radio-group> --> </v-col>
</v-list-item> </v-row>
</v-list> </v-container>
<template #actions> <template #actions>
<outlined-button <outlined-button

View File

@@ -49,13 +49,12 @@ watch(() => currentStep.value, () => {
max-width="800" max-width="800"
persistent persistent
> >
<template #borderless>
<v-stepper <v-stepper
v-model="currentStep" v-model="currentStep"
alt-labels alt-labels
flat flat
> >
<template #default="{ prev, next}"> <template #default="{ prev, next }">
<!-- Header items --> <!-- Header items -->
<v-stepper-header> <v-stepper-header>
<template v-for="(step, n) in steps"> <template v-for="(step, n) in steps">
@@ -180,6 +179,5 @@ watch(() => currentStep.value, () => {
</v-stepper-actions> </v-stepper-actions>
</template> </template>
</v-stepper> </v-stepper>
</template>
</action-dialog> </action-dialog>
</template> </template>

View File

@@ -30,7 +30,11 @@ export const useAccountStore = defineStore("accountStore", {
registerData: ref<AccountModel>(new AccountModel()), registerData: ref<AccountModel>(new AccountModel()),
/** Request to server sent, waiting for data response */ /** Request to server sent, waiting for data response */
fetchInProgress: ref(false) fetchInProgress: ref(false),
adminPanelVisible: ref(false),
privilegeBuy: ref(false)
}), }),
actions: { actions: {
@@ -73,26 +77,11 @@ export const useAccountStore = defineStore("accountStore", {
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGINSUCCESSFUL) feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGINSUCCESSFUL)
this.fetchInProgress = false this.fetchInProgress = false
this.privilegeBuy = true
this.adminPanelVisible = account.data.accountRole.privilegeAdminPanel
}) })
}) })
// await loginAccount(this.loginData.username, this.loginData.password)
// .then(async result => {
// this.userAccountId = result.data.id
// this.userLoggedIn = true
// fetchAddresses(result.data.id)
// .then(addresses => {
// })
// feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGINSUCCESSFUL)
// this.fetchInProgress = false
// return true
// })
.catch(error => { .catch(error => {
if (error.status == 400) { if (error.status == 400) {
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGINERROR) feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGINERROR)
@@ -170,6 +159,8 @@ export const useAccountStore = defineStore("accountStore", {
this.userAccount = new AccountModel() this.userAccount = new AccountModel()
this.userAccountId = -1 this.userAccountId = -1
this.loggedIn = false this.loggedIn = false
this.privilegeBuy = false
this.adminPanelVisible = false
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGOUTSUCCESSFUL) feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGOUTSUCCESSFUL)
}, },

View File

@@ -19,10 +19,10 @@ export const useBasketStore = defineStore('basketStore', {
itemsInBasket: useLocalStorage<Array<BasketItemModel>>("hackmycart/basketStore/itemsInBasket", []), itemsInBasket: useLocalStorage<Array<BasketItemModel>>("hackmycart/basketStore/itemsInBasket", []),
/** Address used in the order dialog */ /** Address used in the order dialog */
usedAddress: useLocalStorage("hackmycart/basketStore/usedAddress", new AddressModel()), usedAddress: ref(new AddressModel()),
/** Payment method used in the order dialog */ /** Payment method used in the order dialog */
usedPayment: useLocalStorage("hackmycart/basketStore/usedPayment", new PaymentModel()), usedPayment: ref(new PaymentModel()),
/** Selected seats in the booking page */ /** Selected seats in the booking page */
selectedSeats: ref<Array<SelectedSeatModel>>([]) selectedSeats: ref<Array<SelectedSeatModel>>([])

View File

@@ -9,6 +9,8 @@ import { BannerStateEnum } from "@/data/enums/bannerStateEnum";
import { useFeedbackStore } from "./feedback.store"; import { useFeedbackStore } from "./feedback.store";
import { useBasketStore } from "./basket.store"; import { useBasketStore } from "./basket.store";
import { useExerciseStore } from "./exercise.store"; import { useExerciseStore } from "./exercise.store";
import { useAccountStore } from "./account.store";
import { AccountApiModel } from "@/data/models/user/accountApiModel";
export const usePreferencesStore = defineStore('preferencesStore', { export const usePreferencesStore = defineStore('preferencesStore', {
state: () => ({ state: () => ({
@@ -115,6 +117,7 @@ export const usePreferencesStore = defineStore('preferencesStore', {
*/ */
resetToFactorySettings() { resetToFactorySettings() {
const basketStore = useBasketStore() const basketStore = useBasketStore()
const accountStore = useAccountStore()
this.firstStartup = true this.firstStartup = true
this.studentName = "" this.studentName = ""
@@ -122,6 +125,10 @@ export const usePreferencesStore = defineStore('preferencesStore', {
this.theme = "dark" this.theme = "dark"
this.language = LanguageEnum.GERMAN this.language = LanguageEnum.GERMAN
basketStore.itemsInBasket = [] basketStore.itemsInBasket = []
accountStore.userAccountToken = ""
accountStore.userAccount = new AccountApiModel()
this.showFactoryResetDialog = false this.showFactoryResetDialog = false
} }