{"version":3,"file":"index-BIbCOafI.js","sources":["../../../app/javascript/src/explore/scenes/OrderStatus/elements/LogIn/index.tsx","../../../app/javascript/src/explore/scenes/OrderStatus/index.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useDispatch, useSelector } from 'react-redux';\n\nimport { open, switchMode } from 'src/explore/compositions/Auth/actions';\nimport { useRoutes } from 'src/explore/hooks/useRoutes';\n\nimport styles from './index.module.sass';\n\nexport const LogIn: React.FC = () => {\n const account = useSelector(( state: any ) => state.data.account );\n const dispatch = useDispatch();\n\n const routes = useRoutes();\n\n const handleClick = () => {\n if ( account.data ) {\n location.href = routes.account.orders();\n } else {\n dispatch( switchMode( 'login' ));\n dispatch( open( routes.account.orders()));\n }\n };\n\n return (\n <p>\n {'Already have a Goldbelly Account? '}\n <a className={`${styles.link} spec__account-orders-log-in`} onClick={handleClick}>\n Log In\n </a>\n </p>\n );\n};\n","import * as React from 'react';\nimport { useFormState } from 'react-use-form-state';\n\nimport api from 'src/explore/services/api';\nimport { ErrorBox } from 'src/explore/elements/bs4/ErrorBox';\nimport { FormStateInput } from 'src/explore/elements/FormStateInput';\nimport { LoadingButton } from 'src/shoppe/elements/LoadingButton';\nimport { useRoutes } from 'src/explore/hooks/useRoutes';\n\nimport { LogIn } from './elements/LogIn';\n\nimport styles from './index.module.sass';\n\ntype IOrderStatusField = {\n id: number;\n email: string;\n};\n\nconst OrderStatus: React.FC = () => {\n const routes = useRoutes();\n\n const [ error, setError ] = React.useState<string[] | null>( null );\n const [ loading, setLoading ] = React.useState<boolean>( false );\n\n const [ formState, { number, email }] = useFormState<IOrderStatusField>();\n\n const handleSubmit = ( event: React.FormEvent ) => {\n event.preventDefault();\n\n setLoading( true );\n setError( null );\n\n const request = api.get( '/orders/lookup', { params: formState.values });\n\n return request\n .then(( response: { data: { slug: string; tracking: string } }) => {\n if ( response.data.tracking ) {\n location.href = routes.suborderTracking( response.data.tracking );\n } else {\n location.href = routes.order( response.data.slug );\n }\n })\n .catch(() => {\n setError([\n 'Your order number and email address do not match any orders. Please try again.',\n ]);\n\n setLoading( false );\n });\n };\n\n return (\n <div className=\"container-xl py-8 py-md-9\">\n <div className=\"row pt-md-2 mt-1 mt-md-8 text-center\">\n <div className=\"col\">\n <h1 className={`${styles.headline} fs-md-12 text-uppercase`}>\n Check the Status of Your Order\n </h1>\n <p className={`${styles.copy} mt-1 mt-md-3 fs-5`}>\n Please enter your order number and the email address used to place the order to easily\n track it.\n </p>\n </div>\n </div>\n\n {!!error && (\n <div className=\"row mt-5 mb-n2 text-center\">\n <div className=\"col-md-8 mx-auto\">\n <ErrorBox errors={error} />\n </div>\n </div>\n )}\n\n <div className=\"row pt-2 pb-3 pb-md-5 mt-8\">\n <form className=\"col col-md-4 form-group mx-auto fs-4\" onSubmit={handleSubmit}>\n <label className=\"w-100 font-weight-normal\" htmlFor=\"order-number\">\n <div className=\"mb-2\">Order Number</div>\n <FormStateInput\n {...number( 'id' )}\n id=\"order-number\"\n className={`${styles.number} w-100 fs-4`}\n placeholder=\"Order Number\"\n required\n />\n </label>\n\n <label className=\"w-100 mt-2 font-weight-normal\" htmlFor=\"email-address\">\n <div className=\"mb-2\">Email Address</div>\n <FormStateInput\n {...email( 'email' )}\n id=\"email-address\"\n className=\"w-100 fs-4\"\n placeholder=\"Email Address\"\n required\n />\n </label>\n\n <LoadingButton\n type=\"submit\"\n className=\"btn btn-block btn-secondary py-2 mt-2 spec__find-my-order-btn\"\n loading={loading}\n >\n Find My Order\n </LoadingButton>\n\n <div className=\"mt-9\">\n <LogIn />\n </div>\n </form>\n </div>\n </div>\n );\n};\n\nexport default OrderStatus;\n"],"names":["LogIn","account","useSelector","state","dispatch","useDispatch","routes","useRoutes","handleClick","switchMode","open","React.createElement","styles","OrderStatus","error","setError","React.useState","loading","setLoading","formState","number","email","useFormState","handleSubmit","event","api","response","ErrorBox","FormStateInput","LoadingButton"],"mappings":"2nBAQaA,EAAkB,IAAM,CACnC,MAAMC,EAAUC,EAAcC,GAAgBA,EAAM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