230 lines
6.1 KiB
JavaScript
230 lines
6.1 KiB
JavaScript
/**
|
|
* Project YooLearn
|
|
* File skills.reducer
|
|
* Path app/redux/skills
|
|
* Created by BRICE ZELE
|
|
* Date: 13/09/2021
|
|
*/
|
|
import InsuranceActions from "./insurance.type";
|
|
|
|
interface SkillsActions {
|
|
payload?: any;
|
|
type: string;
|
|
}
|
|
|
|
const INITIAL_STATE = {
|
|
loading: false,
|
|
result: null,
|
|
error: null,
|
|
};
|
|
|
|
export const insuranceListReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
switch (action.type) {
|
|
case InsuranceActions.GET_INSURANCE_LIST_PENDING:
|
|
return {
|
|
...state,
|
|
loading: true
|
|
}
|
|
case InsuranceActions.GET_INSURANCE_LIST_SUCCESS:
|
|
return {
|
|
loading: false,
|
|
result: action.payload,
|
|
error: null
|
|
}
|
|
case InsuranceActions.GET_INSURANCE_LIST_ERROR:
|
|
return {
|
|
...state,
|
|
loading: false,
|
|
result: null,
|
|
error: action.payload
|
|
}
|
|
|
|
case InsuranceActions.GET_INSURANCE_LIST_RESET:
|
|
return INITIAL_STATE;
|
|
|
|
default:
|
|
return state
|
|
|
|
}
|
|
};
|
|
|
|
export const subscribeInsuranceReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
switch (action.type) {
|
|
case InsuranceActions.SUBSCRIBE_INSURANCE_PENDING:
|
|
return {
|
|
...state,
|
|
loading: true
|
|
}
|
|
case InsuranceActions.SUBSCRIBE_INSURANCE_SUCCESS:
|
|
return {
|
|
loading: false,
|
|
result: action.payload,
|
|
error: null
|
|
}
|
|
case InsuranceActions.SUBSCRIBE_INSURANCE_ERROR:
|
|
return {
|
|
...state,
|
|
loading: false,
|
|
result: null,
|
|
error: action.payload
|
|
}
|
|
|
|
case InsuranceActions.SUBSCRIBE_INSURANCE_RESET:
|
|
return INITIAL_STATE;
|
|
|
|
default:
|
|
return state
|
|
|
|
}
|
|
};
|
|
|
|
export const getInsurancePrimeAmountReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
switch (action.type) {
|
|
case InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_PENDING:
|
|
return {
|
|
...state,
|
|
loading: true
|
|
}
|
|
case InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_SUCCESS:
|
|
return {
|
|
loading: false,
|
|
result: action.payload,
|
|
error: null
|
|
}
|
|
case InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_ERROR:
|
|
return {
|
|
...state,
|
|
loading: false,
|
|
result: null,
|
|
error: action.payload
|
|
}
|
|
|
|
case InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_RESET:
|
|
return INITIAL_STATE;
|
|
|
|
default:
|
|
return state
|
|
|
|
}
|
|
};
|
|
|
|
export const uploadInsuranceImagesReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
switch (action.type) {
|
|
case InsuranceActions.UPLOAD_INSURANCE_IMAGES_PENDING:
|
|
return {
|
|
...state,
|
|
loading: true
|
|
}
|
|
case InsuranceActions.UPLOAD_INSURANCE_IMAGES_SUCCESS:
|
|
return {
|
|
loading: false,
|
|
result: action.payload,
|
|
error: null
|
|
}
|
|
case InsuranceActions.UPLOAD_INSURANCE_IMAGES_ERROR:
|
|
return {
|
|
...state,
|
|
loading: false,
|
|
result: null,
|
|
error: action.payload
|
|
}
|
|
|
|
case InsuranceActions.UPLOAD_INSURANCE_IMAGES_RESET:
|
|
return INITIAL_STATE;
|
|
|
|
default:
|
|
return state
|
|
|
|
}
|
|
};
|
|
|
|
export const getSubscriptionListReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
switch (action.type) {
|
|
case InsuranceActions.GET_SUBSCRIPTION_LIST_PENDING:
|
|
return {
|
|
...state,
|
|
loading: true
|
|
}
|
|
case InsuranceActions.GET_SUBSCRIPTION_LIST_SUCCESS:
|
|
return {
|
|
loading: false,
|
|
result: action.payload,
|
|
error: null
|
|
}
|
|
case InsuranceActions.GET_SUBSCRIPTION_LIST_ERROR:
|
|
return {
|
|
...state,
|
|
loading: false,
|
|
result: null,
|
|
error: action.payload
|
|
}
|
|
|
|
case InsuranceActions.GET_SUBSCRIPTION_LIST_RESET:
|
|
return INITIAL_STATE;
|
|
|
|
default:
|
|
return state
|
|
|
|
}
|
|
};
|
|
|
|
export const activatePaySubscriptionReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
switch (action.type) {
|
|
case InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_PENDING:
|
|
return {
|
|
...state,
|
|
loading: true
|
|
}
|
|
case InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_SUCCESS:
|
|
return {
|
|
loading: false,
|
|
result: action.payload,
|
|
error: null
|
|
}
|
|
case InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_ERROR:
|
|
return {
|
|
...state,
|
|
loading: false,
|
|
result: null,
|
|
error: action.payload
|
|
}
|
|
|
|
case InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_RESET:
|
|
return INITIAL_STATE;
|
|
|
|
default:
|
|
return state
|
|
|
|
}
|
|
};
|
|
|
|
export const addBeneficiaryToSubscriptionReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
switch (action.type) {
|
|
case InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_PENDING:
|
|
return {
|
|
...state,
|
|
loading: true
|
|
}
|
|
case InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_SUCCESS:
|
|
return {
|
|
loading: false,
|
|
result: action.payload,
|
|
error: null
|
|
}
|
|
case InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_ERROR:
|
|
return {
|
|
...state,
|
|
loading: false,
|
|
result: null,
|
|
error: action.payload
|
|
}
|
|
|
|
case InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_RESET:
|
|
return INITIAL_STATE;
|
|
|
|
default:
|
|
return state
|
|
|
|
}
|
|
};
|