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 -->
|
2024-01-02 12:09:41 +00:00
|
|
|
<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>
|
|
|
|
|
2024-01-02 12:09:41 +00:00
|
|
|
<script setup>
|
|
|
|
import { useRouter } from 'vue-router';
|
2023-12-09 14:47:03 +00:00
|
|
|
|
2024-01-02 12:09:41 +00:00
|
|
|
const router = useRouter()
|
|
|
|
const authStore = useAuthStore()
|
|
|
|
let loading = false
|
2023-12-09 14:47:03 +00:00
|
|
|
|
2024-01-04 17:38:50 +00:00
|
|
|
useOpnSeoMeta({
|
|
|
|
title: 'Account'
|
|
|
|
})
|
|
|
|
|
2024-01-02 12:09:41 +00:00
|
|
|
const deleteAccount = () => {
|
|
|
|
loading = true
|
|
|
|
opnFetch('/user', {method:'DELETE'}).then(async (data) => {
|
|
|
|
loading = false
|
|
|
|
useAlert().success(data.message)
|
2024-01-04 17:38:50 +00:00
|
|
|
|
2024-01-02 12:09:41 +00:00
|
|
|
// Log out the user.
|
|
|
|
await authStore.logout()
|
2023-12-09 14:47:03 +00:00
|
|
|
|
2024-01-02 12:09:41 +00:00
|
|
|
// Redirect to login.
|
|
|
|
router.push({ name: 'login' })
|
|
|
|
}).catch((error) => {
|
|
|
|
useAlert().error(error.response.data.message)
|
|
|
|
loading = false
|
|
|
|
})
|
2023-12-09 14:47:03 +00:00
|
|
|
}
|
|
|
|
</script>
|