Bugfix order process/account update
This commit is contained in:
@@ -154,7 +154,8 @@ account.patch("/", verifyToken, (req: Request, res: Response) => {
|
||||
}
|
||||
|
||||
// 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 => {
|
||||
// Status: 400 Bad request
|
||||
|
||||
@@ -33,8 +33,7 @@ exerciseStore.getAllExercises()
|
||||
</div>
|
||||
|
||||
<v-btn
|
||||
v-if="accountStore.userAccountToken != '' &&
|
||||
accountStore.userAccount.accountRole.privilegeAdminPanel"
|
||||
v-if="accountStore.adminPanelVisible"
|
||||
variant="plain"
|
||||
icon="mdi-table-cog"
|
||||
to="/admin"
|
||||
|
||||
@@ -25,6 +25,13 @@ export async function createOrder(
|
||||
}
|
||||
}
|
||||
|
||||
console.log({
|
||||
accountId: accountId,
|
||||
tickets: tickets,
|
||||
paymentId: paymentId,
|
||||
addressId: addressId
|
||||
})
|
||||
|
||||
return axios.post(BASE_URL, {
|
||||
accountId: accountId,
|
||||
tickets: tickets,
|
||||
|
||||
@@ -6,5 +6,5 @@ import { PaymentModel } from "./paymentModel"
|
||||
export class AccountApiModel extends AccountModel {
|
||||
addresses: Array<AddressModel>
|
||||
payments: Array<PaymentModel>
|
||||
accountRole: AccountRole
|
||||
accountRole: AccountRole = new AccountRole()
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import { useBasketStore } from '@/stores/basket.store';
|
||||
import outlinedButton from '@/components/basics/outlinedButton.vue';
|
||||
import { ModelRef, ref } from 'vue';
|
||||
import { useAccountStore } from '@/stores/account.store';
|
||||
import { AddressModel } from '@/data/models/user/addressModel';
|
||||
import { PaymentModel } from '@/data/models/user/paymentModel';
|
||||
|
||||
const basketStore = useBasketStore()
|
||||
const accountStore = useAccountStore()
|
||||
@@ -32,6 +34,20 @@ async function doOrder() {
|
||||
|
||||
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>
|
||||
|
||||
<template>
|
||||
@@ -42,64 +58,33 @@ async function doOrder() {
|
||||
max-width="800"
|
||||
persistent
|
||||
>
|
||||
<v-radio-group class="pa-0" v-model="basketStore.usedAddress">
|
||||
<v-list-subheader>
|
||||
{{ $t('account.userData.address', accountStore.userAccount.addresses.length) }}
|
||||
</v-list-subheader>
|
||||
|
||||
<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-container>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-select
|
||||
v-model="basketStore.usedAddress"
|
||||
:error="addressError"
|
||||
>
|
||||
<v-radio
|
||||
v-for="address in accountStore.userAccount.addresses"
|
||||
:value="address"
|
||||
:label="address.street + ' ' + address.houseNumber + ', ' + address.postalCode + ' ' + address.city"
|
||||
|
||||
:items="accountStore.userAccount.addresses"
|
||||
:item-props="addressItemProps"
|
||||
:label="$t('account.userData.address')"
|
||||
variant="outlined"
|
||||
hide-details
|
||||
/>
|
||||
</v-radio-group> -->
|
||||
</v-list-item>
|
||||
</v-radio-group>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-list>
|
||||
<v-list-subheader>
|
||||
{{ $t('account.userData.payment', accountStore.userAccount.payments.length) }}
|
||||
</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-row>
|
||||
<v-col>
|
||||
<v-select
|
||||
v-model="basketStore.usedPayment"
|
||||
>
|
||||
<v-radio
|
||||
|
||||
:value="payment"
|
||||
:label="payment.bankName + ': ' + payment.iban"
|
||||
:error="paymentError"
|
||||
:items="accountStore.userAccount.payments"
|
||||
:item-props="paymentItemProps"
|
||||
:label="$t('account.userData.payment')"
|
||||
variant="outlined"
|
||||
hide-details
|
||||
/>
|
||||
</v-radio-group> -->
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
|
||||
<template #actions>
|
||||
<outlined-button
|
||||
|
||||
@@ -49,13 +49,12 @@ watch(() => currentStep.value, () => {
|
||||
max-width="800"
|
||||
persistent
|
||||
>
|
||||
<template #borderless>
|
||||
<v-stepper
|
||||
v-model="currentStep"
|
||||
alt-labels
|
||||
flat
|
||||
>
|
||||
<template #default="{ prev, next}">
|
||||
<template #default="{ prev, next }">
|
||||
<!-- Header items -->
|
||||
<v-stepper-header>
|
||||
<template v-for="(step, n) in steps">
|
||||
@@ -180,6 +179,5 @@ watch(() => currentStep.value, () => {
|
||||
</v-stepper-actions>
|
||||
</template>
|
||||
</v-stepper>
|
||||
</template>
|
||||
</action-dialog>
|
||||
</template>
|
||||
@@ -30,7 +30,11 @@ export const useAccountStore = defineStore("accountStore", {
|
||||
registerData: ref<AccountModel>(new AccountModel()),
|
||||
|
||||
/** Request to server sent, waiting for data response */
|
||||
fetchInProgress: ref(false)
|
||||
fetchInProgress: ref(false),
|
||||
|
||||
adminPanelVisible: ref(false),
|
||||
|
||||
privilegeBuy: ref(false)
|
||||
}),
|
||||
|
||||
actions: {
|
||||
@@ -73,26 +77,11 @@ export const useAccountStore = defineStore("accountStore", {
|
||||
|
||||
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGINSUCCESSFUL)
|
||||
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 => {
|
||||
if (error.status == 400) {
|
||||
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGINERROR)
|
||||
@@ -170,6 +159,8 @@ export const useAccountStore = defineStore("accountStore", {
|
||||
this.userAccount = new AccountModel()
|
||||
this.userAccountId = -1
|
||||
this.loggedIn = false
|
||||
this.privilegeBuy = false
|
||||
this.adminPanelVisible = false
|
||||
|
||||
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGOUTSUCCESSFUL)
|
||||
},
|
||||
|
||||
@@ -19,10 +19,10 @@ export const useBasketStore = defineStore('basketStore', {
|
||||
itemsInBasket: useLocalStorage<Array<BasketItemModel>>("hackmycart/basketStore/itemsInBasket", []),
|
||||
|
||||
/** Address used in the order dialog */
|
||||
usedAddress: useLocalStorage("hackmycart/basketStore/usedAddress", new AddressModel()),
|
||||
usedAddress: ref(new AddressModel()),
|
||||
|
||||
/** Payment method used in the order dialog */
|
||||
usedPayment: useLocalStorage("hackmycart/basketStore/usedPayment", new PaymentModel()),
|
||||
usedPayment: ref(new PaymentModel()),
|
||||
|
||||
/** Selected seats in the booking page */
|
||||
selectedSeats: ref<Array<SelectedSeatModel>>([])
|
||||
|
||||
@@ -9,6 +9,8 @@ import { BannerStateEnum } from "@/data/enums/bannerStateEnum";
|
||||
import { useFeedbackStore } from "./feedback.store";
|
||||
import { useBasketStore } from "./basket.store";
|
||||
import { useExerciseStore } from "./exercise.store";
|
||||
import { useAccountStore } from "./account.store";
|
||||
import { AccountApiModel } from "@/data/models/user/accountApiModel";
|
||||
|
||||
export const usePreferencesStore = defineStore('preferencesStore', {
|
||||
state: () => ({
|
||||
@@ -115,6 +117,7 @@ export const usePreferencesStore = defineStore('preferencesStore', {
|
||||
*/
|
||||
resetToFactorySettings() {
|
||||
const basketStore = useBasketStore()
|
||||
const accountStore = useAccountStore()
|
||||
|
||||
this.firstStartup = true
|
||||
this.studentName = ""
|
||||
@@ -122,6 +125,10 @@ export const usePreferencesStore = defineStore('preferencesStore', {
|
||||
this.theme = "dark"
|
||||
this.language = LanguageEnum.GERMAN
|
||||
basketStore.itemsInBasket = []
|
||||
accountStore.userAccountToken = ""
|
||||
accountStore.userAccount = new AccountApiModel()
|
||||
|
||||
|
||||
|
||||
this.showFactoryResetDialog = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user