import {
  actionSelectChat,
  actionGetChatById
} from '../action';
import { startChat,getChatById } from '../../../api-data';

import { TChat } from '../../../typescript/redux/chat/types'

const asyncStartChatById = (id:string) => async (dispatch:any) => {
  try {
    const data = await startChat<TChat>(id)
    data&&dispatch(actionSelectChat(data))
  } catch(e) {}
};

const asyncGetChatById = (id:string) => async (dispatch:any) => {
  try {
    const data = await getChatById<TChat>(id)
    data&&dispatch(actionGetChatById(data))
  } catch(e) {}
};



export { asyncStartChatById,asyncGetChatById };




