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EAAAA,EAAa,CAAAC,UACZR,EAAAA,EAAAA,KAACS,EAAAA,EAAkB,CAACC,UAAU,KAGpC,C","sources":["webpack://checkout/./app/javascript/checkout/components/Information.js"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useNavigate } from \"react-router-dom\";\n// Actions\nimport {\n fetchDataInformation,\n setFieldInformation,\n setFieldShipping,\n} from \"../actions/checkoutStore\";\n\n// Components\nimport { LoadingIcon } from \"./LoadingIcon\";\nimport StepsTemplate from \"../templates/stepsTemplate\";\nimport InformationContent from \"./InformationContent\";\nimport CheckStep from \"../utils/CheckStep\";\n\nexport default function Information() {\n const dispatch = useDispatch();\n const state = useSelector((state) => state);\n const navigate = useNavigate();\n const isFirstRun = useRef(true);\n const mediaWatcher = window.matchMedia(\"(max-width: 992px)\");\n\n function changeStoreInformationField(field, value) {\n dispatch(setFieldInformation(field, value));\n }\n\n function updateMobile(e) {\n changeStoreInformationField(\"is_mobile\", mediaWatcher.matches);\n }\n\n useEffect(() => {\n const queryParams = new URLSearchParams(window.location.search);\n const previewMode = queryParams.get(\"preview_mode\") || \"false\";\n dispatch(fetchDataInformation(previewMode));\n }, []);\n\n useEffect(() => {\n if (\n state.checkoutStore.shipping?.pickup_points &&\n state.checkoutStore.shipping?.pickup_points.length == 1\n ) {\n dispatch(\n setFieldShipping(\n \"pickup_point_id\",\n state.checkoutStore.shipping.pickup_points[0].id,\n ),\n );\n dispatch(\n setFieldShipping(\n \"pickup_point_name\",\n state.checkoutStore.shipping.pickup_points[0].name,\n ),\n );\n }\n }, [state.checkoutStore.shipping?.pickup_points]);\n\n useEffect(() => {\n if (isFirstRun.current) {\n if (mediaWatcher.addEventListener) {\n mediaWatcher.addEventListener(\"change\", updateMobile);\n } else {\n mediaWatcher.addListener(updateMobile);\n }\n\n isFirstRun.current = false;\n return;\n }\n }, [state.checkoutStore.information]);\n\n if (state.ui.isLoading) {\n return ;\n }\n\n const currentUrl = window.location.href;\n const redirectUrl = CheckStep(state, currentUrl);\n if (redirectUrl) navigate(redirectUrl);\n\n return (\n \n \n \n );\n}\n"],"names":["Information","dispatch","useDispatch","state","useSelector","navigate","useNavigate","isFirstRun","useRef","mediaWatcher","window","matchMedia","updateMobile","e","field","value","matches","setFieldInformation","useEffect","previewMode","URLSearchParams","location","search","get","fetchDataInformation","checkoutStore","shipping","pickup_points","length","setFieldShipping","id","name","current","addEventListener","addListener","information","ui","isLoading","_jsx","LoadingIcon","default","currentUrl","href","redirectUrl","CheckStep","StepsTemplate","children","InformationContent","vertical"],"sourceRoot":""}