{ "version": 3, "sources": ["../javascripts/routes/customer-service/faq.tsx", "../javascripts/routes/customer-service/Data/useCurrentCategory.ts"], "sourcesContent": ["import React, { useEffect, useMemo } from 'react';\nimport { Trans, useTranslation } from 'react-i18next';\nimport { useLocation, useNavigate, useParams } from 'react-router-dom';\n\nimport useIsErrorPage from '../../hooks/useIsErrorPage';\nimport { resetViewport } from '../../utils/ts/viewport';\nimport ErrorView from '../error';\nimport useCurrentCategory from './Data/useCurrentCategory';\nimport useFaqCategories from './Data/useFaqCategories';\nimport useFaqs from './Data/useFaqs';\nimport { getFaqsURLSearchParams } from './utils';\n\nimport { asHtml } from '../../helpers/markdown';\nimport { createPageTitle } from '../../helpers/text';\nimport useTrackPageView from '../../hooks/useTrackPageView';\nimport { getMarket } from '../../i18n';\nimport SchemaFaqPage from '../../structured-data/SchemaFaqPage';\nimport Alert from '../../styled-components/components/Alert';\nimport { Breadcrumb, Breadcrumbs } from '../../styled-components/components/Breadcrumbs';\nimport { RouterLink } from '../../styled-components/components/Link';\nimport Loader from '../../styled-components/components/Loader';\n\nconst resolveCustomerServiceRoute = () => {\n const { marketCode } = getMarket();\n switch (marketCode) {\n case 'NO':\n return '/kundeservice';\n default:\n return '/kundservice';\n }\n};\n\nconst Faq = () => {\n const urlParams = useParams();\n const slug = urlParams.slug;\n\n const { t } = useTranslation(['customerService', 'global', 'validation']);\n const isErrorPage = useIsErrorPage();\n if (isErrorPage) return ;\n\n const { search } = useLocation();\n const navigate = useNavigate();\n const [categories, requestCategories] = useFaqCategories();\n const currentCategory = useCurrentCategory(categories);\n\n const urlSearchParams = useMemo(\n () => getFaqsURLSearchParams(currentCategory, search),\n [currentCategory, search],\n );\n\n const [faqs, request, setSearchParams, currentSearchParams] = useFaqs(urlSearchParams);\n const faq = useMemo(\n () => faqs?.response.documentList.documents.find((document) => document.slug === slug),\n [faqs, slug],\n );\n\n const trackPageViewEvent = useTrackPageView();\n\n useEffect(() => {\n resetViewport();\n }, [navigate]);\n\n useEffect(() => {\n trackPageViewEvent();\n }, [currentCategory]);\n\n useEffect(() => {\n const title: string[] = [];\n\n if (currentCategory?.name) {\n title.push(currentCategory.name);\n }\n title.push(t('customerService', { ns: 'customerService' }));\n\n document.title = createPageTitle(title.join(' | '));\n\n if (currentSearchParams.toString().localeCompare(urlSearchParams.toString()) !== 0) {\n setSearchParams(urlSearchParams);\n resetViewport();\n }\n }, [urlSearchParams]);\n\n return (\n <>\n
\n {requestCategories.isLoading ? (\n \n ) : (\n
\n \n
\n {currentCategory && (\n <>\n
\n
\n \n \n \n {t('customerService', { ns: 'customerService' })}\n \n \n {slug && faq ? (\n <>\n \n \n {currentCategory.name}\n \n \n \n {faq.question.length > 30\n ? `${faq.question.slice(0, 30)}...`\n : faq.question}\n \n \n ) : (\n {currentCategory.name}\n )}\n \n
\n {!slug ? (\n <>\n

{currentCategory.name}

\n {currentCategory.description && (\n
\n

{currentCategory.description}

\n
\n )}\n \n ) : request.isLoading ? (\n \n ) : request.isError ? (\n {t('unknownError', { ns: 'validation' })}\n ) : (\n request.isSuccess &&\n (!faq ? (\n \n {t('couldNotFindQuestion', { ns: 'customerService' })}\n \n ) : (\n <>\n

{faq.question}

\n \n \n ))\n )}\n
\n {!slug && (\n
\n {request.isLoading ? (\n \n ) : request.isError ? (\n {t('unknownError', { ns: 'validation' })}\n ) : (\n request.isSuccess &&\n (!faqs?.response.documentList.documents.length ? (\n \n {t('noQuestionsToDisplay', { ns: 'customerService' })}\n \n ) : (\n faqs?.response.documentList.documents\n .sort((a, b) => a.sortOrder - b.sortOrder)\n .map((document) => (\n
\n \n {document.question}\n \n
\n ))\n ))\n )}\n
\n )}\n
\n
\n
\n

\n {t('cantFindTheAnswerYouAreLookingFor', { ns: 'customerService' })}\n

\n
\n \n {' '}\n ,\n ]}\n />\n
\n
\n
\n \n )}\n
\n
\n )}\n
\n {!!faqs?.response?.documentList?.documents?.length && !slug && (\n ({\n question: document.question,\n answer: document.answer,\n }))}\n />\n )}\n \n );\n};\n\nexport default Faq;\n", "import { useLocation } from 'react-router-dom';\nimport type { FaqCategory } from '../../../@types/FaqCategory';\nimport { getCategory } from '../utils';\n\nconst useCurrentCategory = (categories: FaqCategory[] | undefined) => {\n const { pathname } = useLocation();\n return getCategory(categories, pathname);\n};\n\nexport default useCurrentCategory;\n"], "mappings": "uvDAAA,IAAAA,EAA0C,SCI1C,IAAMC,EAAsBC,GAA0C,CACpE,GAAM,CAAE,SAAAC,CAAS,EAAIC,EAAY,EACjC,OAAOC,EAAYH,EAAYC,CAAQ,CACzC,EAEOG,EAAQL,EDaf,IAAMM,EAA8B,IAAM,CACxC,GAAM,CAAE,WAAAC,CAAW,EAAIC,EAAU,EACjC,OAAQD,EAAY,CAClB,IAAK,KACH,MAAO,gBACT,QACE,MAAO,cACX,CACF,EAEME,EAAM,IAAM,CAEhB,IAAMC,EADYC,EAAU,EACL,KAEjB,CAAE,EAAAC,CAAE,EAAIC,EAAe,CAAC,kBAAmB,SAAU,YAAY,CAAC,EAExE,GADoBC,EAAe,EAClB,OAAO,EAAAC,QAAA,cAACC,EAAA,IAAU,EAEnC,GAAM,CAAE,OAAAC,CAAO,EAAIC,EAAY,EACzBC,EAAWC,EAAY,EACvB,CAACC,EAAYC,CAAiB,EAAIC,EAAiB,EACnDC,EAAkBC,EAAmBJ,CAAU,EAE/CK,KAAkB,WACtB,IAAMC,EAAuBH,EAAiBP,CAAM,EACpD,CAACO,EAAiBP,CAAM,CAC1B,EAEM,CAACW,EAAMC,EAASC,EAAiBC,CAAmB,EAAIC,EAAQN,CAAe,EAC/EO,KAAM,WACV,IAAML,GAAM,SAAS,aAAa,UAAU,KAAMM,GAAaA,EAAS,OAASxB,CAAI,EACrF,CAACkB,EAAMlB,CAAI,CACb,EAEMyB,EAAqBC,EAAiB,EAE5C,sBAAU,IAAM,CACdC,EAAc,CAChB,EAAG,CAAClB,CAAQ,CAAC,KAEb,aAAU,IAAM,CACdgB,EAAmB,CACrB,EAAG,CAACX,CAAe,CAAC,KAEpB,aA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,QAAA,cAAC,MAAG,UAAU,eACXH,EAAE,oCAAqC,CAAE,GAAI,iBAAkB,CAAC,CACnE,EACA,EAAAG,QAAA,cAAC,WACC,EAAAA,QAAA,cAACkC,EAAA,CACC,QAAQ,mCACR,OAAQ,CACN,aAAcrC,EAAE,YAAa,CAAE,GAAI,QAAS,CAAC,CAC/C,EACA,WAAY,CACV,EAAAG,QAAA,cAAC,KACC,IAAI,aACJ,KAAM,UAAUH,EAAE,YAAa,CAAE,GAAI,QAAS,CAAC,CAAC,GAChD,MACEA,EAAE,4BAA6B,CAC7B,GAAI,iBACN,CAAC,GAAK,GAER,eAAa,IAEZ,GACH,CACF,EACF,CACF,CACF,CACF,CACF,CAEJ,CACF,CAEJ,EACC,CAAC,CAACgB,GAAM,UAAU,cAAc,WAAW,QAAU,CAAClB,GACrD,EAAAK,QAAA,cAACmC,EAAA,CACC,UAAWtB,GAAM,SAAS,aAAa,UAAU,IAAKM,IAAc,CAClE,SAAUA,EAAS,SACnB,OAAQA,EAAS,MACnB,EAAE,EACJ,CAEJ,CAEJ,EAEOiB,GAAQ1C", "names": ["import_react", "useCurrentCategory", "categories", "pathname", "useLocation", "getCategory", "useCurrentCategory_default", "resolveCustomerServiceRoute", "marketCode", "getMarket", "Faq", "slug", "useParams", "t", "useTranslation", "useIsErrorPage_default", "React", "error_default", "search", "useLocation", "navigate", "useNavigate", "categories", "requestCategories", "useFaqCategories_default", "currentCategory", "useCurrentCategory_default", "urlSearchParams", "getFaqsURLSearchParams", "faqs", "request", "setSearchParams", "currentSearchParams", "useFaqs_default", "faq", "document", "trackPageViewEvent", "useTrackPageView_default", "resetViewport", "title", "createPageTitle", "Loader_default", "category", "RouterLink", "Breadcrumbs", "Breadcrumb", "Alert_default", "asHtml", "a", "b", "Trans", "SchemaFaqPage_default", "faq_default"] }