Skip to content

Commit 54c9c3a

Browse files
luizhf42gustavosbarreto
authored andcommitted
refactor(ui): migrate TagRemove to script setup syntax
1 parent 4dddcb1 commit 54c9c3a

File tree

1 file changed

+36
-41
lines changed

1 file changed

+36
-41
lines changed

ui/src/components/Tags/TagRemove.vue

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -39,56 +39,51 @@
3939
</v-dialog>
4040
</template>
4141

42-
<script lang="ts">
43-
import { defineComponent, ref } from "vue";
42+
<script setup lang="ts">
43+
import { ref } from "vue";
4444
import {
4545
INotificationsError,
4646
INotificationsSuccess,
4747
} from "@/interfaces/INotifications";
4848
import { useStore } from "@/store";
4949
import handleError from "@/utils/handleError";
5050
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,
6163
},
62-
emits: ["update"],
63-
inheritAttrs: true,
64-
setup(props, ctx) {
65-
const showDialog = ref(false);
66-
const store = useStore();
64+
});
6765
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();
7169
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);
8773
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+
};
9489
</script>

0 commit comments

Comments
 (0)