You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

41 lines
1.3 KiB

import proxy from "../proxy";
const initialState = {
status: proxy.status(),
loading: false,
error: null,
list: null,
domains: [],
mothers: [],
profileStatus: false,
};
export default function user(state = initialState, action) {
let { type, data } = action;
switch (type) {
case "user/login":
case "user/register":
case "user/switchRole":
case "user/getProfile":
case "public/sendOTP":
case "user/otp/login":
return { ...state, loading: false, status: data, error: null };
case "user/logout":
return { ...state, loading: false, status: proxy.status(), error: null };
case "user/getUserRole":
return { ...state, loading: false, userRoles: data, error: null };
case "user/list":
return { ...state, loading: false, list: data, error: null };
case "user/domains":
return { ...state, loading: false, domains: data, error: null };
case "mothers/list":
return { ...state, loading: false, mothers: data, error: null };
case "user/setProfile":
return { ...state, loading: false, error: null };
/////////////
case "loading":
return { ...state, loading: true };
case "error":
return { ...state, loading: false, error: data.message };
default:
return state;
}
}