Skip to content

Commit 9b8b92e

Browse files
committed
fix: streamline user deactivation process by removing dialog component
1 parent 4752cc3 commit 9b8b92e

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

custom/DisableButton.vue

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,33 @@
11
<template>
22
<Tooltip>
3-
<button
4-
@click="openDialog()"
5-
>
3+
<button @click="onClick">
64
<IconUserRemoveSolid class="w-5 h-5 me-2"/>
75
</button>
8-
9-
<template v-slot:tooltip>
6+
<template #tooltip>
107
{{ $t('Deactivate user') }}
118
</template>
129
</Tooltip>
13-
<Dialog
14-
ref="confirmDialog"
15-
class="w-96"
16-
:header="t('Deactivate user')"
17-
:buttons="[
18-
{ label: t('Confirm'), onclick: (dialog) => { deactivateUser(); dialog.hide(); } },
19-
{ label: t('Cancel'), onclick: (dialog) => dialog.hide() },
20-
]"
21-
>
22-
<div class="space-y-4">
23-
<p>{{ $t('Are you sure you want to deactivate this user?') }}</p>
24-
</div>
25-
</Dialog>
2610
</template>
2711

2812
<script lang="ts" setup>
29-
import { Dialog, Tooltip } from '@/afcl';
30-
import { ref } from 'vue';
31-
import { AdminUser, type AdminForthResourceCommon } from '@/types';
13+
import { Tooltip } from '@/afcl';
14+
import { type AdminUser, type AdminForthResourceCommon } from '@/types/Common';
3215
import adminforth from "@/adminforth"
3316
import { callAdminForthApi } from '@/utils';
3417
import { IconUserRemoveSolid } from '@iconify-prerendered/vue-flowbite';
3518
import { useI18n } from 'vue-i18n';
3619
3720
const { t } = useI18n();
38-
const confirmDialog = ref(null);
3921
40-
function openDialog() {
41-
confirmDialog.value.open();
22+
async function onClick() {
23+
const confirmed = await adminforth.confirm({
24+
message: t('Are you sure you want to deactivate this user?'),
25+
yes: t('Confirm'),
26+
no: t('Cancel'),
27+
});
28+
if (confirmed) {
29+
await deactivateUser();
30+
}
4231
}
4332
4433
async function deactivateUser() {

0 commit comments

Comments
 (0)