Skip to content

Commit

Permalink
fix(client): MessagePage MessageList js->ts
Browse files Browse the repository at this point in the history
fixing #109
  • Loading branch information
roman-ojha committed Jun 30, 2022
1 parent 4a5175b commit 5892a85
Showing 1 changed file with 9 additions and 4 deletions.
@@ -1,25 +1,30 @@
import React, { useEffect, useState } from "react";
import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
import SearchIcon from "@mui/icons-material/Search";
import { messageListAction } from "../../services/redux-actions/index";
// import { messageListAction } from "../../services/redux-actions/index";
import { toastError } from "../../services/toast";
import messageApi from "../../services/api/global/message";
import MessageListSingleMessage from "./MessagesListSingleMessage";
import { useDispatch, useSelector } from "react-redux";
import { AppState, actionCreators } from "../../services/redux";
import { bindActionCreators } from "redux";

const MessagesList = () => {
const dispatch = useDispatch();
const [showLoadingSpinner, setShowLoadingSpinner] = useState(false);
const messageList = useSelector((state) => state.messageListReducer);
const messageList = useSelector(
(state: AppState) => state.messageListReducer
);
const { messageListAction } = bindActionCreators(actionCreators, dispatch);

useEffect(() => {
const getUserMessages = async () => {
const getUserMessages = async (): Promise<void> => {
try {
setShowLoadingSpinner(true);
const resMessage = await messageApi.getUserMessages();
const resMessageData = await resMessage.data;
if (resMessage.status === 200 && resMessageData.success) {
dispatch(messageListAction(resMessageData.messages));
messageListAction(resMessageData.messages);
} else {
toastError("Error While fetching Messages");
}
Expand Down

0 comments on commit 5892a85

Please sign in to comment.