2021-10-26 18:19:13 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
2021-11-11 11:43:33 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
2021-11-22 18:20:54 +00:00
|
|
|
|
|
|
|
export const getUserByIdQRCodeReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case InsuranceActions.GET_USER_BY_ID_QR_CODE_PENDING:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: true
|
|
|
|
}
|
|
|
|
case InsuranceActions.GET_USER_BY_ID_QR_CODE_SUCCESS:
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
result: action.payload,
|
|
|
|
error: null
|
|
|
|
}
|
|
|
|
case InsuranceActions.GET_USER_BY_ID_QR_CODE_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: false,
|
|
|
|
result: null,
|
|
|
|
error: action.payload
|
|
|
|
}
|
|
|
|
|
|
|
|
case InsuranceActions.GET_USER_BY_ID_QR_CODE_RESET:
|
|
|
|
return INITIAL_STATE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getUserByNameOrNumberReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_PENDING:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: true
|
|
|
|
}
|
|
|
|
case InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_SUCCESS:
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
result: action.payload,
|
|
|
|
error: null
|
|
|
|
}
|
|
|
|
case InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: false,
|
|
|
|
result: null,
|
|
|
|
error: action.payload
|
|
|
|
}
|
|
|
|
|
|
|
|
case InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_RESET:
|
|
|
|
return INITIAL_STATE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
2021-11-29 11:30:04 +00:00
|
|
|
|
|
|
|
export const getDrugAppareilReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case InsuranceActions.GET_DRUG_APPAREIL_PENDING:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: true
|
|
|
|
}
|
|
|
|
case InsuranceActions.GET_DRUG_APPAREIL_SUCCESS:
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
result: action.payload,
|
|
|
|
error: null
|
|
|
|
}
|
|
|
|
case InsuranceActions.GET_DRUG_APPAREIL_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: false,
|
|
|
|
result: null,
|
|
|
|
error: action.payload
|
|
|
|
}
|
|
|
|
|
|
|
|
case InsuranceActions.GET_DRUG_APPAREIL_RESET:
|
|
|
|
return INITIAL_STATE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const addDrugReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case InsuranceActions.ADD_DRUG_PENDING:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: true
|
|
|
|
}
|
|
|
|
case InsuranceActions.ADD_DRUG_SUCCESS:
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
result: action.payload,
|
|
|
|
error: null
|
|
|
|
}
|
|
|
|
case InsuranceActions.ADD_DRUG_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: false,
|
|
|
|
result: null,
|
|
|
|
error: action.payload
|
|
|
|
}
|
|
|
|
|
|
|
|
case InsuranceActions.ADD_DRUG_RESET:
|
|
|
|
return INITIAL_STATE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getProviderClassReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case InsuranceActions.GET_PROVIDER_CLASS_PENDING:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: true
|
|
|
|
}
|
|
|
|
case InsuranceActions.GET_PROVIDER_CLASS_SUCCESS:
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
result: action.payload,
|
|
|
|
error: null
|
|
|
|
}
|
|
|
|
case InsuranceActions.GET_PROVIDER_CLASS_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: false,
|
|
|
|
result: null,
|
|
|
|
error: action.payload
|
|
|
|
}
|
|
|
|
|
|
|
|
case InsuranceActions.GET_PROVIDER_CLASS_RESET:
|
|
|
|
return INITIAL_STATE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getNetworkActReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case InsuranceActions.GET_NETWORK_ACT_PENDING:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: true
|
|
|
|
}
|
|
|
|
case InsuranceActions.GET_NETWORK_ACT_SUCCESS:
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
result: action.payload,
|
|
|
|
error: null
|
|
|
|
}
|
|
|
|
case InsuranceActions.GET_NETWORK_ACT_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: false,
|
|
|
|
result: null,
|
|
|
|
error: action.payload
|
|
|
|
}
|
|
|
|
|
|
|
|
case InsuranceActions.GET_NETWORK_ACT_RESET:
|
|
|
|
return INITIAL_STATE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const createConsultationReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case InsuranceActions.CREATE_CONSULTATION_PENDING:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: true
|
|
|
|
}
|
|
|
|
case InsuranceActions.CREATE_CONSULTATION_SUCCESS:
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
result: action.payload,
|
|
|
|
error: null
|
|
|
|
}
|
|
|
|
case InsuranceActions.CREATE_CONSULTATION_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: false,
|
|
|
|
result: null,
|
|
|
|
error: action.payload
|
|
|
|
}
|
|
|
|
|
|
|
|
case InsuranceActions.CREATE_CONSULTATION_RESET:
|
|
|
|
return INITIAL_STATE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|