{"version":3,"file":"roomTypeConfigurationStore-BGPN3fmc-601d0a.js","sources":["../../ClientSPA/src/stores/roomTypeConfigurationStore.ts"],"sourcesContent":["import { defineStore } from 'pinia';\r\nimport { Services } from 'src/services/Services';\r\nimport { Api } from 'src/services/api/Api';\r\nimport { usePropertyStore } from 'src/stores/propertyStore';\r\nimport {\r\n RoomTypeConfigurationGroupDTO,\r\n ApiDropdown,\r\n} from 'src/services/api/data-contracts';\r\n\r\nconst apiService = Services.getService(Api);\r\n\r\nexport const useRoomTypeConfigurationStore = defineStore(\r\n 'roomTypeConfigurationStore',\r\n {\r\n state: () => ({\r\n roomTypeConfigurationCache: [] as RoomTypeConfigurationGroupDTO[],\r\n }),\r\n getters: {},\r\n actions: {\r\n getRoomTypeConfigurationsForRoomType(roomTypeId: number): ApiDropdown[] {\r\n const roomType = this.roomTypeConfigurationCache.filter((rt) => {\r\n return rt.RoomTypeId == roomTypeId;\r\n });\r\n if (roomType != null && roomType.length > 0) {\r\n return roomType[0].Configurations.map((c) => {\r\n return {\r\n Id: c.RoomTypeConfigurationId,\r\n Text: c.RoomTypeConfiguration,\r\n } as ApiDropdown;\r\n });\r\n }\r\n return [];\r\n },\r\n getRoomTypeConfigurationCache() {\r\n const propertyStore = usePropertyStore();\r\n const propertyId = propertyStore.propertyId;\r\n\r\n if (propertyId) {\r\n const query = {\r\n propertyId: propertyId,\r\n languageCode: 'en',\r\n };\r\n\r\n const cachePromise = apiService.roomTypeConfigurationGet(query);\r\n cachePromise.then((cacheResponse) => {\r\n this.roomTypeConfigurationCache = cacheResponse.data.map((t) => {\r\n return t;\r\n });\r\n });\r\n }\r\n },\r\n },\r\n },\r\n);\r\n"],"names":["apiService","Services","Api","useRoomTypeConfigurationStore","defineStore","roomTypeId","roomType","rt","c","propertyId","usePropertyStore","query","cacheResponse","t"],"mappings":"qEASA,MAAMA,EAAaC,EAAS,WAAWC,CAAG,EAE7BC,EAAgCC,EAC3C,6BACA,CACE,MAAO,KAAO,CACZ,2BAA4B,CAAC,CAAA,GAE/B,QAAS,CAAC,EACV,QAAS,CACP,qCAAqCC,EAAmC,CACtE,MAAMC,EAAW,KAAK,2BAA2B,OAAQC,GAChDA,EAAG,YAAcF,CACzB,EACD,OAAIC,GAAY,MAAQA,EAAS,OAAS,EACjCA,EAAS,CAAC,EAAE,eAAe,IAAKE,IAC9B,CACL,GAAIA,EAAE,wBACN,KAAMA,EAAE,qBAAA,EAEX,EAEI,EACT,EACA,+BAAgC,CAE9B,MAAMC,EADgBC,IACW,WAEjC,GAAID,EAAY,CACd,MAAME,EAAQ,CACZ,WAAAF,EACA,aAAc,IAAA,EAGKT,EAAW,yBAAyBW,CAAK,EACjD,KAAMC,GAAkB,CACnC,KAAK,2BAA6BA,EAAc,KAAK,IAAKC,GACjDA,CACR,CAAA,CACF,CACH,CACF,CACF,CACF,CACF"}