/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License.
 */ import { ActionObject , UserState } from '../types' ; import { AT } from '../types/ActionTypes' ; import { Reducer } from 'redux' ; import * as ClientFactory from '../services/clientFactory' ; import produce from 'immer' ; const initialState = { user : undefined } ; const initializeClientFactory = ( memoryKey , botChecksum ) => { ClientFactory . setHeaders ( ( ) => { return { memoryKey , botChecksum } ; } ) ; } ; const userReducer = produce ( ( state , action ) => { switch ( action . type ) { case AT . FETCH_BOTINFO_FULFILLED : const user = action . botInfo . user ; initializeClientFactory ( user . id , action . botInfo . checksum ) ; state . user = user ; return ; default : return ; } } , initialState ) ; export default userReducer ;