%PDF- %PDF-
Direktori : /home/emergentqj/actioncivile/pre-auth/.632e77b3fb93bc8da5b589b869bc0037/static/js/containers/ |
Current File : /home/emergentqj/actioncivile/pre-auth/.632e77b3fb93bc8da5b589b869bc0037/static/js/containers/SignUpBusinessContainer.js |
import { connect } from "react-redux"; import SignUpBusiness from "components/SignUpBusiness"; import appConfig from "config/countryData"; // import { withRouter } from "react-router-dom"; import { useLocation, useNavigate, useParams, } from "react-router-dom"; import { registerSepaPayment, checkExistingUser, checkExistingUserReset, signUpCorporateLogin, setBusinessPaymentMethod, getCompaniesInfo, getCompanyVatInfo, getCompaniesInfoReset, getCompanyVatInfoReset, getCompanyInfo, registerDirectDebit, checkDirectDebitStatus, } from "../actions/api_actions"; import { showAlert, selectCode, getProductPackageInfo, setBusinessIframeSuccess, setBusinessIframeError, } from "../actions/list_actions"; import { getEnvConstant } from "../utils"; function withRouter(Component) { function ComponentWithRouterProp(props) { const location = useLocation(); const navigate = useNavigate(); const params = useParams(); return ( // eslint-disable-next-line react/react-in-jsx-scope <Component {...props} router={{ location, navigate, params }} /> ); } return ComponentWithRouterProp; } // const selector = formValueSelector("signUpForm"); let countrycode; const environment = getEnvConstant() === "production" ? "production" : "staging"; const mapStateToProps = (state) => { const productPackage = state.productPackageInfo.toJS(); countrycode = state.config.toJS().config.countryConstant; const isCountryHaveServerVatValidation = [ "BE", "DK", "ES", "FI", "IT", "NL", "NO", "SE", ].includes(countrycode); const isPecFieldsVisible = ["IT"].includes(countrycode); const { countryData } = appConfig; const signUpForm = state.form.signUpBusinessForm ? state.form.signUpBusinessForm : null; const selectedCode = state.user.get("selectedCode"); const checkExistingUserState = state.user.get("checkExistingUser"); const userIsLoading = state.user.get("isLoading"); return { checkExistingUserState, config: state.config.toJS(), company: state.getCompanyInfo.get("company"), countryCode: countrycode, countryData, environment, getCompanyInfoState: state.getCompanyInfo.toJS(), isCountryHaveServerVatValidation, isPecFieldsVisible, productPackagesInfo: productPackage.productPackagesInfo, selectedCode, signUpBusinessState: state.signUpBusiness.toJS(), signUpForm, userIsLoading, }; }; const mapDispatchToProps = (dispatch) => ({ loadCompany: (data) => { dispatch(getCompanyInfo(data)); }, getCompaniesInfo: (data) => { if (data && data.companyName && data.companyName.length > 3) { dispatch(getCompaniesInfo(data)); } }, getCompanyVatInfo: (data, isCountryHaveServerVatValidation) => { if ( data && data.organizationnumber && data.organizationnumber.length > 5 && isCountryHaveServerVatValidation === true ) { dispatch(getCompanyVatInfo(data)); } }, checkExistingUser: (phone) => { if (phone === "") { dispatch(checkExistingUserReset()); } else if (phone.length && phone.length > 7) { dispatch( checkExistingUser({ isBusinessFlow: true, phoneNumber: phone, }), ); } }, selectCode: (code) => dispatch(selectCode(code)), signUpCorporateLogin: (data, selectedCode) => { const countryCode = countrycode; data.countryCode = countryCode; data.selectedCode = selectedCode; dispatch(signUpCorporateLogin(data)); }, getCompaniesInfoReset: () => dispatch(getCompaniesInfoReset()), getCompanyVatInfoReset: () => dispatch(getCompanyVatInfoReset()), registerSepa: (data) => { dispatch(registerSepaPayment(data)); }, registerDirectDebit: (data) => { dispatch(registerDirectDebit(data)); }, checkDirectDebitStatus: (data) => { dispatch(checkDirectDebitStatus(data)); }, getProductPackageInfo: (ids) => dispatch(getProductPackageInfo(ids)), setBusinessPaymentMethod: (data) => { dispatch(setBusinessPaymentMethod(data)); }, showAlert: (params) => dispatch(showAlert(params)), setBusinessIframeSuccess: () => dispatch(setBusinessIframeSuccess()), setBusinessIframeError: () => dispatch(setBusinessIframeError()), }); export default withRouter(connect( mapStateToProps, mapDispatchToProps, )(SignUpBusiness));