Account itself deletable

This commit is contained in:
2024-11-04 19:05:14 +01:00
parent ffccd9f2d4
commit c3d0cc2879
6 changed files with 27 additions and 11 deletions

View File

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

View File

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

View File

@@ -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)"
/>
<!-- todo :onConfirm="deleteAccount" -->
</template>

View File

@@ -60,6 +60,7 @@ async function startLogin() {
append-icon="mdi-arrow-right"
@click="startLogin"
:loading="accountStore.fetchInProgress"
color="green"
>
{{ $t('account.login.login') }}
</outlined-button>

View File

@@ -38,12 +38,7 @@ concertStore.getConcert(Number(router.currentRoute.value.params.id))
:link="false"
:title="concertStore.concert.location.city.name"
:show-button="false"
>
<template #description>
<p>{{ concertStore.concert.location.name }}</p>
<!-- todo <p>{{ concertModel.event.band.name }} - {{ concertModel.event.name }}</p> -->
</template>
</concert-list-item>
/>
</v-col>
</v-row>
<v-row>

View File

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