diff --git a/client/src/components/MessageWrapper.tsx b/client/src/components/MessageWrapper.tsx index 455e8ee..bba1bd8 100644 --- a/client/src/components/MessageWrapper.tsx +++ b/client/src/components/MessageWrapper.tsx @@ -1,22 +1,31 @@ -import Message from "./Message"; -import { getMessages } from "@controllers/MessageController"; -import { useQuery } from "@tanstack/react-query"; -import { toastError } from "@controllers/Toasts"; +import Message from './Message'; +import { getMessages } from '@controllers/MessageController'; +import { useQuery } from '@tanstack/react-query'; +import { toastError } from '@controllers/Toasts'; +import ScrollToBottom from './ScrollToBottom'; const MessageWrapper = () => { - const { data: messages, isLoading, isError } = useQuery(["messages"], getMessages, { + const { + data: messages, + isLoading, + isError, + } = useQuery(['messages'], getMessages, { onError: (error) => { toastError(error as string); }, }); return ( -
- {isLoading ? '' : isError ? '' : messages?.map((message: any) => ( - - ))} +
+ + {isLoading + ? '' + : isError + ? '' + : messages?.map((message: any) => )} +
); -} +}; -export default MessageWrapper; \ No newline at end of file +export default MessageWrapper; diff --git a/client/src/components/ScrollToBottom.tsx b/client/src/components/ScrollToBottom.tsx new file mode 100644 index 0000000..49a0025 --- /dev/null +++ b/client/src/components/ScrollToBottom.tsx @@ -0,0 +1,25 @@ +import { ReactNode, useRef } from 'react'; +import { FaChevronDown } from 'react-icons/fa'; + +const ScrollToBottom = ({ children, className = '' }: { children: ReactNode; className?: string }) => { + const bottom = useRef(null); + + return ( + <> +
+ {children} +
+
+ + + ); +}; + +export default ScrollToBottom;