import { createReducer } from '@reduxjs/toolkit';
import { IChatsState, IChatsPayload } from '../../../typescript/redux/chats/interfaces';

import {
  actionGetChatsSuccess,
  actionGetChatsReject,
} from '../action';

const initialState: IChatsState = {
  total: "0",
  limit: "0",
  page: "0",
  chats: [],
}



const reducerChats = createReducer(initialState, {
  [actionGetChatsSuccess.type]: (_,{ payload }:IChatsPayload) => {
    return payload
  },
  [actionGetChatsReject.type]: (state, _) => {
    return state;
  },
});

export default reducerChats;
