import {
  actionGetMessagesSuccess,
  actionGetMessagesReject
} from '../action';
import { getMessagesById } from '../../../api-data';
import { IMessagesState } from '../../../typescript/redux/messages/interfaces'


const asyncGetMessagesById= (id:string,cb:any) => async (dispatch:any) => {
  try {
    const data = await getMessagesById<IMessagesState>(id)
    data && dispatch(actionGetMessagesSuccess(data))
    cb&&cb()
  } catch (e) {
    dispatch(actionGetMessagesReject())
  } 
};


export { asyncGetMessagesById };




