-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
649 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
REACT_APP_BASE_URL=http://127.0.0.1:8000 | ||
axios.defaults.baseURL = process.env.REACT_APP_BASE_URL; | ||
REACT_APP_BASE_URL=http://127.0.0.1:8000/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare module 'black-scholes'; | ||
declare module '*'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
interface MessageData { | ||
message: string; | ||
} | ||
|
||
function WebSocketComponent() { | ||
const [socket, setSocket] = useState<WebSocket | null>(null); | ||
const [error, setError] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
const socketInstance = new WebSocket('ws://localhost:8000/ws/tradepodapi/'); | ||
|
||
socketInstance.onopen = function(e) { | ||
console.log('Connection established successfully'); | ||
}; | ||
|
||
socketInstance.onerror = function(e) { | ||
console.error('Error connecting to WebSocket'); | ||
setError('Error connecting to WebSocket'); | ||
}; | ||
|
||
socketInstance.onmessage = function(e) { | ||
const data: MessageData = JSON.parse(e.data); | ||
console.log(data.message); | ||
}; | ||
|
||
socketInstance.onclose = function(e) { | ||
console.error('Chat socket closed unexpectedly'); | ||
}; | ||
|
||
setSocket(socketInstance); | ||
|
||
return () => { | ||
if (socket) { | ||
socket.close(); | ||
} | ||
}; | ||
}, [socket]); | ||
|
||
const sendMessage = () => { | ||
if (socket && !error) { | ||
socket.send(JSON.stringify({ | ||
'message': 'Hello, world!' | ||
})); | ||
} | ||
}; | ||
|
||
if (error) { | ||
return <div>Error: {error}</div>; | ||
} | ||
|
||
return ( | ||
<div> | ||
<button onClick={sendMessage}>Send Message</button> | ||
</div> | ||
); | ||
} | ||
|
||
export default WebSocketComponent; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
7bb3943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
tradepod – ./
tradepod-suyeshs.vercel.app
tradepod-git-master-suyeshs.vercel.app
tradepod.vercel.app