{ "version": 3, "sources": ["../javascripts/components/filters/sort-options-modal.tsx", "../javascripts/components/filters/sort-option.tsx", "../javascripts/components/filters/type-filter-bar.tsx"], "sourcesContent": ["import React, { useEffect, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport type { SortOption } from '../../@types/ElasticSearchResponse';\nimport { Form, FormGroup } from '../../styled-components/components/Form';\nimport Modal from '../../styled-components/components/Modal';\nimport SortOptionComponent from './sort-option';\n\ninterface SortOptionsModalProps {\n sortOptions: SortOption[];\n onClose: () => void;\n onApplySort: (query: string) => void;\n}\n\nconst SortOptionsModal = ({ sortOptions, onClose, onApplySort }: SortOptionsModalProps) => {\n const { t } = useTranslation(['common', 'search']);\n const [options, setOptions] = useState([]);\n\n useEffect(() => {\n if (sortOptions.length) setOptions(sortOptions);\n }, [sortOptions]);\n\n return (\n \n
\n {options.map((sortOption) => (\n \n \n \n ))}\n
\n
\n );\n};\n\nexport default SortOptionsModal;\n", "import React from 'react';\nimport type { SortOption as SortOptionModel } from '../../@types/ElasticSearchResponse';\nimport InputRadio from '../../styled-components/components/InputRadio';\nimport { getOptionDisplayName } from './type-filter-bar';\n\ninterface SortOptionProps {\n sortOption: SortOptionModel;\n disabled?: boolean;\n onClick: (query: string) => void;\n}\n\nconst SortOption = ({ sortOption, disabled, onClick }: SortOptionProps) => (\n onClick(sortOption.query)}\n id={sortOption.query}\n title={getOptionDisplayName(sortOption.displayName)}\n >\n {getOptionDisplayName(sortOption.displayName)}\n \n);\n\nexport default SortOption;\n", "import React, { useMemo, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useSelector } from 'react-redux';\n\nimport i18next from 'i18next';\nimport type { SortOption } from '../../@types/ElasticSearchResponse';\nimport type QueryFilter from '../../helpers/query-filter';\nimport { getMarket } from '../../i18n';\nimport { getQueryFilter } from '../../utils/reselectors';\nimport SortOptionsModal from './sort-options-modal';\n\nexport const getOptionDisplayName = (displayName: string) => {\n switch (displayName) {\n case 'Pris l\u00E4gst':\n return i18next.t('sort.priceAsc', { ns: 'search' });\n case 'Pris h\u00F6gst':\n return i18next.t('sort.priceDesc', { ns: 'search' });\n case '\u00C5rsmodell nyast':\n return i18next.t('sort.modelYearAsc', { ns: 'search' });\n case '\u00C5rsmodell \u00E4ldst':\n return i18next.t('sort.modelYearDesc', { ns: 'search' });\n case 'Miltal l\u00E4gst':\n return i18next.t('sort.mileageAsc', { ns: 'search' });\n case 'Miltal h\u00F6gst':\n return i18next.t('sort.mileageDesc', { ns: 'search' });\n case 'Senaste':\n return i18next.t('sort.latest', { ns: 'search' });\n default:\n return displayName;\n }\n};\n\ninterface TypeFilterBarProps {\n queryFilter?: QueryFilter;\n sortOptions?: SortOption[];\n disableCurrentIndicator?: boolean;\n onApplySort: (query: string) => void;\n onRequestSearch: (queryFilter: QueryFilter) => void;\n}\n\nconst TypeFilterBar = ({\n queryFilter: _queryFilter,\n sortOptions,\n disableCurrentIndicator,\n onApplySort,\n onRequestSearch,\n}: TypeFilterBarProps) => {\n const { t } = useTranslation(['common', 'search']);\n const queryFilter = _queryFilter || useSelector(getQueryFilter);\n\n const [state, setState] = useState({ sortModal: false, subscribeModal: false });\n const onToggleOptions = () => setState({ ...state, sortModal: !state.sortModal });\n\n const marketCode = getMarket().marketCode;\n const showAuction = marketCode === 'SE';\n const showBusinessLeasing = marketCode === 'SE';\n\n const AdTypes = [\n {\n displayName: t('All', { ns: 'common' }),\n isActive: (queryFilter: QueryFilter) =>\n !queryFilter.has('sellerType') &&\n !queryFilter.has('isAuctionItem') &&\n !queryFilter.has('leasing') &&\n !queryFilter.has('businessLeasing'),\n getQueryFilter: (queryFilter: QueryFilter) =>\n queryFilter\n .remove('sellerType')\n .remove('isAuctionItem')\n .remove('businessLeasing')\n .remove('leasing'),\n },\n {\n displayName: t('Private leasing', { ns: 'search' }),\n isActive: (queryFilter: QueryFilter) => queryFilter.contains('leasing', 'true'),\n getQueryFilter: (queryFilter: QueryFilter) =>\n queryFilter\n .remove('sellerType')\n .remove('isAuctionItem')\n .remove('businessLeasing')\n .remove('leasing')\n .add('leasing', 'true'),\n },\n ];\n\n if (showAuction) {\n AdTypes.push({\n displayName: t('Auction', { ns: 'search' }),\n isActive: (queryFilter: QueryFilter) => queryFilter.contains('isAuctionItem', 'true'),\n getQueryFilter: (queryFilter: QueryFilter) => {\n if (queryFilter.has('isAuctionItem')) {\n return queryFilter\n .remove('sellerType')\n .remove('isAuctionItem')\n .remove('leasing')\n .remove('businessLeasing');\n }\n return queryFilter\n .remove('sellerType')\n .remove('leasing')\n .remove('businessLeasing')\n .add('isAuctionItem', 'true');\n },\n });\n }\n\n if (showBusinessLeasing) {\n AdTypes.push({\n displayName: t('Business leasing', { ns: 'search' }),\n isActive: (queryFilter: QueryFilter) => queryFilter.contains('businessLeasing', 'true'),\n getQueryFilter: (queryFilter: QueryFilter) =>\n queryFilter\n .remove('sellerType')\n .remove('isAuctionItem')\n .remove('leasing')\n .remove('businessLeasing')\n .add('businessLeasing', 'true'),\n });\n }\n\n const sortDisplayName = useMemo(() => {\n const activeSortOption = sortOptions?.find((sortOption) => sortOption.selected) || undefined;\n const activeSortOptionDisplayName = getOptionDisplayName(\n activeSortOption?.displayName || t('Sort', { ns: 'common' }),\n );\n\n return activeSortOptionDisplayName;\n }, [sortOptions]);\n\n return (\n
\n {state.sortModal && sortOptions && (\n \n )}\n
\n
\n
\n
\n
\n
    \n {AdTypes.map((adType) => (\n
  • \n onRequestSearch(adType.getQueryFilter(queryFilter))}\n title={adType.displayName}\n >\n {adType.displayName}\n \n
  • \n ))}\n
\n
\n
\n
\n
\n \n
\n \n
\n
{sortDisplayName}
\n \n
\n
\n
\n );\n};\n\nexport default TypeFilterBar;\n"], "mappings": "qWAAA,IAAAA,EAA2C,SCA3C,IAAAC,EAAkB,SCAlB,IAAAC,EAAyC,SAWlC,IAAMC,EAAwBC,GAAwB,CAC3D,OAAQA,EAAa,CACnB,IAAK,gBACH,OAAOC,EAAQ,EAAE,gBAAiB,CAAE,GAAI,QAAS,C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C,CAAU,KAAI,YAAuB,CAAC,CAAC,EAEvD,sBAAU,IAAM,CACVN,EAAY,QAAQM,EAAWN,CAAW,CAChD,EAAG,CAACA,CAAW,CAAC,EAGd,EAAAO,QAAA,cAACC,EAAA,CAAM,QAASL,EAAE,OAAQ,CAAE,GAAI,QAAS,CAAC,EAAG,QAASF,GACpD,EAAAM,QAAA,cAACE,EAAA,KACEJ,EAAQ,IAAKK,GACZ,EAAAH,QAAA,cAACI,EAAA,CAAU,IAAKD,EAAW,OACzB,EAAAH,QAAA,cAACK,EAAA,CACC,WAAYF,EACZ,QAASR,EACT,SAAU,CAACF,EAAY,OACzB,CACF,CACD,CACH,CACF,CAEJ,EAEOa,EAAQd", "names": ["import_react", "import_react", "import_react", "getOptionDisplayName", "displayName", "instance", "TypeFilterBar", "_queryFilter", "sortOptions", "disableCurrentIndicator", "onApplySort", "onRequestSearch", "t", "useTranslation", "queryFilter", "useSelector", "getQueryFilter", "state", "setState", "onToggleOptions", "marketCode", "getMarket", "showAuction", "showBusinessLeasing", "AdTypes", "sortDisplayName", "activeSortOption", "sortOption", "React", "sort_options_modal_default", "adType", "type_filter_bar_default", "SortOption", "sortOption", "disabled", "onClick", "React", "InputRadio_default", "getOptionDisplayName", "sort_option_default", "SortOptionsModal", "sortOptions", "onClose", "onApplySort", "t", "useTranslation", "options", "setOptions", "React", "Modal_default", "Form", "sortOption", "FormGroup", "sort_option_default", "sort_options_modal_default"] }