Payments and Addresses add- and removeable

This commit is contained in:
2024-09-24 20:53:46 +02:00
parent fd4c1d5a65
commit 3dc4c7af1e
8 changed files with 116 additions and 34 deletions

View File

@@ -1,6 +1,6 @@
export class AddressModel {
street: string = ""
houseNumber: number = 0
postalCode: number = 0
houseNumber: number
postalCode: number
city: string = ""
}

View File

@@ -7,6 +7,8 @@ import { loginAccount, registerAccount, updateAccount } from "../api/accountApi"
import { getUserOrders } from "../api/orderApi";
import { BannerStateEnum } from "../enums/bannerStateEnum";
import { calcPrice } from "@/scripts/productScripts";
import { AddressModel } from "../models/addressModel";
import { PaymentModel } from "../models/paymentModel";
export const useAccountStore = defineStore("accountStore", {
state: () => ({
@@ -89,6 +91,18 @@ export const useAccountStore = defineStore("accountStore", {
}
return Math.round(totalPrice * 100) / 100
},
removeAddress(address: AddressModel) {
this.userAccount.addresses = this.userAccount.addresses.filter((addr: AddressModel) =>
addr != address
)
},
removePayment(payment: PaymentModel) {
this.userAccount.payments = this.userAccount.payments.filter((paym: PaymentModel) =>
paym != payment
)
}
}
})