|
|
@@ -29,20 +29,15 @@ Bouton Delete avec modale de confirmation de la suppression
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
+import type { Ref, PropType } from 'vue'
|
|
|
import { TYPE_ALERT } from '~/types/enum/enums'
|
|
|
-import type { Ref } from '@vue/reactivity'
|
|
|
import { useEntityManager } from '~/composables/data/useEntityManager'
|
|
|
import ApiResource from '~/models/ApiResource'
|
|
|
import { usePageStore } from '~/stores/page'
|
|
|
-import ApiModel from '~/models/ApiModel'
|
|
|
|
|
|
const props = defineProps({
|
|
|
- model: {
|
|
|
- type: Function as any as () => typeof ApiModel,
|
|
|
- required: true,
|
|
|
- },
|
|
|
entity: {
|
|
|
- type: Object as () => ApiResource,
|
|
|
+ type: Object as PropType<ApiResource>,
|
|
|
required: true,
|
|
|
},
|
|
|
flat: {
|
|
|
@@ -58,10 +53,10 @@ const { em } = useEntityManager()
|
|
|
|
|
|
const deleteItem = async () => {
|
|
|
try {
|
|
|
- //@ts-ignore
|
|
|
- await em.delete(props.model, props.entity)
|
|
|
+ await em.delete(props.entity)
|
|
|
usePageStore().addAlert(TYPE_ALERT.SUCCESS, ['deleteSuccess'])
|
|
|
- } catch (error: any) {
|
|
|
+ } catch (error) {
|
|
|
+ // @ts-expect-error error is supposed to have a message prop
|
|
|
usePageStore().addAlert(TYPE_ALERT.ALERT, [error.message])
|
|
|
throw error
|
|
|
}
|