Browse Source

fix(redux user): add new variable register

master
farhantock 6 months ago
parent
commit
b8ea95882c
  1. 6
      src/appredux/modules/user/actions.js
  2. 27
      src/appredux/modules/user/reducers.js

6
src/appredux/modules/user/actions.js

@ -2,7 +2,7 @@ export const SET_IS_LOGIN = 'SET_IS_LOGIN';
export const SET_USER = 'SET_USER';
export const SET_FCM_TOKEN = 'SET_FCM_TOKEN';
export const SET_CHOSEN_LANGUAGE = 'SET_CHOSEN_LANGUAGE';
export const SET_SCANNED_CODE = 'SET_SCANNED_CODE';
export const SET_REGISTER = 'SET_REGISTER';
export const setIsLogin = auth => dispatch => {
dispatch({
@ -32,9 +32,9 @@ export const setChosenLanguage = obj => dispatch => {
})
}
export const setScannedCode = obj => dispatch => {
export const setRegister = obj => dispatch => {
dispatch({
type: SET_SCANNED_CODE,
type: SET_REGISTER,
payload: obj
})
}

27
src/appredux/modules/user/reducers.js

@ -3,33 +3,16 @@ import {
SET_USER,
SET_FCM_TOKEN,
SET_CHOSEN_LANGUAGE,
SET_SCANNED_CODE
SET_REGISTER
} from "./actions";
// user object sample
// {
// "apikey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJZCI6ODgwLCJOYW1lIjoicG9kdGVzdDIiLCJSb2xlIjoiYWRtX2ludGVncmFzaWFfZGVtbyIsIkNvbXBhbnkiOjQ0MiwiVXNlclBvZElkIjoyMDAsImlzcyI6Ik9TTE9HIDUgQVBJIn0.7pgAw4uDC_HrSQ_2zQMuzeMiQ5YfQwU59txeZ3ZVLTQ",
// "company": 442,
// "fcm_token": "",
// "id": 3916,
// "imei_no": "442846900000001",
// "last_login_date": "2023-12-05T23:14:40.47940801+07:00",
// "name": "John",
// "password": "827ccb0eea8a706c4c34a16891f84e7b",
// "password_not_encrypt": "12345",
// "role_name": "adm_integrasia_demo",
// "shipment_order": 281756,
// "user_id": 880,
// "user_pod": 200,
// "username": "podtest2"
// }
const initialState = {
isLogin: false,
user: null, // the payload after request login to API
fcmToken: null,
chosenLanguage: 'id', // id / en
scannedCode: null // to place a global scan code feature
chosenLanguage: 'en', // id / en
isRegister: false
}
function userReducer(state = initialState, action) {
@ -42,8 +25,8 @@ function userReducer(state = initialState, action) {
return { ...state, fcmToken: action.payload }
case SET_CHOSEN_LANGUAGE:
return { ...state, chosenLanguage: action.payload }
case SET_SCANNED_CODE:
return { ...state, scannedCode: action.payload }
case SET_REGISTER:
return { ...state, isRegister: action.payload }
default:
return state;
}

Loading…
Cancel
Save