useTypeOfPractice.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { AnyJson } from '~/types/interfaces'
  2. import {QUERY_TYPE} from "~/types/enums";
  3. import { useContext, useFetch, computed } from '@nuxtjs/composition-api'
  4. import DataProvider from "~/services/data/dataProvider";
  5. import {repositoryHelper} from "~/services/store/repository";
  6. import {TypeOfPractice} from "~/models/Organization/TypeOfPractice";
  7. /**
  8. * @category composables/data
  9. * @class UseTypeOfPractice
  10. * Use Classe qui va récupérer les UseTypeOfPractices
  11. */
  12. export class UseTypeOfPractice {
  13. private $dataProvider!: DataProvider
  14. constructor() {
  15. const {$dataProvider} = useContext()
  16. this.$dataProvider = $dataProvider
  17. }
  18. /**
  19. * Récupération des UseTypeOfPractices via l'API
  20. */
  21. public getAll(): AnyJson{
  22. const {fetch, fetchState} = useFetch(async () => {
  23. await this.$dataProvider.invoke({
  24. type: QUERY_TYPE.MODEL,
  25. model: TypeOfPractice
  26. })
  27. })
  28. const typeOfPractices = computed(() => {
  29. return repositoryHelper.findCollectionFromModel(TypeOfPractice)
  30. })
  31. return {
  32. typeOfPractices,
  33. fetch,
  34. fetchState
  35. }
  36. }
  37. }