Skip to content

Commit

Permalink
update for backend
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILIPP111007 committed Apr 12, 2024
1 parent 9689dc9 commit a067c65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
6 changes: 1 addition & 5 deletions frontend/src/pages/PredictDay/PredictDay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ export default function PredictDay() {
var [predict, setPredict] = useState(undefined)

async function getPredict(date) {
var body = { date: date }
var response = await Fetch({ action: "api/v1/predict_day/", method: HttpMethod.POST, body: body })

// TODO: remove
response = { data: 10 }
var response = await Fetch({ action: "api/v1/predict_day/", method: HttpMethod.POST, body: date })

if (response && response.data) {
setError("")
Expand Down
13 changes: 7 additions & 6 deletions frontend/src/pages/PredictDay/components/PredictForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function PredictForm({ getPredict, error, setError, success, setS

async function callFunc(event) {
await event.preventDefault()

if (form.CAPITALIZATION && form.CLOSE && form.DIVISOR && form.HIGH && form.LOW && form.OPEN && form.TRADEDATE && form.finance && form.economic && form.politic) {
setError("")
return await getPredict(form)
Expand Down Expand Up @@ -66,7 +67,7 @@ export default function PredictForm({ getPredict, error, setError, success, setS
type="number"
step="0.01"
placeholder="CAPITALIZATION"
onChange={e => setForm({ ...form, CAPITALIZATION: e.target.value })}
onChange={e => setForm({ ...form, CAPITALIZATION: Number.parseFloat(e.target.value) })}
/>
</FloatingLabel>
</Col>
Expand All @@ -76,7 +77,7 @@ export default function PredictForm({ getPredict, error, setError, success, setS
type="number"
step="0.01"
placeholder="OPEN"
onChange={e => setForm({ ...form, OPEN: e.target.value })}
onChange={e => setForm({ ...form, OPEN: Number.parseFloat(e.target.value) })}
/>
</FloatingLabel>
</Col>
Expand All @@ -86,7 +87,7 @@ export default function PredictForm({ getPredict, error, setError, success, setS
type="number"
step="0.01"
placeholder="CLOSE"
onChange={e => setForm({ ...form, CLOSE: e.target.value })}
onChange={e => setForm({ ...form, CLOSE: Number.parseFloat(e.target.value) })}
/>
</FloatingLabel>
</Col>
Expand All @@ -99,7 +100,7 @@ export default function PredictForm({ getPredict, error, setError, success, setS
type="number"
step="0.01"
placeholder="HIGH"
onChange={e => setForm({ ...form, HIGH: e.target.value })}
onChange={e => setForm({ ...form, HIGH: Number.parseFloat(e.target.value) })}
/>
</FloatingLabel>
</Col>
Expand All @@ -109,7 +110,7 @@ export default function PredictForm({ getPredict, error, setError, success, setS
type="number"
step="0.01"
placeholder="LOW"
onChange={e => setForm({ ...form, LOW: e.target.value })}
onChange={e => setForm({ ...form, LOW: Number.parseFloat(e.target.value) })}
/>
</FloatingLabel>
</Col>
Expand All @@ -122,7 +123,7 @@ export default function PredictForm({ getPredict, error, setError, success, setS
type="number"
step="0.01"
placeholder="DIVISOR"
onChange={e => setForm({ ...form, DIVISOR: e.target.value })}
onChange={e => setForm({ ...form, DIVISOR: Number.parseFloat(e.target.value) })}
/>
</FloatingLabel>
</Col>
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/pages/PredictInterval/PredictInterval.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ export default function PredictInterval() {
var body = { date: date }
var response = await Fetch({ action: "api/v1/predict_interval/", method: HttpMethod.POST, body: body })

// TODO: remove
response = {
data: {
dates: ["2020-01-01", "2020-01-02", "2020-01-03", "2020-01-04", "2020-01-05", "2020-01-06"],
x: [1, 2, 3, 4, 5, 6],
y_pred: [1.8, 2.6, 3, 1, 2, 3],
y_true: [2, 3]
}
}

if (response && response.data) {
setError("")
setSuccess(true)
Expand Down

0 comments on commit a067c65

Please sign in to comment.