{"version":3,"file":"after_push_through_to_match_flow-SNpWDplm.js","sources":["../../app/javascript/components/sign_up/after_push_through_to_match_flow.jsx","../../app/javascript/entrypoints/react_rails/sign_up/after_push_through_to_match_flow.tsx"],"sourcesContent":["// Third-party imports.\nimport React from \"react\";\nimport jQuery from \"jquery\";\nimport PropTypes from \"prop-types\";\nimport \"react-phone-number-input/style.css\";\nimport PhoneInput from \"react-phone-number-input\";\n// Our imports.\nimport LegalTermsAgreement from \"../legal_terms_agreement\";\nimport EuCitizenCheckbox from \"./eu_citizen_checkbox\";\nimport ButtonWithSpinner from \"../button_with_spinner\";\nimport { Provider as StyletronProvider } from \"styletron-react\";\nimport { Client as Styletron } from \"styletron-engine-atomic\";\nimport { BaseProvider } from \"baseui\";\nimport { ThemeProvider } from \"styled-components\";\nimport { ThemeProvider as MaterialThemeProvider, THEME_ID } from \"@mui/material/styles\";\nimport { LocalizationProvider } from \"@mui/x-date-pickers/LocalizationProvider\";\nimport { AdapterDateFns } from \"@mui/x-date-pickers/AdapterDateFnsV3\";\nimport materialTheme from \"../styling/material_theme\";\nimport deprecatedTheme from \"../styling/deprecated_theme\";\nimport baseuiTheme from \"../styling/baseui_theme\";\nimport \"./after_push_through_to_match_flow.css\";\nimport ProgramSchoolLogoBlock from \"../shared/login_and_sign_up/program_school_logo_block\";\n\nconst engine = new Styletron();\nclass AfterPushThroughToMatchFlow extends React.Component {\n static propTypes = {\n // The jwt token containing the user's email address.\n token: PropTypes.string.isRequired,\n programData: PropTypes.object.isRequired,\n\n createZendeskTicketPath: PropTypes.string.isRequired,\n signUpAndRegisterPath: PropTypes.string.isRequired,\n csrfToken: PropTypes.string.isRequired,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n // The user's phone number in E164 format.\n phone: \"\",\n\n isEUCitizen: false,\n acceptedLegalTerms: false,\n\n // We may display errors to the user if information they provided is invalid.\n errors: [],\n\n // Whether a request to the backend is in-flight.\n processingSubmission: false,\n };\n }\n\n render() {\n return (\n <StyletronProvider value={engine}>\n <BaseProvider theme={baseuiTheme}>\n <ThemeProvider theme={{ ...deprecatedTheme, ...baseuiTheme }}>\n <MaterialThemeProvider theme={{ [THEME_ID]: materialTheme }}>\n <LocalizationProvider dateAdapter={AdapterDateFns}>\n <div className=\"brand-name text-align-center\">\n <ProgramSchoolLogoBlock\n programLogo={this.props.programData.logo}\n programName={this.props.programData.title}\n schoolLogo={this.props.programData.schoolLogo}\n schoolName={this.props.programData.schoolName}\n />\n </div>\n <div className=\"after-push-through-to-match-flow text-align-center\">\n {this.renderFormElement()}\n {this.renderFormErrorsElement()}\n\n <div className=\"vertical-spacing-top three-rems\">\n <span className=\"regular-alt\">What's the point of this?</span>\n {this.renderWhatIsThePointOfThisText()}\n </div>\n </div>\n </LocalizationProvider>\n </MaterialThemeProvider>\n </ThemeProvider>\n </BaseProvider>\n </StyletronProvider>\n );\n }\n\n renderFormElement() {\n // Default to US as that's where most of our users are based.\n const defaultCountryCode = \"US\";\n\n // We aren't using the submit capabilities of the <form> element -- that is handled by Ajax.\n return (\n <form className=\"vertical-spacing four-rems\" onSubmit={this.onSubmitForm}>\n <ul className=\"form-items-container\">\n <li className=\"form-item\">\n <span className=\"text-align-center\">\n <PhoneInput\n aria-label=\"phone\"\n country={defaultCountryCode}\n defaultCountry=\"US\"\n placeholder=\"Phone number\"\n value={this.state.phone}\n name=\"phone\"\n onChange={(value) => this.onFormDataChanged(\"phone\", value)}\n />\n </span>\n </li>\n </ul>\n <span className=\"text-align-center\">\n <div className=\"vertical-spacing-top one-rem\">\n <LegalTermsAgreement\n acceptedLegalTerms={this.state.acceptedLegalTerms}\n onAgreementStatusChanged={(agreementStatus) =>\n this.setState({ acceptedLegalTerms: agreementStatus })\n }\n />\n <EuCitizenCheckbox\n schoolId={this.props.programData.schoolId}\n euCitizen={this.state.isEUCitizen}\n onChange={(event) => this.onFormDataChanged(\"isEUCitizen\", event.target.checked)}\n />\n </div>\n </span>\n <div className=\"vertical-spacing-top one-rem\">\n <ButtonWithSpinner\n text={\"Continue\"}\n isDisabled={!this.allowSubmit()}\n isSpinning={this.state.processingSubmission}\n />\n </div>\n </form>\n );\n }\n\n allowSubmit() {\n return this.state.acceptedLegalTerms;\n }\n\n onFormDataChanged(key, newValue) {\n // Copied from SignUpFlow.\n\n // Whenever form data changes, we want to reset the errors attribute as they may no longer be\n // relevant. (There might still be errors, of course, but we want to be optimistic. We'll\n // discover them again when the user presses submit.)\n const update = { errors: [] };\n update[key] = newValue;\n\n this.setState(update);\n }\n\n renderFormErrorsElement() {\n if (this.state.errors.length === 0) {\n return null;\n }\n\n const errorItems = this.state.errors.map((error, i) => (\n <div key={i} className=\"error-item\">\n {error}\n </div>\n ));\n\n return <div className=\"form-errors\">{errorItems}</div>;\n }\n\n onSubmitForm = async (event) => {\n event.preventDefault();\n\n this.setState({ processingSubmission: true });\n try {\n await jQuery.post({\n url: this.props.signUpAndRegisterPath,\n headers: { \"X-CSRF-Token\": this.props.csrfToken },\n data: {\n program_id: this.props.programData.id,\n token: this.props.token,\n phone: this.state.phone,\n is_eu_citizen: this.state.isEUCitizen,\n has_accepted_privacy_policy: this.state.acceptedLegalTerms,\n },\n });\n\n // Move the user along to the rest of the webapp.\n window.location.reload();\n } catch (response) {\n // Display the error in the form.\n if (response.responseJSON) {\n this.setState({ errors: response.responseJSON.errors });\n } else {\n this.setState({\n errors: [`Error: HTTP ${response.status}. Please try again or refresh the page.`],\n });\n }\n return;\n } finally {\n this.setState({ processingSubmission: false });\n }\n };\n\n renderWhatIsThePointOfThisText() {\n return (\n <p>\n Your phone number will be shared with your mentor when you are matched (and in exchange, you\n will receive theirs). We will also use it to check in with you and make sure everything is\n going ok in the program.\n </p>\n );\n }\n}\n\nexport default AfterPushThroughToMatchFlow;\n","import React from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport AfterPushThroughToMatchFlow from \"../../../components/sign_up/after_push_through_to_match_flow\";\n\nfunction init() {\n const componentElements = document.querySelectorAll(\n '[data-react-class=\"sign_up/after_push_through_to_match_flow\"]',\n );\n componentElements.forEach((rootElement) => {\n const classString = rootElement.getAttribute(\"data-react-class\");\n const propsJson = rootElement.getAttribute(\"data-react-props\");\n const props = rootElement && JSON.parse(propsJson ?? \"\");\n if (classString) {\n const root = createRoot(rootElement);\n root.render(<AfterPushThroughToMatchFlow {...props} />);\n }\n });\n}\n\nif (document.readyState === \"complete\" || document.readyState === \"interactive\") {\n // document has at least been parsed\n init();\n} else {\n document.addEventListener(\"DOMContentLoaded\", () => {\n init();\n });\n}\n"],"names":["engine","Styletron","AfterPushThroughToMatchFlow","React","props","__publicField","event","jQuery","response","jsx","StyletronProvider","BaseProvider","baseuiTheme","ThemeProvider","deprecatedTheme","MaterialThemeProvider","THEME_ID","materialTheme","jsxs","LocalizationProvider","AdapterDateFns","ProgramSchoolLogoBlock","PhoneInput","value","LegalTermsAgreement","agreementStatus","EuCitizenCheckbox","ButtonWithSpinner","key","newValue","update","errorItems","error","i","PropTypes","init","rootElement","classString","propsJson","createRoot"],"mappings":"ooCAuBA,MAAMA,EAAS,IAAIC,EACnB,MAAMC,UAAoCC,EAAM,SAAU,CAWxD,YAAYC,EAAO,CACjB,MAAMA,CAAK,EA8HbC,EAAA,oBAAe,MAAOC,GAAU,CAC9BA,EAAM,eAAe,EAErB,KAAK,SAAS,CAAE,qBAAsB,EAAA,CAAM,EACxC,GAAA,CACF,MAAMC,EAAO,KAAK,CAChB,IAAK,KAAK,MAAM,sBAChB,QAAS,CAAE,eAAgB,KAAK,MAAM,SAAU,EAChD,KAAM,CACJ,WAAY,KAAK,MAAM,YAAY,GACnC,MAAO,KAAK,MAAM,MAClB,MAAO,KAAK,MAAM,MAClB,cAAe,KAAK,MAAM,YAC1B,4BAA6B,KAAK,MAAM,kBAAA,CAC1C,CACD,EAGD,OAAO,SAAS,OAAO,QAChBC,EAAU,CAEbA,EAAS,aACX,KAAK,SAAS,CAAE,OAAQA,EAAS,aAAa,OAAQ,EAEtD,KAAK,SAAS,CACZ,OAAQ,CAAC,eAAe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