|
|
@@ -33,9 +33,10 @@ Bouton Delete avec modale de confirmation de la suppression
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
|
-import { defineComponent, useContext, ref, Ref } from '@nuxtjs/composition-api'
|
|
|
-import { DataDeleterArgs, alert } from '~/types/interfaces'
|
|
|
-import { TYPE_ALERT } from '~/types/enums'
|
|
|
+import {defineComponent, ref, Ref, useContext} from '@nuxtjs/composition-api'
|
|
|
+import {alert, DataDeleterArgs} from '~/types/interfaces'
|
|
|
+import {TYPE_ALERT} from '~/types/enums'
|
|
|
+import Page from "~/services/store/page";
|
|
|
|
|
|
export default defineComponent({
|
|
|
props: {
|
|
|
@@ -47,21 +48,14 @@ export default defineComponent({
|
|
|
setup (props) {
|
|
|
const { $dataDeleter, store, app: { i18n } } = useContext()
|
|
|
const showDialog: Ref<boolean> = ref(false)
|
|
|
+ const page = new Page(store)
|
|
|
|
|
|
const deleteItem = async () => {
|
|
|
try {
|
|
|
await $dataDeleter.invoke(props.deleteArgs)
|
|
|
- const alert: alert = {
|
|
|
- type: TYPE_ALERT.SUCCESS,
|
|
|
- message: i18n.t('deleteSuccess') as string
|
|
|
- }
|
|
|
- store.commit('page/setAlert', alert)
|
|
|
+ page.addAlerts(TYPE_ALERT.SUCCESS, [i18n.t('deleteSuccess') as string])
|
|
|
} catch (error) {
|
|
|
- const alert: alert = {
|
|
|
- type: TYPE_ALERT.ALERT,
|
|
|
- message: error.message
|
|
|
- }
|
|
|
- store.commit('page/setAlert', alert)
|
|
|
+ page.addAlerts(TYPE_ALERT.ALERT, [error.message])
|
|
|
}
|
|
|
showDialog.value = false
|
|
|
}
|