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GACLhE,KAAKH,MAAMgD,gBAAgB,yBAA2BmB,OAAGZ,EAAW,CAAEC,UAAW,gBAEjFC,KAAK,MACP5B,EAAcQ,KACblC,KAAKH,MAAMgD,gBAAgB,qCAAsC,eADlEnB,CAEEoB,WAAY,CAACiB,K,EAK2B,IAAvCvC,EAASyC,6BAEVzC,EAASoC,UACTpC,EAASoC,WAAapC,EAASoC,SAAS3B,MAAMiC,GAAW,sBAALA,MAGrDxC,EAAcQ,KAAKlC,KAAKH,MAAMgD,gBAAgB,kDAI5CrB,EAAS2C,0BACZzC,EAAcQ,KACblC,KAAKH,MAAMgD,gBACV,+CACA,qEACA,CACCC,WAAY,CACXtB,EAAS2C,yBAAyBC,oBAAoBC,WACtD7C,EAAS2C,yBAAyBG,cAClC9C,EAAS2C,yBAAyBI,qBAMvC,MAAMjB,EAAOA,CAACkB,EAAoBC,IAAsBD,EAASlB,KAAKmB,GAEhEC,EAAgB,KAEtB,OAAIhD,EAAcuB,OADc,GAG9B,EAAAzD,EAAAa,MAAAb,EAAAmF,SAAA,C,UACErB,EAAK,IAAI5B,EAAckD,MAAM,EAJD,GAI8B,IAAKF,GAE/D1E,KAAKC,MAAM4E,kBACX,EAAArF,EAAAe,KAAC,OAAI,C,SAAE+C,EAAK5B,EAAckD,MAPE,GAO8BF,MAGzD1E,KAAKC,MAAM4E,kBACZ,EAAArF,EAAAe,KAAC,IAAC,CAACuE,KAAK,GAAGxD,QAAStB,KAAK+E,sB,UACxB,EAAAvF,EAAAe,KAACO,EAAAC,aAAY,CACZC,YAAY,uDACZC,YAAY,uBAQXqC,EAAK5B,EAAegD,E,CAG5BK,sBAAyBb,IACxBA,EAAEc,iBACFhF,KAAKiF,SAAS,CAAEJ,iBAAiB,GAAO,E,IAI1CK,GAAeC,8BAAwBC,kBAAQhC,EAAW,GAAnBgC,CAAuB1F,G","sources":["src/SearchWatch/Components/SearchWatchCriteriaSummary.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport { LocationData } from '../../LocationDataProvider/LocationData';\r\nimport { SearchWatchCreationData, SearchWatch } from '../searchWatchState';\r\nimport { ResourceText, IUseResourceTexts, withResourceTextSupport } from '../../Components/ResourceText';\r\nimport { connect } from 'react-redux';\r\nimport { Button } from '@kojamo/lumo-dls';\r\n\r\ninterface SearchWatchCriteriaSummaryParamProps {\r\n\tlocationData: LocationData | undefined;\r\n\tsearchWatch: SearchWatch | SearchWatchCreationData;\r\n\tonStartEdit: () => any;\r\n}\r\n\r\ntype SearchWatchCriteriaSummaryProps = SearchWatchCriteriaSummaryParamProps & IUseResourceTexts;\r\n\r\ninterface SearchWatchCriteriaSummaryState {\r\n\tshowAllCriteria?: boolean;\r\n}\r\n\r\nclass SearchWatchCriteriaSummary extends React.Component<\r\n\tSearchWatchCriteriaSummaryProps,\r\n\tSearchWatchCriteriaSummaryState\r\n> {\r\n\tconstructor(props: SearchWatchCriteriaSummaryProps, context?: any) {\r\n\t\tsuper(props, context);\r\n\t\tthis.state = {};\r\n\t}\r\n\r\n\trender() {\r\n\t\tif (!this.props.searchWatch || !this.props.searchWatch.searchCriteria) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\treturn (\r\n\t\t\t<div className=\"atom-card -noGrid mod-apartmentWatch__filters\">\r\n\t\t\t\t<h4 className=\"mod-apartmentWatch__filtersHeading\">\r\n\t\t\t\t\t<svg\r\n\t\t\t\t\t\tclassName=\"mod-apartmentWatch__filtersIcon\"\r\n\t\t\t\t\t\twidth=\"16\"\r\n\t\t\t\t\t\theight=\"15\"\r\n\t\t\t\t\t\tviewBox=\"0 0 16 15\"\r\n\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<g fillRule=\"evenodd\">\r\n\t\t\t\t\t\t\t<path\r\n\t\t\t\t\t\t\t\td=\"M5.5 6.5a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-1a2 2 0 1 1 0-4 2 2 0 0 1 0 4zM10.5 14.5a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-1a2 2 0 1 1 0-4 2 2 0 0 1 0 4z\"\r\n\t\t\t\t\t\t\t\tfillRule=\"nonzero\"\r\n\t\t\t\t\t\t\t/>\r\n\t\t\t\t\t\t\t<path d=\"M10 3h6v1h-6zM0 3h3v1H0zM13 11h3v1h-3zM0 11h6v1H0z\" />\r\n\t\t\t\t\t\t</g>\r\n\t\t\t\t\t</svg>\r\n\t\t\t\t\t<ResourceText\r\n\t\t\t\t\t\tresourceKey=\"SearchWatchCreate_InitialData_Heading_SearchCriteria\"\r\n\t\t\t\t\t\tdefaultText=\"Hakuehdot\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</h4>\r\n\t\t\t\t<p className=\"mod-apartmentWatch__filtersText\">{this.formatCriteria()}</p>\r\n\t\t\t\t<Button variant=\"text\" onClick={this.props.onStartEdit}>\r\n\t\t\t\t\t<ResourceText\r\n\t\t\t\t\t\tresourceKey=\"SearchWatchCreate_InitialData_SearchCriteria_EditLink\"\r\n\t\t\t\t\t\tdefaultText=\"Muokkaa hakuehtoja ›\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</Button>\r\n\t\t\t</div>\r\n\t\t);\r\n\t}\r\n\r\n\tprivate formatCriteria() {\r\n\t\tif (!this.props.searchWatch || !this.props.searchWatch.searchCriteria) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\tconst criteria = this.props.searchWatch.searchCriteria;\r\n\t\tconst locationData = this.props.locationData!;\r\n\r\n\t\tconst criteriaTerms: string[] = [];\r\n\t\tif (criteria.location) {\r\n\t\t\tif (criteria.location.businessEntityIds) {\r\n\t\t\t\tcriteria.location.businessEntityIds.forEach((id) => {\r\n\t\t\t\t\tconst be = locationData.businessEntities.find((be) => be.id == id);\r\n\t\t\t\t\tif (be) {\r\n\t\t\t\t\t\tcriteriaTerms.push(be.name);\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\tif (criteria.location.municipalitySubAreas) {\r\n\t\t\t\tcriteria.location.municipalitySubAreas.forEach((sa) => {\r\n\t\t\t\t\tconst mun = locationData.municipalities.find((m) => m.id == sa.municipalityId)!;\r\n\t\t\t\t\tcriteriaTerms.push(sa.name + ', ' + mun.name);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\tif (criteria.location.municipalities) {\r\n\t\t\t\tcriteria.location.municipalities.forEach((mun) => {\r\n\t\t\t\t\tcriteriaTerms.push(mun.name);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\tif (criteria.location.zipCodes) {\r\n\t\t\t\tcriteriaTerms.push(...criteria.location.zipCodes);\r\n\t\t\t}\r\n\t\t\tif (criteria.location.freeLocationTerms) {\r\n\t\t\t\tcriteriaTerms.push(...criteria.location.freeLocationTerms);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (criteria.maxRent) {\r\n\t\t\tcriteriaTerms.push(\r\n\t\t\t\tthis.props.getResourceText('SearchWatchCriteria_RentMax', 'vuokra max {0} €/kk', {\r\n\t\t\t\t\tparameters: [String(criteria.maxRent)],\r\n\t\t\t\t}),\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (criteria.roomCount && criteria.roomCount.length) {\r\n\t\t\tcriteriaTerms.push(\r\n\t\t\t\tthis.props.getResourceText('SearchWatchCriteria_RoomCount', 'asuntotyyppi') +\r\n\t\t\t\t\t': ' +\r\n\t\t\t\t\tcriteria.roomCount\r\n\t\t\t\t\t\t.map((rc) =>\r\n\t\t\t\t\t\t\tthis.props.getResourceText('ApartmentSearch_Type_' + rc, undefined, {\r\n\t\t\t\t\t\t\t\ttransform: 'lowercase',\r\n\t\t\t\t\t\t\t}),\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t\t.join('/'),\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (criteria.areaInSqm && (criteria.areaInSqm.min || criteria.areaInSqm.max)) {\r\n\t\t\tconst formatArea = (a: number | undefined) => (!a ? '' : String(a));\r\n\t\t\tcriteriaTerms.push(\r\n\t\t\t\tthis.props.getResourceText('SearchWatchCriteria_AreaInSqm', 'koko {0}-{1} m²', {\r\n\t\t\t\t\tparameters: [formatArea(criteria.areaInSqm.min), formatArea(criteria.areaInSqm.max)],\r\n\t\t\t\t}),\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (criteria.features && criteria.features.length) {\r\n\t\t\tcriteria.features.forEach((f) => {\r\n\t\t\t\tcriteriaTerms.push(\r\n\t\t\t\t\tthis.props.getResourceText('ApartmentFeature_' + f, undefined, { transform: 'lowercase' }),\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t}\r\n\t\tif (criteria.nearbyServices && criteria.nearbyServices.length) {\r\n\t\t\tconst serviceList = criteria.nearbyServices\r\n\t\t\t\t.map((s) =>\r\n\t\t\t\t\tthis.props.getResourceText('NearbyServiceCategory_' + s, undefined, { transform: 'lowercase' }),\r\n\t\t\t\t)\r\n\t\t\t\t.join(', ');\r\n\t\t\tcriteriaTerms.push(\r\n\t\t\t\tthis.props.getResourceText('SearchWatchCriteria_NearbyServices', 'lähellä: {0}', {\r\n\t\t\t\t\tparameters: [serviceList],\r\n\t\t\t\t}),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (criteria.includeFinanciallyLimited === true) {\r\n\t\t\tif (\r\n\t\t\t\t!criteria.features ||\r\n\t\t\t\t(criteria.features && !criteria.features.find((e) => e == 'FinanciallyLimited'))\r\n\t\t\t) {\r\n\t\t\t\t// includeFinanciallyLimited is TRUE also when FinanciallyLimited is set.\r\n\t\t\t\tcriteriaTerms.push(this.props.getResourceText('SearchWatchCriteria_IncludeFinanciallyLimited'));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (criteria.travelTimeSearchCriteria) {\r\n\t\t\tcriteriaTerms.push(\r\n\t\t\t\tthis.props.getResourceText(\r\n\t\t\t\t\t'SearchWatchCriteria_TravelTimeSearchCriteria',\r\n\t\t\t\t\t'Matka-aika: Asunnot, joista on max. {0} min osoitteeseen {1}, {2}.',\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tparameters: [\r\n\t\t\t\t\t\t\tcriteria.travelTimeSearchCriteria.travelTimeInMinutes.toString(),\r\n\t\t\t\t\t\t\tcriteria.travelTimeSearchCriteria.streetAddress,\r\n\t\t\t\t\t\t\tcriteria.travelTimeSearchCriteria.municipalityName,\r\n\t\t\t\t\t\t],\r\n\t\t\t\t\t},\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t}\r\n\t\tconst join = (elements: string[], separator: string) => elements.join(separator);\r\n\r\n\t\tconst termSeparator = '; ';\r\n\t\tconst maxTermsToShowByDefault = 4;\r\n\t\tif (criteriaTerms.length > maxTermsToShowByDefault) {\r\n\t\t\treturn (\r\n\t\t\t\t<>\r\n\t\t\t\t\t{join([...criteriaTerms.slice(0, maxTermsToShowByDefault), ''], termSeparator)}\r\n\r\n\t\t\t\t\t{this.state.showAllCriteria && (\r\n\t\t\t\t\t\t<span>{join(criteriaTerms.slice(maxTermsToShowByDefault), termSeparator)}</span>\r\n\t\t\t\t\t)}\r\n\r\n\t\t\t\t\t{!this.state.showAllCriteria && (\r\n\t\t\t\t\t\t<a href=\"\" onClick={this.showAllSearchCriteria}>\r\n\t\t\t\t\t\t\t<ResourceText\r\n\t\t\t\t\t\t\t\tresourceKey=\"SearchWatchCreate_InitialData_SearchCriteria_ShowAll\"\r\n\t\t\t\t\t\t\t\tdefaultText=\"näytä kaikki…\"\r\n\t\t\t\t\t\t\t/>\r\n\t\t\t\t\t\t</a>\r\n\t\t\t\t\t)}\r\n\t\t\t\t</>\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\treturn join(criteriaTerms, termSeparator);\r\n\t}\r\n\r\n\tshowAllSearchCriteria = (e: React.MouseEvent) => {\r\n\t\te.preventDefault();\r\n\t\tthis.setState({ showAllCriteria: true });\r\n\t};\r\n}\r\n\r\nexport default withResourceTextSupport(connect(undefined, {})(SearchWatchCriteriaSummary));\r\n"],"names":["$ed3kz","parcelRequire","SearchWatchCriteriaSummary","React","constructor","props","context","super","this","state","render","searchWatch","searchCriteria","jsxs","className","jsx","width","height","viewBox","xmlns","fillRule","d","$jjuiK","ResourceText","resourceKey","defaultText","formatCriteria","$icxVu","Button","variant","onClick","onStartEdit","criteria","locationData","criteriaTerms","location","businessEntityIds","forEach","id","be","businessEntities","find","push","name","municipalitySubAreas","sa","mun","municipalities","m","municipalityId","zipCodes","freeLocationTerms","maxRent","getResourceText","parameters","String","roomCount","length","map","rc","undefined","transform","join","areaInSqm","min","max","formatArea","a","features","f","nearbyServices","serviceList","s","includeFinanciallyLimited","e","travelTimeSearchCriteria","travelTimeInMinutes","toString","streetAddress","municipalityName","elements","separator","termSeparator","Fragment","slice","showAllCriteria","href","showAllSearchCriteria","preventDefault","setState","$b0112b226c001976$export$2e2bcd8739ae039","withResourceTextSupport","connect"],"version":3,"file":"SearchWatchCreatePage.c8b0d392.js.map"}