From 14da64ecbe9cf5c1485e7ad9130c92c979a1c051 Mon Sep 17 00:00:00 2001 From: TobiZog Date: Tue, 24 Sep 2024 20:53:46 +0200 Subject: [PATCH] Payments and Addresses add- and removeable --- software/src/data/models/addressModel.ts | 4 +-- software/src/data/stores/accountStore.ts | 14 ++++++++ software/src/locales/de.json | 9 +++-- software/src/locales/en.json | 9 +++-- .../src/pages/accountPage/accountDataCard.vue | 11 +----- .../src/pages/accountPage/addressesCard.vue | 34 ++++++++++++++---- software/src/pages/accountPage/index.vue | 33 +++++++++++++---- .../src/pages/accountPage/paymentsCard.vue | 36 +++++++++++++++---- 8 files changed, 116 insertions(+), 34 deletions(-) diff --git a/software/src/data/models/addressModel.ts b/software/src/data/models/addressModel.ts index 6349eec..0a01ded 100644 --- a/software/src/data/models/addressModel.ts +++ b/software/src/data/models/addressModel.ts @@ -1,6 +1,6 @@ export class AddressModel { street: string = "" - houseNumber: number = 0 - postalCode: number = 0 + houseNumber: number + postalCode: number city: string = "" } \ No newline at end of file diff --git a/software/src/data/stores/accountStore.ts b/software/src/data/stores/accountStore.ts index 47a7fe4..be6897e 100644 --- a/software/src/data/stores/accountStore.ts +++ b/software/src/data/stores/accountStore.ts @@ -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 + ) } } }) \ No newline at end of file diff --git a/software/src/locales/de.json b/software/src/locales/de.json index 98d3e18..b7808d4 100644 --- a/software/src/locales/de.json +++ b/software/src/locales/de.json @@ -68,7 +68,10 @@ "managingAccount": "Account verwalten", "addresses": "Adressen", "payments": "Bezahlarten", - "masterData": "Stammdaten" + "masterData": "Stammdaten", + "noAddresses": "Keine Adressen gefunden", + "noPayments": "Keine Bezahlarten gefunden", + "newPayment": "New Payment" }, "bannerMessages": { "loginSuccessful": "Login erfolgreich!", @@ -122,5 +125,7 @@ "passwordToShort": "Passwort zu kurz", "onlyDigitsAllowed": "Nur Zahlen erlaubt", "noOrders": "Keine Bestellungen gefunden", - "noOrdersText": "Bisher wurden keine Bestellungen von diesem Account getätigt. Gehe zum Warenkorb und bestelle!" + "noOrdersText": "Bisher wurden keine Bestellungen von diesem Account getätigt. Gehe zum Warenkorb und bestelle!", + "add": "Hinzufügen", + "remove": "Entfernen" } diff --git a/software/src/locales/en.json b/software/src/locales/en.json index 08686f0..4a7910f 100644 --- a/software/src/locales/en.json +++ b/software/src/locales/en.json @@ -68,7 +68,10 @@ "managingAccount": "Managing Account", "addresses": "Addresses", "payments": "Payments", - "masterData": "Master data" + "masterData": "Master data", + "noAddresses": "No Addresses found", + "noPayments": "No payments found", + "newPayment": "New Payment" }, "bannerMessages": { "loginSuccessful": "Login erfolgreich!", @@ -122,5 +125,7 @@ "passwordToShort": "Password too short", "onlyDigitsAllowed": "Only digits are allowed", "noOrders": "No orders found", - "noOrdersText": "There are no orders with this account until now. Go to the basket page and order something!" + "noOrdersText": "There are no orders with this account until now. Go to the basket page and order something!", + "add": "Add", + "remove": "Remove" } diff --git a/software/src/pages/accountPage/accountDataCard.vue b/software/src/pages/accountPage/accountDataCard.vue index 6cfb757..9d899ca 100644 --- a/software/src/pages/accountPage/accountDataCard.vue +++ b/software/src/pages/accountPage/accountDataCard.vue @@ -2,6 +2,7 @@ import cardView from '@/components/cardView.vue'; import outlinedButton from '@/components/outlinedButton.vue'; import { useAccountStore } from '@/data/stores/accountStore'; +import { ref } from 'vue'; const accountStore = useAccountStore() @@ -42,15 +43,5 @@ const accountStore = useAccountStore() /> - - \ No newline at end of file diff --git a/software/src/pages/accountPage/addressesCard.vue b/software/src/pages/accountPage/addressesCard.vue index fd4719e..5f0ca7c 100644 --- a/software/src/pages/accountPage/addressesCard.vue +++ b/software/src/pages/accountPage/addressesCard.vue @@ -2,6 +2,7 @@ import cardView from '@/components/cardView.vue'; import { useAccountStore } from '@/data/stores/accountStore'; import outlinedButton from '@/components/outlinedButton.vue'; +import { AddressModel } from '@/data/models/addressModel'; const accountStore = useAccountStore() @@ -11,12 +12,15 @@ const accountStore = useAccountStore() icon="mdi-home" :title="$t('account.addresses')" > - + + + + + diff --git a/software/src/pages/accountPage/index.vue b/software/src/pages/accountPage/index.vue index 5915315..7d87a0d 100644 --- a/software/src/pages/accountPage/index.vue +++ b/software/src/pages/accountPage/index.vue @@ -4,16 +4,23 @@ import accountDataCard from './accountDataCard.vue'; import accountManagingCard from './accountManagingCard.vue'; import addressesCard from './addressesCard.vue'; import paymentsCard from './paymentsCard.vue'; +import { ref } from 'vue'; +import { useAccountStore } from '@/data/stores/accountStore'; + +const accountStore = useAccountStore() +const updateInProgress = ref(false) + +async function updateAccount() { + updateInProgress.value = true + + await accountStore.updateAccount() + + updateInProgress.value = false +} \ No newline at end of file diff --git a/software/src/pages/accountPage/paymentsCard.vue b/software/src/pages/accountPage/paymentsCard.vue index 42cbd1d..656929f 100644 --- a/software/src/pages/accountPage/paymentsCard.vue +++ b/software/src/pages/accountPage/paymentsCard.vue @@ -2,8 +2,10 @@ import cardView from '@/components/cardView.vue'; import { useAccountStore } from '@/data/stores/accountStore'; import outlinedButton from '@/components/outlinedButton.vue'; +import { PaymentModel } from '@/data/models/paymentModel'; const accountStore = useAccountStore() +