import React from "react";

const initialState = {
    isDataDownloaded: false,
    startDownload:false,
    startUpload:false,
    isInternetAvailable:true,
    showConnChange:false,
    AutoGoToPrev:false,
    StaticText:{},
    isTodayLoginExists: false,
    isTodayDataDownloaded: false,
    AllKPIDisable:false,
};

const globalDataReducer = (state = initialState, action) => {
    switch(action.type) {
        case 'SET_GLOBAL_DATA':
            return {...state,isDataDownloaded:action.data.isDataDownloaded};  
        case 'START_DOWNLOAD':
            return {...state,startDownload:action.data.startDownload};  
        case 'START_UPLOAD':
            return {...state,startUpload:action.data.startUpload};  
        case 'SET_NETWORK':
            return {...state,isInternetAvailable:action.data?(action.data.isInternetAvailable?action.data.isInternetAvailable:false):false};  
        case 'SHOW_CONCHANGE':
            return {...state,showConnChange:action.data?(action.data.showConnChange?action.data.showConnChange:false):false};  
        case 'AUTO_BACK':
            return {...state,AutoGoToPrev:action.data?(action.data.AutoGoToPrev?action.data.AutoGoToPrev:false):false};  
        case 'SET_STATIC_TEXT':
            return {...state,StaticText:action.data?action.data:{}};  
        case 'SET_LOGIN_EXISTS':
            return {...state,isTodayLoginExists:action.data?action.data:false}; 
        case 'SET_TODAY_DATA_EXISTS':
            return {...state,isTodayDataDownloaded:action.data?action.data:false}; 
        case 'ALLKPIDISABLE':
            return {...state,AllKPIDisable:action.data?action.data:false};
        default:
            return state;
    }
}
export default globalDataReducer;