-
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.
Implemented submit form functionality. TODO: Send axios client POST r…
…equest to REST API.
- Loading branch information
Breno Tostes
committed
Nov 18, 2023
1 parent
0a44381
commit da9b7de
Showing
3 changed files
with
81 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,56 @@ | ||
// REST API "/api/tunnels/tunnel/" endpoint expects | ||
// POST form data as: | ||
// | ||
// { | ||
// "userId": "[email protected]", | ||
// "assetId": "SYMBOL.NAME", | ||
// "lowerVal": 0.00, | ||
// "upperVal": 0.00, | ||
// "interval": 0 | ||
// } | ||
// | ||
// Check "/api/docs/" endpoint for more details. | ||
// ######################################################## | ||
|
||
import React from 'react'; | ||
|
||
import Form from 'react-bootstrap/Form'; | ||
import InputGroup from 'react-bootstrap/InputGroup'; | ||
|
||
const NewTunnelForm = ({ticker, onChange}) => { | ||
const NewTunnelForm = ({ticker, index, formData, setFormData}) => { | ||
|
||
function handleChange(index, field, value) { | ||
const updatedFormData = [...formData]; | ||
updatedFormData[index][field] = value; | ||
setFormData(updatedFormData); | ||
} | ||
|
||
return ( | ||
<> | ||
<Form.Label>{ticker}</Form.Label> | ||
<InputGroup className="mb-3"> | ||
<InputGroup.Text>Lower Threshold</InputGroup.Text> | ||
<Form.Control aria-label="Lower Threshold" type='number'/> | ||
<Form.Control | ||
aria-label="Lower Threshold" | ||
placeholder='0.00' | ||
type='number' | ||
onChange={e => handleChange(index, 'lowerVal', e.target.value)} | ||
/> | ||
<InputGroup.Text>Upper Threshold</InputGroup.Text> | ||
<Form.Control aria-label="Upper Threshold" type='number'/> | ||
<Form.Control | ||
aria-label="Upper Threshold" | ||
placeholder='0.00' | ||
type='number' | ||
onChange={e => handleChange(index, 'upperVal', e.target.value)} | ||
/> | ||
<br/> | ||
<InputGroup.Text>Periodicity</InputGroup.Text> | ||
<Form.Control aria-label='Periodicity' type='number' max={720}/> | ||
<Form.Control | ||
aria-label='Periodicity' | ||
type='number' | ||
max={720} | ||
onChange={e => handleChange(index, 'interval', e.target.value)} | ||
/> | ||
</InputGroup> | ||
</> | ||
) | ||
|
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