{"version":3,"file":"LocalesDropdown-2e8e105e.js","sources":["../../../app/javascript/components_contributor/molecules/LocalesDropdown.tsx"],"sourcesContent":["import React from 'react'\nimport { useLocation } from '@reach/router'\nimport I18n, { useLocale } from 'components/i18n'\nimport { capitalize } from 'lodash'\nimport { Dropdown } from 'react-bootstrap'\nimport useQueryParam from 'shared/hooks/useQueryParam'\nimport classNames from 'classnames'\nimport './LocalesDropdown.scss'\n\ninterface Props {\n reloadPageOnChange?: boolean\n}\n\nexport default function LocalesDropdown({ reloadPageOnChange = false }: Props): JSX.Element {\n const { setLocale } = useLocale()\n const [_, setQueryLocale] = useQueryParam('locale', '')\n const location = useLocation()\n\n const urlForLocale = (locale: string): string => {\n const queryParams = new URLSearchParams(window.location.search)\n queryParams.set('locale', locale)\n return `${location.pathname}?${queryParams.toString()}`\n }\n\n const onClick = (event: React.MouseEvent, locale: string) => {\n if (reloadPageOnChange) return\n\n event.preventDefault()\n setQueryLocale(locale)\n setLocale(locale)\n }\n\n return (\n \n \n \n \"\"\n \n {capitalize(I18n.t(I18n.locale.toUpperCase(), { scope: 'languages' }))}\n \n \n \n \n \n
    \n {I18n.availableLocales.map((locale) => (\n \n onClick(e, locale)}\n >\n \n {capitalize(I18n.t(locale.toUpperCase(), {\n scope: 'languages',\n locale,\n }))}\n \n \n \n ))}\n
\n
\n
\n\n )\n}\n"],"names":["LocalesDropdown","reloadPageOnChange","setLocale","useLocale","_","setQueryLocale","useQueryParam","location","useLocation","urlForLocale","locale","queryParams","onClick","event","React","Dropdown","I18n","capitalize","classNames","e"],"mappings":"kUAaA,SAAwBA,EAAgB,CAAE,mBAAAC,EAAqB,IAA6B,CACpF,KAAA,CAAE,UAAAC,GAAcC,IAChB,CAACC,EAAGC,CAAc,EAAIC,EAAc,SAAU,EAAE,EAChDC,EAAWC,IAEXC,EAAgBC,GAA2B,CAC/C,MAAMC,EAAc,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAClD,OAAAA,EAAA,IAAI,SAAUD,CAA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