{"version":3,"file":"propertyGroupStore-Di26e1_7-601d0a.js","sources":["../../ClientSPA/src/stores/propertyGroupStore.ts"],"sourcesContent":["import { defineStore } from 'pinia';\r\nimport { setCssVar } from 'quasar';\r\nimport { Services } from 'src/services/Services';\r\nimport { Api } from 'src/services/api/Api';\r\nimport {\r\n PropertyGroupConfigurationDTO,\r\n PropertyThemeDTO,\r\n PropertyGroupPropertyDTO,\r\n PropertyGroupAreaDTO,\r\n} from 'src/services/api/data-contracts';\r\nimport { IImageData } from 'src/composables/utils';\r\n\r\nimport useUtils from 'src/composables/utils';\r\n\r\nconst propertyGroupApiService = Services.getService(Api);\r\n\r\nexport const usePropertyGroupStore = defineStore('propertyGroupStore', {\r\n state: () => ({\r\n propertyGroupId: undefined as number | undefined,\r\n propertyGroupCode: undefined as string | undefined,\r\n propertyGroupName: undefined as string | undefined,\r\n propertyGroupLogo: undefined as string | undefined,\r\n propertyGroupLogoWidth: '100px' as string,\r\n\r\n websiteUrl: '' as string,\r\n\r\n properties: [] as PropertyGroupPropertyDTO[],\r\n areas: [] as PropertyGroupAreaDTO[],\r\n\r\n propertyGroupImageUrl: null as string,\r\n\r\n theme: undefined as PropertyThemeDTO | undefined,\r\n enableChildrenSearch: true as boolean,\r\n enableInfantSearch: true as boolean,\r\n defaultOccupancyAdult: 1 as number,\r\n defaultOccupancyChildren: 0 as number,\r\n defaultOccupancyInfant: 0 as number,\r\n adultMaximumOccupancy: null as number | null,\r\n childMaximumOccupancy: null as number | null,\r\n\r\n occupancyAdultLabelText: undefined as string | undefined,\r\n occupancyChildrenLabelText: undefined as string | undefined,\r\n occupancyInfantLabelText: undefined as string | undefined,\r\n\r\n hidePromoCodeOnLandingPage: false as boolean,\r\n useAreaSearch: false as boolean,\r\n\r\n config: undefined as PropertyGroupConfigurationDTO | undefined,\r\n }),\r\n getters: {\r\n getConfig(): PropertyGroupConfigurationDTO | undefined {\r\n return this.config;\r\n },\r\n },\r\n actions: {\r\n async getPropertyGroup(propertyGroupCodeOrId) {\r\n const propertyConfigData = await propertyGroupApiService.propertyGroupGet(\r\n propertyGroupCodeOrId,\r\n );\r\n\r\n this.setPropertyGroupData(propertyConfigData.data);\r\n },\r\n async setPropertyGroupData(\r\n propertyConfigData: PropertyGroupConfigurationDTO,\r\n ) {\r\n this.propertyGroupId = propertyConfigData.PropertyGroupId;\r\n this.propertyGroupCode = propertyConfigData.PropertyGroupCode;\r\n this.propertyGroupName = propertyConfigData.PropertyGroupName;\r\n this.propertyGroupLogo = propertyConfigData.LogoFileUrl;\r\n\r\n useUtils()\r\n .getImageDimensions(this.propertyGroupLogo)\r\n .then((imageData: IImageData) => {\r\n if (imageData.ratio > 16 / 9) {\r\n this.propertyGroupLogoWidth = '300px';\r\n }\r\n })\r\n .catch(() => {\r\n // no op if no logo file is found.\r\n });\r\n\r\n this.websiteUrl = propertyConfigData.WebsiteUrl;\r\n this.areas = propertyConfigData.Areas;\r\n this.properties = propertyConfigData.Properties;\r\n\r\n this.hidePromoCodeOnLandingPage =\r\n propertyConfigData.HidePromoCodeOnLandingPage;\r\n\r\n this.useAreaSearch = propertyConfigData.UseAreaSearch;\r\n this.areas = propertyConfigData.Areas;\r\n this.propertyGroupImageUrl = propertyConfigData.PropertyGroupImageUrl;\r\n\r\n this.configureTheme(propertyConfigData.Theme);\r\n },\r\n configureTheme(theme: PropertyThemeDTO) {\r\n this.theme = theme;\r\n const utils = useUtils();\r\n\r\n if (this.theme) {\r\n setCssVar('primary', theme.Primary);\r\n setCssVar('secondary', theme.Secondary);\r\n setCssVar('accent', theme.Accent);\r\n setCssVar('tertiary', theme.Tertiary);\r\n setCssVar('dark', theme.Dark);\r\n setCssVar('dark-page', theme.DarkPage);\r\n setCssVar('positive', theme.Positive);\r\n setCssVar('negative', theme.Negative);\r\n setCssVar('info', theme.Info);\r\n setCssVar('warning', theme.Warning);\r\n\r\n setCssVar('light-page', theme.LightPage);\r\n setCssVar('brand-primary', theme.BrandPrimary);\r\n\r\n if (utils.isLightColor(theme.BrandPrimary)) {\r\n setCssVar('text-on-brand-primary', '#000000');\r\n } else if (!utils.isLightColor(theme.BrandPrimary)) {\r\n setCssVar('text-on-brand-primary', '#FFFFFF');\r\n }\r\n }\r\n },\r\n },\r\n});\r\n"],"names":["propertyGroupApiService","Services","Api","usePropertyGroupStore","defineStore","propertyGroupCodeOrId","propertyConfigData","useUtils","imageData","theme","utils","setCssVar"],"mappings":"6EAcA,MAAMA,EAA0BC,EAAS,WAAWC,CAAG,EAE1CC,EAAwBC,EAAY,qBAAsB,CACrE,MAAO,KAAO,CACZ,gBAAiB,OACjB,kBAAmB,OACnB,kBAAmB,OACnB,kBAAmB,OACnB,uBAAwB,QAExB,WAAY,GAEZ,WAAY,CAAC,EACb,MAAO,CAAC,EAER,sBAAuB,KAEvB,MAAO,OACP,qBAAsB,GACtB,mBAAoB,GACpB,sBAAuB,EACvB,yBAA0B,EAC1B,uBAAwB,EACxB,sBAAuB,KACvB,sBAAuB,KAEvB,wBAAyB,OACzB,2BAA4B,OAC5B,yBAA0B,OAE1B,2BAA4B,GAC5B,cAAe,GAEf,OAAQ,MAAA,GAEV,QAAS,CACP,WAAuD,CACrD,OAAO,KAAK,MACd,CACF,EACA,QAAS,CACP,MAAM,iBAAiBC,EAAuB,CACtC,MAAAC,EAAqB,MAAMN,EAAwB,iBACvDK,CAAA,EAGG,KAAA,qBAAqBC,EAAmB,IAAI,CACnD,EACA,MAAM,qBACJA,EACA,CACA,KAAK,gBAAkBA,EAAmB,gBAC1C,KAAK,kBAAoBA,EAAmB,kBAC5C,KAAK,kBAAoBA,EAAmB,kBAC5C,KAAK,kBAAoBA,EAAmB,YAE5CC,EAAA,EACG,mBAAmB,KAAK,iBAAiB,EACzC,KAAMC,GAA0B,CAC3BA,EAAU,MAAQ,GAAK,IACzB,KAAK,uBAAyB,QAChC,CACD,EACA,MAAM,IAAM,CAAA,CAEZ,EAEH,KAAK,WAAaF,EAAmB,WACrC,KAAK,MAAQA,EAAmB,MAChC,KAAK,WAAaA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