Payments and Addresses add- and removeable

This commit is contained in:
2024-09-24 20:53:46 +02:00
parent 76c5e953a1
commit 14da64ecbe
8 changed files with 116 additions and 34 deletions

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
)
}
}
})