Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions chat/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
"react-toastify": "^11.0.3",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
Expand Down
4 changes: 3 additions & 1 deletion chat/src/App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import './App.css';
import ChatApp from './ChatApp.tsx'; // Import the ChatApp component
import ChatApp from './ChatApp.tsx';
import { ToastContainer, toast } from 'react-toastify';

function App() {
return (
<div className="App" style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
<header className="App-header" style={{height: "100%"}}>
<ChatApp />
<ToastContainer />
</header>
</div>
);
Expand Down
49 changes: 36 additions & 13 deletions chat/src/ChatApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Button,
} from 'antd';
import { ArrowRightOutlined } from '@ant-design/icons';
import {ToastContainer, toast, Bounce} from 'react-toastify';

const { Header, Content, Footer } = Layout;
const { TextArea } = Input;
Expand Down Expand Up @@ -74,21 +75,40 @@ const ChatApp: React.FC = () => {

// Send message
const sendMessage = (): void => {
if (ws && input.trim()) {
ws.send(input);
setMessages((prev) => [
...prev,
{
type: 'question',
reporter: 'user',
message: input,
links: [],
},
]);
setInput('');
try {
if (ws && input.trim()) {
ws.send(input);
setMessages((prev) => [
...prev,
{
type: 'question',
reporter: 'user',
message: input,
links: [],
},
]);
setInput('');
}
} catch (e) {
console.error(e);
}
};

async function handleLinkClick(link: string) {
await navigator.clipboard.writeText(link);
toast('Link copied!', {
position: "top-right",
autoClose: 1000,
hideProgressBar: true,
closeOnClick: true,
pauseOnHover: true,
draggable: false,
progress: undefined,
theme: "light",
transition: Bounce,
});
}

return (
<ConfigProvider
theme={{
Expand All @@ -100,7 +120,7 @@ const ChatApp: React.FC = () => {
>
<Layout
style={{
width: '40%',
width: '100%',
height: '100vh',
margin: '0 auto',
display: 'flex',
Expand Down Expand Up @@ -189,6 +209,9 @@ const ChatApp: React.FC = () => {
<React.Fragment key={linkIndex}>
<br />
<AntLink
onClick={async () => {
await handleLinkClick(link)
}}
href={link}
target="_blank"
rel="noopener noreferrer"
Expand Down