| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- import { AnyJson, organizationState, OrganizationStore } from '~/types/interfaces'
- /**
- * L'OrganizationProfile permet de manipuler l'OrganizationState auquel
- * l'access courant est connecté et qui peuvent être nécessaires pour l'affichage
- * de chacune des pages de l'application
- * (ex: modules, produit, ...etc)
- */
- class OrganizationProfile {
- private organizationProfile: organizationState
- /**
- * @constructor
- * @param {OrganizationStore} store State organization du store contenant les informations de l'organisation
- */
- constructor (store: OrganizationStore) {
- this.organizationProfile = store.state.profile.organization
- }
- /**
- * Est-ce que l'organisation possède le module donné
- *
- * @param {Array<string>} modules Modules à tester
- * @return {boolean}
- */
- hasModule (modules: Array<string>): boolean {
- let hasModule = false
- modules.map((module) => {
- if (this.organizationProfile.modules && this.organizationProfile.modules.includes(module)) { hasModule = true }
- })
- return hasModule
- }
- /**
- * L'organization fait-elle partie d'un réseau ?
- *
- * @return {boolean}
- */
- isInsideNetwork (): boolean {
- return this.isCmf() || this.isFfec()
- }
- /**
- * L'organization fait-elle partie du réseau CMF?
- *
- * @return {boolean}
- */
- isCmf (): boolean {
- return this.organizationProfile.networks.filter((network: string) => {
- return network === process.env.cmf_network
- }).length > 0
- }
- /**
- * L'organization fait-elle partie du réseau FFEC?
- *
- * @return {boolean}
- */
- isFfec (): boolean {
- return this.organizationProfile.networks.filter((network: string) => {
- return network === process.env.ffec_network
- }).length > 0
- }
- /**
- * L'organization possède t'elle un produit premium
- * @return {boolean}
- */
- isArtistProduct (): boolean {
- return this.organizationProfile.product === process.env.artist_product
- }
- /**
- * L'organization possède t'elle un produit artiste premium
- * @return {boolean}
- */
- isArtistPremiumProduct (): boolean {
- return this.organizationProfile.product === process.env.artist_premium_product
- }
- /**
- * L'organization possède-t-elle un produit school?
- *
- * @return {boolean}
- */
- isSchoolProduct (): boolean {
- return this.organizationProfile.product === process.env.school_product
- }
- /**
- * L'organization possède-t-elle un produit school-premium?
- *
- * @return {boolean}
- */
- isSchoolPremiumProduct (): boolean {
- return this.organizationProfile.product === process.env.school_premium_product
- }
- /**
- * L'organization possède-t-elle un produit school ou school-premium
- * @return {boolean}
- */
- isSchool (): boolean {
- return this.isSchoolProduct() || this.isSchoolPremiumProduct()
- }
- /**
- * L'organization possède t'elle un produit artiste ou artiste premium
- * @return {boolean}
- */
- isArtist (): boolean {
- return this.isArtistProduct() || this.isArtistPremiumProduct()
- }
- /**
- * L'organization possède t'elle un produit manager
- * @return {boolean}
- */
- isManagerProduct (): boolean {
- return this.organizationProfile.product === process.env.manager_product
- }
- /**
- * L'organization possède t-elle des enfants
- * @return {boolean|null}
- */
- hasChildren (): any {
- return this.organizationProfile.hasChildren
- }
- /**
- * L'organization peut elle afficher la lister des adhérents avec leurs coordonnées
- * @return {boolean|null}
- */
- isShowAdherentList():any{
- return this.organizationProfile.showAdherentList;
- }
- /**
- * L'organization est elle une association ?
- * @return {boolean|null}
- */
- isAssociation():any{
- return this.organizationProfile.legalStatus === 'ASSOCIATION_LAW_1901';
- }
- /**
- * Factory
- *
- * @return {AnyJson} retourne les fonction rendues publiques
- */
- handler (): AnyJson {
- return {
- hasModule: this.hasModule.bind(this),
- isSchool: this.isSchool.bind(this),
- isArtist: this.isArtist.bind(this),
- isManagerProduct: this.isManagerProduct.bind(this),
- isOrganizationWithChildren: this.hasChildren.bind(this),
- isAssociation: this.isAssociation.bind(this),
- isShowAdherentList: this.isShowAdherentList.bind(this),
- isCmf: this.isCmf.bind(this)
- }
- }
- }
- export const $organizationProfile = (store:OrganizationStore) => new OrganizationProfile(store)
|