organization.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { baseOrganizationState, organizationState } from '~/types/interfaces'
  2. import {defineStore} from "pinia";
  3. export const useProfileOrganizationStore = defineStore('profileOrganization', {
  4. state: (): organizationState => {
  5. return {
  6. id: null,
  7. parametersId: null,
  8. name: null,
  9. product: null,
  10. currentActivityYear: null,
  11. modules: [],
  12. hasChildren: false,
  13. legalStatus: null,
  14. showAdherentList: false,
  15. networks: [],
  16. website: null,
  17. parents: []
  18. }
  19. },
  20. actions : {
  21. setProfile (profile: any) {
  22. this.id = profile.id
  23. this.parametersId = profile.parametersId
  24. this.name = profile.name
  25. this.product = profile.product
  26. this.currentActivityYear = profile.currentYear
  27. this.website = profile.website
  28. this.modules = profile.modules
  29. this.hasChildren = profile.hasChildren
  30. this.legalStatus = profile.legalStatus
  31. this.showAdherentList = profile.showAdherentList
  32. this.networks = profile.networks
  33. useEach(profile.parents, (parent) => {
  34. const p: baseOrganizationState = {
  35. id: parent.id,
  36. name: parent.name,
  37. website: parent.website
  38. }
  39. this.parents.push(p)
  40. })
  41. },
  42. refreshProfile (profile: any) {
  43. this.name = profile.name
  44. this.currentActivityYear = profile.currentYear
  45. this.website = profile.website
  46. this.legalStatus = profile.legalStatus
  47. }
  48. }
  49. })