From c3d0cc287998d4c9f618eb23487579675376c5b5 Mon Sep 17 00:00:00 2001 From: Tobias Zoghaib Date: Mon, 4 Nov 2024 19:05:14 +0100 Subject: [PATCH] Account itself deletable --- software/backend/routes/account.routes.ts | 11 +++++++++++ software/src/data/api/accountApi.ts | 4 ++++ .../account/accountDataPage/accountManagingCard.vue | 2 +- software/src/pages/account/loginPage/loginForm.vue | 1 + .../src/pages/concerts/concertBookingPage/index.vue | 7 +------ software/src/stores/account.store.ts | 13 +++++++++---- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/software/backend/routes/account.routes.ts b/software/backend/routes/account.routes.ts index e703a89..5cab2c6 100644 --- a/software/backend/routes/account.routes.ts +++ b/software/backend/routes/account.routes.ts @@ -139,3 +139,14 @@ account.patch("/", (req: Request, res: Response) => { }) }) }) + +account.delete("/:id", (req: Request, res: Response) => { + Account.destroy({ + where: { + id: req.params.id + } + }) + .then(account => { + res.status(200).send() + }) +}) \ No newline at end of file diff --git a/software/src/data/api/accountApi.ts b/software/src/data/api/accountApi.ts index 2efc97f..9d855e3 100644 --- a/software/src/data/api/accountApi.ts +++ b/software/src/data/api/accountApi.ts @@ -20,4 +20,8 @@ export async function registerAccount(account: AccountModel) { export async function updateAccount(account: AccountModel) { return await axios.patch(BASE_URL, account) +} + +export async function deleteAccount(account: AccountModel) { + return await axios.delete(BASE_URL + "/" + account.id) } \ No newline at end of file diff --git a/software/src/pages/account/accountDataPage/accountManagingCard.vue b/software/src/pages/account/accountDataPage/accountManagingCard.vue index 9a404ea..b48b997 100644 --- a/software/src/pages/account/accountDataPage/accountManagingCard.vue +++ b/software/src/pages/account/accountDataPage/accountManagingCard.vue @@ -43,6 +43,6 @@ const accountStore = useAccountStore() v-model="showConfirmDialog" :title="$t('account.deleteAccount.dialog.title')" :description="$t('account.deleteAccount.dialog.description')" + :on-confirm="() => accountStore.deleteAccount(accountStore.userAccount)" /> - \ No newline at end of file diff --git a/software/src/pages/account/loginPage/loginForm.vue b/software/src/pages/account/loginPage/loginForm.vue index 31304b2..6fdaa26 100644 --- a/software/src/pages/account/loginPage/loginForm.vue +++ b/software/src/pages/account/loginPage/loginForm.vue @@ -60,6 +60,7 @@ async function startLogin() { append-icon="mdi-arrow-right" @click="startLogin" :loading="accountStore.fetchInProgress" + color="green" > {{ $t('account.login.login') }} diff --git a/software/src/pages/concerts/concertBookingPage/index.vue b/software/src/pages/concerts/concertBookingPage/index.vue index 61ae855..860249c 100644 --- a/software/src/pages/concerts/concertBookingPage/index.vue +++ b/software/src/pages/concerts/concertBookingPage/index.vue @@ -38,12 +38,7 @@ concertStore.getConcert(Number(router.currentRoute.value.params.id)) :link="false" :title="concertStore.concert.location.city.name" :show-button="false" - > - - + /> diff --git a/software/src/stores/account.store.ts b/software/src/stores/account.store.ts index d1df021..7dba419 100644 --- a/software/src/stores/account.store.ts +++ b/software/src/stores/account.store.ts @@ -1,9 +1,9 @@ import { useLocalStorage } from "@vueuse/core"; -import { defineStore } from "pinia"; +import { acceptHMRUpdate, defineStore } from "pinia"; import { AccountModel } from "../data/models/user/accountModel"; import { OrderModel } from "../data/models/ordering/orderModel"; import { useFeedbackStore } from "./feedback.store"; -import { fetchAllAccounts, loginAccount, registerAccount, updateAccount } from "../data/api/accountApi"; +import { deleteAccount, fetchAllAccounts, loginAccount, registerAccount, updateAccount } from "../data/api/accountApi"; import { fetchUserOrders } from "../data/api/orderApi"; import { BannerStateEnum } from "../data/enums/bannerStateEnum"; import { AddressModel } from "../data/models/user/addressModel"; @@ -191,8 +191,13 @@ export const useAccountStore = defineStore("accountStore", { // todo }, - async deleteAccount(item: AccountModel) { - // todo + async deleteAccount(account: AccountModel) { + this.fetchInProgress = true + + deleteAccount(account) + .then(response => { + this.fetchInProgress = false + }) } } }) \ No newline at end of file