|
39 | 39 | </v-dialog> |
40 | 40 | </template> |
41 | 41 |
|
42 | | -<script lang="ts"> |
43 | | -import { defineComponent, ref } from "vue"; |
| 42 | +<script setup lang="ts"> |
| 43 | +import { ref } from "vue"; |
44 | 44 | import { |
45 | 45 | INotificationsError, |
46 | 46 | INotificationsSuccess, |
47 | 47 | } from "@/interfaces/INotifications"; |
48 | 48 | import { useStore } from "@/store"; |
49 | 49 | import handleError from "@/utils/handleError"; |
50 | 50 |
|
51 | | -export default defineComponent({ |
52 | | - props: { |
53 | | - tag: { |
54 | | - type: String, |
55 | | - required: true, |
56 | | - }, |
57 | | - notHasAuthorization: { |
58 | | - type: Boolean, |
59 | | - required: true, |
60 | | - }, |
| 51 | +defineOptions({ |
| 52 | + inheritAttrs: false, |
| 53 | +}); |
| 54 | +
|
| 55 | +const props = defineProps({ |
| 56 | + tag: { |
| 57 | + type: String, |
| 58 | + required: true, |
| 59 | + }, |
| 60 | + notHasAuthorization: { |
| 61 | + type: Boolean, |
| 62 | + required: true, |
61 | 63 | }, |
62 | | - emits: ["update"], |
63 | | - inheritAttrs: true, |
64 | | - setup(props, ctx) { |
65 | | - const showDialog = ref(false); |
66 | | - const store = useStore(); |
| 64 | +}); |
67 | 65 |
|
68 | | - const remove = async () => { |
69 | | - try { |
70 | | - await store.dispatch("tags/remove", props.tag); |
| 66 | +const emit = defineEmits(["update"]); |
| 67 | +const showDialog = ref(false); |
| 68 | +const store = useStore(); |
71 | 69 |
|
72 | | - store.dispatch( |
73 | | - "snackbar/showSnackbarSuccessAction", |
74 | | - INotificationsSuccess.deviceTagDelete, |
75 | | - ); |
76 | | - ctx.emit("update"); |
77 | | - } catch (error: unknown) { |
78 | | - store.dispatch( |
79 | | - "snackbar/showSnackbarErrorAction", |
80 | | - INotificationsError.deviceTagDelete, |
81 | | - ); |
82 | | - handleError(error); |
83 | | - } finally { |
84 | | - showDialog.value = false; |
85 | | - } |
86 | | - }; |
| 70 | +const remove = async () => { |
| 71 | + try { |
| 72 | + await store.dispatch("tags/remove", props.tag); |
87 | 73 |
|
88 | | - return { |
89 | | - showDialog, |
90 | | - remove, |
91 | | - }; |
92 | | - }, |
93 | | -}); |
| 74 | + store.dispatch( |
| 75 | + "snackbar/showSnackbarSuccessAction", |
| 76 | + INotificationsSuccess.deviceTagDelete, |
| 77 | + ); |
| 78 | + emit("update"); |
| 79 | + } catch (error: unknown) { |
| 80 | + store.dispatch( |
| 81 | + "snackbar/showSnackbarErrorAction", |
| 82 | + INotificationsError.deviceTagDelete, |
| 83 | + ); |
| 84 | + handleError(error); |
| 85 | + } finally { |
| 86 | + showDialog.value = false; |
| 87 | + } |
| 88 | +}; |
94 | 89 | </script> |
0 commit comments