opnform/client/pages/settings/account.vue

46 lines
1.1 KiB
Vue
Raw Normal View History

2023-12-09 14:47:03 +00:00
<template>
<div>
<h3 class="font-semibold text-2xl text-gray-900">Danger zone</h3>
<p class="text-gray-600 text-sm mt-2">
This will permanently delete your entire account. All your forms, submissions and workspaces will be deleted.
<span class="text-red-500">
This cannot be undone.
</span>
</p>
<!-- Submit Button -->
<v-button :loading="loading" class="mt-4" color="red" @click="useAlert().confirm('Do you really want to delete your account?',deleteAccount)">
2023-12-09 14:47:03 +00:00
Delete account
</v-button>
</div>
</template>
<script setup>
import { useRouter } from 'vue-router';
2023-12-09 14:47:03 +00:00
const router = useRouter()
const authStore = useAuthStore()
let loading = false
2023-12-09 14:47:03 +00:00
useOpnSeoMeta({
title: 'Account'
})
definePageMeta({
middleware: "auth"
})
const deleteAccount = () => {
loading = true
opnFetch('/user', {method:'DELETE'}).then(async (data) => {
loading = false
useAlert().success(data.message)
authStore.logout()
router.push({ name: 'login' })
}).catch((error) => {
useAlert().error(error.data.message)
loading = false
})
2023-12-09 14:47:03 +00:00
}
</script>