| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import {AnyJson, organizationState, OrganizationStore} from "~/types/types";
- /**
- * @category Services/profiles
- * @class OrganizationProfile
- * Classe répondant aux différentes questions que l'on peut se poser sur l'organization de l'access connecté
- */
- 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
- * @param {Array<string>} modules Modules à tester
- * @returns {boolean}
- */
- hasModule(modules:Array<string>) {
- let hasModule = false;
- modules.map((module) => {
- if (this.organizationProfile.modules.indexOf(module) > -1)
- hasModule = true;
- });
- return hasModule;
- }
- /**
- * L'organization possède t'elle un produit school ou school premium
- * @returns {boolean}
- */
- isSchool():boolean {
- return this.isSchoolProduct() || this.isSchoolPremiumProduct();
- }
- /**
- * L'organization possède t'elle un produit artiste ou artiste premium
- * @returns {boolean}
- */
- isArtist():boolean {
- return this.isArtistProduct() || this.isArtistPremiumProduct();
- }
- /**
- * L'organization possède t'elle un produit school
- * @returns {boolean}
- */
- isSchoolProduct() {
- return this.organizationProfile.product === process.env.school_product
- }
- /**
- * L'organization possède t'elle un produit school premium
- * @returns {boolean}
- */
- isSchoolPremiumProduct() {
- return this.organizationProfile.product === process.env.school_premium_product
- }
- /**
- * L'organization possède t'elle un produit premium
- * @returns {boolean}
- */
- isArtistProduct() {
- return this.organizationProfile.product === process.env.artist_product
- }
- /**
- * L'organization possède t'elle un produit artiste premium
- * @returns {boolean}
- */
- isArtistPremiumProduct() {
- return this.organizationProfile.product === process.env.artist_premium_product
- }
- /**
- * L'organization possède t'elle un produit manager
- * @returns {boolean}
- */
- isManagerProduct() {
- return this.organizationProfile.product === process.env.manager_product
- }
- /**
- * L'organization possède t'elledes enfants
- * @returns {boolean}
- */
- isOrganizationWithChildren(){
- return this.organizationProfile.hasChildren;
- }
- /**
- * Factory
- * @returns {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.isOrganizationWithChildren.bind(this)
- }
- }
- }
- export const organizationProfile = (store:OrganizationStore) => new OrganizationProfile(store);
|