import React from "react";
import { NonProgramLabel_def, StoreSearch_def, OQAD_TimeConst } from "../constants/constants";

const initialState = {
    projectID: '',
    projectName: "",
    projectCode: "",
    projectData: {},
    baseurl: '',
    companylogo: '',
    splashlogo: '',
    drawerlogo: '',
    imageUploadUrl: '',
    GeoFenceEnable: false,
    GeoFenceRadius: 0,
    GFEnable_checkout: false,
    GFRadius_checkout: 0,
    DBCI_GeoFenceEnable: false,
    DBCI_GeoFenceRadius: 0,
    DBCO_GeoFenceEnable: false,
    DBCO_GeoFenceRadius: 0,
    CheckOut_PhotoReq: false,
    CameraGallery: false,
    CheckInCameraGallery: false,
    DownloadKey: '',
    OQAD_TimeOut: OQAD_TimeConst,
    ShowMenuType: false,
    ShowStoreChecklist: false,
    ShowBeatPlanList: false,
    ShowContractForm: false,
    WarehouseShow: false,
    ShowDBPOSM: false,
    ShowStoreAdd: false,
    ShowAddNewStore: false,
    ShowSideMenuKYC: false,
    ShowStoreProfile: false,
    ShowCompactStoreProfile: false,
    ShowReportAfterCheckIn: false,
    ShowNonMerList: false,
    Show_VisitorFeedBack: false,
    Show_ConsumerSection: false,
    ShowNonProgram: false,
    StoreChecklistOnce: false,
    FaceRecognition: false,
    AddNewStoreInJCP: false,
    AddNewStoreVerificationReq: false,
    ShowStoreSearch: false,
    ShowStoreSearchLabel: StoreSearch_def,
    Clear_storage: false,
    PartialSaveAllow: false,
    NonProgramLabel: NonProgramLabel_def,
    CheckinOpenBackCamera: false,
    CheckoutOpenBackCamera: false,
    CheckInSwitchingCamera: false,
    IR_CameraEnableOnApp: false,
    RefImagePopUpTime: 0,
    AdhocActivated: "",
    IR_Creds: {},
    Chatbot_Creds: {},
    AppDashboardReports: {},
    Show_OldMTDReports: true,
    Allow_Change_Password: false,
    forget_Password_on_LoginPage: false,
    Gyancast: false,
    WebViewDashboard: false,
    Chatbot: false,
    StoreMapView: false,
    StoreRouteView: false,
    NoCheckIn_Photo: false,
    GroomingObj : {},
    pPAYObj: {},
    AppDashboardWebViewObj : "",

};

const projectReducer = (state = initialState, action) => {
    switch (action.type) {
        case 'GETPROJECT':
            return { ...state };
        case 'SETPROJECT':
            const pdata = action.data || {};
            let newstate = {
                projectID: pdata.pid, projectName: pdata.pname, projectCode: pdata.pcode, projectData: pdata.alldata, baseurl: pdata.baseurl, companylogo: (pdata.companylogo || ''), splashlogo: (pdata.splashlogo || ''), drawerlogo: (pdata.drawerlogo || ''), imageUploadUrl: (pdata.imageUploadUrl || ''),
                GeoFenceEnable: (pdata.GeoFenceEnable || false), GeoFenceRadius: (pdata.GeoFenceRadius || 0), GFEnable_checkout: (pdata.GFEnable_checkout || false), GFRadius_checkout: (pdata.GFRadius_checkout || 0), CheckOut_PhotoReq: (pdata.CheckOut_PhotoReq != null ? pdata.CheckOut_PhotoReq : false),
                CameraGallery: (pdata.CameraGallery != null ? pdata.CameraGallery : false), CheckInCameraGallery: (pdata.CheckInCameraGallery != null ? pdata.CheckInCameraGallery : false), DownloadKey: (pdata.DownloadKey != null ? pdata.DownloadKey : ''),
                OQAD_TimeOut: (pdata.OQAD_TimeOut != null ? pdata.OQAD_TimeOut : OQAD_TimeConst), ShowMenuType: (pdata.ShowMenuType != null ? pdata.ShowMenuType : false), ShowStoreChecklist: (pdata.ShowStoreChecklist != null ? pdata.ShowStoreChecklist : false), ShowBeatPlanList: (pdata.ShowBeatPlanList != null ? pdata.ShowBeatPlanList : false),
                ShowDBPOSM: (pdata.ShowDBPOSM != null ? pdata.ShowDBPOSM : false), ShowStoreAdd: (pdata.ShowStoreAdd != null ? pdata.ShowStoreAdd : false), ShowAddNewStore: (pdata.ShowAddNewStore != null ? pdata.ShowAddNewStore : false), ShowSideMenuKYC: (pdata.ShowSideMenuKYC != null ? pdata.ShowSideMenuKYC : false), ShowStoreProfile: (pdata.ShowStoreProfile != null ? pdata.ShowStoreProfile : false),
                ShowCompactStoreProfile: (pdata.ShowCompactStoreProfile != null ? pdata.ShowCompactStoreProfile : false),
                ShowReportAfterCheckIn: (pdata.ShowReportAfterCheckIn != null ? pdata.ShowReportAfterCheckIn : false),
                DBCI_GeoFenceEnable: (pdata.DBCI_GeoFenceEnable || false), DBCI_GeoFenceRadius: (pdata.DBCI_GeoFenceRadius || 0), DBCO_GeoFenceEnable: (pdata.DBCO_GeoFenceEnable || false), DBCO_GeoFenceRadius: (pdata.DBCO_GeoFenceRadius || 0), ShowNonMerList: (pdata.ShowNonMerList != null ? pdata.ShowNonMerList : false),
                Show_VisitorFeedBack: (pdata.Show_VisitorFeedBack || false),
                ShowNonProgram: (pdata.ShowNonProgram != null ? pdata.ShowNonProgram : false),
                StoreChecklistOnce: (pdata.StoreChecklistOnce != null ? pdata.StoreChecklistOnce : false),
                FaceRecognition: (pdata.FaceRecognition != null ? pdata.FaceRecognition : false),
                Gyancast: (pdata.Gyancast != null ? pdata.Gyancast : false),
                Chatbot: (pdata.Chatbot != null ? pdata.Chatbot : false),
                WebViewDashboard: (pdata.WebViewDashboard !=null ? pdata.WebViewDashboard : false),
                StoreMapView: (pdata.StoreMapView != null ? pdata.StoreMapView : false),
                StoreRouteView: (pdata.StoreRouteView != null ? pdata.StoreRouteView : false),
                //StoreMapView: true,
                //StoreRouteView: true,
                NoCheckIn_Photo: (pdata.NoCheckIn_Photo != null ? pdata.NoCheckIn_Photo : false),
                AddNewStoreInJCP: (pdata.AddNewStoreInJCP != null ? pdata.AddNewStoreInJCP : false),
                AddNewStoreVerificationReq: (pdata.AddNewStoreVerificationReq != null ? pdata.AddNewStoreVerificationReq : false),
                ShowStoreSearch: (pdata.ShowStoreSearch != null ? pdata.ShowStoreSearch : false),
                ShowStoreSearchLabel: (pdata.ShowStoreSearchLabel != null ? pdata.ShowStoreSearchLabel : StoreSearch_def),
                Show_ConsumerSection: (pdata.Show_ConsumerSection || false),
                Clear_storage: (pdata.Clear_storage || false),
                PartialSaveAllow: (pdata.PartialSaveAllow || false),
                NonProgramLabel: (pdata.NonProgramLabel != null ? pdata.NonProgramLabel : NonProgramLabel_def),
                CheckinOpenBackCamera: (pdata.CheckinOpenBackCamera != null ? pdata.CheckinOpenBackCamera : false),
                CheckoutOpenBackCamera: (pdata.CheckoutOpenBackCamera != null ? pdata.CheckoutOpenBackCamera : false),
                CheckInSwitchingCamera: (pdata.CheckInSwitchingCamera != null ? pdata.CheckInSwitchingCamera : false),
                IR_CameraEnableOnApp: (pdata.IR_CameraEnableOnApp || false),
                IR_Creds: (pdata.IR_Creds != null ? pdata.IR_Creds : {}),
                Chatbot_Creds: (pdata.Chatbot_Creds != null ? pdata.Chatbot_Creds : {}),
                ShowAddNewStore: (pdata.ShowAddNewStore != null ? pdata.ShowAddNewStore : false),
                ShowSideMenuKYC: (pdata.ShowSideMenuKYC != null ? pdata.ShowSideMenuKYC : false),
                RefImagePopUpTime: (pdata.RefImagePopUpTime != null ? pdata.RefImagePopUpTime : 0),
                ShowContractForm: (pdata.ShowContractForm != null ? pdata.ShowContractForm : false),
                WarehouseShow: (pdata.WarehouseShow != null ? pdata.WarehouseShow : false),
                Show_OldMTDReports: (pdata.Show_OldMTDReports == 1 || pdata.Show_OldMTDReports == "true" ? true : false),

                AdhocActivated: (pdata.AdhocActivated != null ? pdata.AdhocActivated : ""),
                Allow_Change_Password: (pdata.Allow_Change_Password != null ? pdata.Allow_Change_Password : false), forget_Password_on_LoginPage: (pdata.forget_Password_on_LoginPage != null ? pdata.forget_Password_on_LoginPage : false)

            };
            // console.log("pdata.Clear_storage Clear_storage",Clear_storage)

            return Object.assign({}, state, newstate);
        case 'SET_DASHBOARD_REPORTS':
            return { ...state, AppDashboardReports: action.data };

            case 'SET_GROOMING_OBJ': 
            console.log("fkgfgmkmgh",action.data)
             return { ...state, GroomingObj: action.data };

              case 'SET_AppDashboardWebView_OBJ': 
            console.log("SET_AppDashboardWebView_OBJ",action.data)
             return { ...state, AppDashboardWebViewObj: action.data };

            case 'SET_PPAY_OBJ': 
            console.log("pPAYObj",action.data)
             return { ...state, pPAYObj: action.data };
        default:
            return state;
    }
}
export default projectReducer;