import Actions from '@/types/Store/Actions';

const INITIAL_STATE = {
  brand: '',
  model: '',
  pixelRatio: '',
  screenWidth: 0,
  screenHeight: 0,
  windowWidth: 0,
  windowHeight: 0,
  statusBarHeight: 0,
  language: '',
  version: '',
  system: '',
  platform: '',
  fontSizeSetting: 0,
  SDKVersion: '',
};

export const updateSystemInfo = (
  entity: Taro.getSystemInfo.Promised,
): Actions => ({
  type: 'UPDATE_SYSTEMINFO',
  payload: entity,
});

export default function systemInfo(
  state: Taro.getSystemInfo.Promised = INITIAL_STATE,
  actions: Actions,
): Taro.getSystemInfo.Promised {
  switch (actions.type) {
    case 'UPDATE_SYSTEMINFO':
      return {
        ...state,
        ...actions.payload,
      };
    default:
      return state;
  }
}
