%PDF- %PDF-
Direktori : /home/emergentqj/actioncivile/pre-auth/.4cc3a2e1590a4463a5f392ddcc26929e/static/js/reducers/ |
Current File : /home/emergentqj/actioncivile/pre-auth/.4cc3a2e1590a4463a5f392ddcc26929e/static/js/reducers/signUpBusiness.js |
import { fromJS } from "immutable"; import LIST_ACTIONS from "../constants/action_types"; /* paymentMethodStatus: 0-not set,1-ok,2-error */ const initialState = fromJS({ paymentMethods: [], isLoading: false, customer: {}, billingAccount: {}, requestedPaymentMethod: "", showPaymentMethodContainer: false, paymentMethodStatus: 0, userIsRegistered: 0, sepaIsRegistered: 0, counter: 0, directDebitResponse: {}, }); const signUpBusiness = (state = initialState, action = {}) => { const counter = state.get("counter") + 1; switch (action.type) { case LIST_ACTIONS.SIGNUP_CORPORATE_LOGIN_REQUEST: // return state.update("cars", arr => arr.delete(action.index)); return state.set("isLoading", true); case LIST_ACTIONS.SIGNUP_CORPORATE_LOGIN_SUCCESS: return state .set("userIsRegistered", 1) .set("customer", fromJS(action.payload.data.customer)) .set("billingAccount", fromJS(action.payload.data.billingAccount)) .set("isLoading", false); case LIST_ACTIONS.SIGNUP_CORPORATE_LOGIN_ERROR: return state.set("userIsRegistered", 2).set("isLoading", false); case LIST_ACTIONS.GET_BUSINESS_PAYMENT_METHODS_REQUEST: { return state.set("paymentMethods", []).set("isLoading", true); } case LIST_ACTIONS.GET_BUSINESS_PAYMENT_METHODS_SUCCESS: return state .set("paymentMethods", fromJS(action.payload.data)) .set("isLoading", false); case LIST_ACTIONS.GET_BUSINESS_PAYMENT_METHODS_ERROR: return state.set("paymentMethods", []).set("isLoading", false); case LIST_ACTIONS.SET_BUSINESS_PAYMENT_METHOD_REQUEST: return state .set("showPaymentMethodContainer", false) .set("requestedPaymentMethod", "") .set("isLoading", true); case LIST_ACTIONS.SET_BUSINESS_PAYMENT_METHOD_SUCCESS: { return state .set("showPaymentMethodContainer", true) .set("requestedPaymentMethod", action.payload) .set("isLoading", false); } case LIST_ACTIONS.SET_BUSINESS_PAYMENT_METHOD_ERROR: return state .set("showPaymentMethodContainer", false) .set("requestedPaymentMethod", "") .set("isLoading", false); case LIST_ACTIONS.SET_BUSINESS_IFRAME_SUCCESS: return state .set("isLoading", false) .set("showPaymentMethodContainer", false) .set("paymentMethodStatus", 1); case LIST_ACTIONS.SET_BUSINESS_IFRAME_ERROR: return state .set("isLoading", false) .set("showPaymentMethodContainer", true) .set("paymentMethodStatus", 2); case LIST_ACTIONS.REGISTER_SEPA_PAYMENT_REQUEST: case LIST_ACTIONS.COMPLETE_SEPA_PAYMENT: return state.set("isLoading", true); case LIST_ACTIONS.REGISTER_SEPA_PAYMENT_SUCCESS: { return state .set("isLoading", false) .set("counter", counter) .set("sepaIsRegistered", 1); } case LIST_ACTIONS.REGISTER_SEPA_PAYMENT_ERROR: return state .set("isLoading", false) .set("counter", counter) .set("sepaIsRegistered", 2); case LIST_ACTIONS.RESET_SEPA_STATUS: return state.set("sepaIsRegistered", 0); case LIST_ACTIONS.REGISTER_DIRECT_DEBIT_REQUEST: case LIST_ACTIONS.CHECK_DIRECT_DEBIT_STATUS_REQUEST: return state.set("isLoading", true); case LIST_ACTIONS.REGISTER_DIRECT_DEBIT_SUCCESS: return state .set("isLoading", false) .set("directDebitResponse", action.payload.data); case LIST_ACTIONS.REGISTER_DIRECT_DEBIT_ERROR: case LIST_ACTIONS.CHECK_DIRECT_DEBIT_STATUS_SUCCESS: case LIST_ACTIONS.CHECK_DIRECT_DEBIT_STATUS_ERROR: { return state.set("isLoading", false); } default: return state; } }; export default signUpBusiness;