|
1 | 1 | <template> |
2 | 2 | <Tooltip> |
3 | | - <button |
4 | | - @click="openDialog()" |
5 | | - > |
| 3 | + <button @click="onClick"> |
6 | 4 | <IconUserRemoveSolid class="w-5 h-5 me-2"/> |
7 | 5 | </button> |
8 | | - |
9 | | - <template v-slot:tooltip> |
| 6 | + <template #tooltip> |
10 | 7 | {{ $t('Deactivate user') }} |
11 | 8 | </template> |
12 | 9 | </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> |
26 | 10 | </template> |
27 | 11 |
|
28 | 12 | <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'; |
32 | 15 | import adminforth from "@/adminforth" |
33 | 16 | import { callAdminForthApi } from '@/utils'; |
34 | 17 | import { IconUserRemoveSolid } from '@iconify-prerendered/vue-flowbite'; |
35 | 18 | import { useI18n } from 'vue-i18n'; |
36 | 19 |
|
37 | 20 | const { t } = useI18n(); |
38 | | -const confirmDialog = ref(null); |
39 | 21 |
|
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 | + } |
42 | 31 | } |
43 | 32 |
|
44 | 33 | async function deactivateUser() { |
|
0 commit comments