Skip to content

Commit 74fe38b

Browse files
luizhf42gustavosbarreto
authored andcommitted
refactor(ui): migrate SessionDelete to script setup syntax
1 parent 2cd444c commit 74fe38b

File tree

1 file changed

+36
-43
lines changed

1 file changed

+36
-43
lines changed

ui/src/components/Sessions/SessionDelete.vue

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -46,57 +46,50 @@
4646
</div>
4747
</template>
4848

49-
<script lang="ts">
50-
import { defineComponent, ref } from "vue";
49+
<script setup lang="ts">
50+
import { ref } from "vue";
5151
import {
5252
INotificationsError,
5353
INotificationsSuccess,
5454
} from "@/interfaces/INotifications";
5555
import { useStore } from "@/store";
5656
import handleError from "@/utils/handleError";
5757
58-
export default defineComponent({
59-
props: {
60-
uid: {
61-
type: String,
62-
required: true,
63-
},
64-
notHasAuthorization: {
65-
type: Boolean,
66-
default: false,
67-
},
68-
style: {
69-
type: [String, Object],
70-
default: undefined,
71-
},
58+
const props = defineProps({
59+
uid: {
60+
type: String,
61+
required: true,
7262
},
73-
emits: ["update"],
74-
setup(props, ctx) {
75-
const showDialog = ref(false);
76-
const store = useStore();
77-
78-
const deleteRecord = async () => {
79-
try {
80-
await store.dispatch("sessions/deleteSessionLogs", props.uid);
81-
showDialog.value = false;
82-
store.dispatch(
83-
"snackbar/showSnackbarSuccessAction",
84-
INotificationsSuccess.sessionRemoveRecord,
85-
);
86-
ctx.emit("update");
87-
} catch (error: unknown) {
88-
store.dispatch(
89-
"snackbar/showSnackbarErrorAction",
90-
INotificationsError.sessionRemoveRecord,
91-
);
92-
handleError(error);
93-
}
94-
};
95-
96-
return {
97-
showDialog,
98-
deleteRecord,
99-
};
63+
notHasAuthorization: {
64+
type: Boolean,
65+
default: false,
66+
},
67+
style: {
68+
type: [String, Object],
69+
default: undefined,
10070
},
10171
});
72+
73+
const emit = defineEmits(["update"]);
74+
75+
const showDialog = ref(false);
76+
const store = useStore();
77+
78+
const deleteRecord = async () => {
79+
try {
80+
await store.dispatch("sessions/deleteSessionLogs", props.uid);
81+
showDialog.value = false;
82+
store.dispatch(
83+
"snackbar/showSnackbarSuccessAction",
84+
INotificationsSuccess.sessionRemoveRecord,
85+
);
86+
emit("update");
87+
} catch (error: unknown) {
88+
store.dispatch(
89+
"snackbar/showSnackbarErrorAction",
90+
INotificationsError.sessionRemoveRecord,
91+
);
92+
handleError(error);
93+
}
94+
};
10295
</script>

0 commit comments

Comments
 (0)