Skip to content

Commit

Permalink
work with date
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILIPP111007 committed Apr 9, 2024
1 parent 697fc65 commit e66c85b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
11 changes: 5 additions & 6 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import "./styles/App.css"
import 'bootstrap/dist/css/bootstrap.min.css'
import "bootstrap/dist/css/bootstrap.min.css"

import { useState } from "react"
import { Button, Row } from 'react-bootstrap'
import { Row } from "react-bootstrap"
import { HttpMethod } from "@data/enums"
import Fetch from "@API/Fetch"
import PredictForm from "components/PredictForm"
Expand All @@ -11,12 +11,11 @@ export default function App() {

var [predict, setPredict] = useState(0)

async function getPredict(event) {
async function getPredict(date) {

event.preventDefault()
console.log(event.target.value)
console.log(date)

var data = await Fetch({ action: `api/predict/`, method: HttpMethod.GET })
var data = await Fetch({ action: "api/v1/predict/", method: HttpMethod.GET })

if (data && data.ok) {
// console.log(data)
Expand Down
13 changes: 7 additions & 6 deletions frontend/src/components/PredictForm.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { useState } from "react"
import { Button, Row, Form, InputGroup } from 'react-bootstrap'
import { HttpMethod } from "@data/enums"
import Fetch from "@API/Fetch"
import { Button, Form, InputGroup } from "react-bootstrap"

export default function PredictForm({ func }) {

var [date, setDate] = useState(undefined)

async function callFunc(event) {
await event.preventDefault()
var date_obj = Date.parse(date)
return await func(date_obj)
}

return (

<>
<Form onSubmit={(e) => func(e)}>
<Form onSubmit={e => callFunc(e)}>
<Form.Group className="mb-3" controlId="formGroupEmail">
<InputGroup className="mb-3">
<Form.Control
Expand All @@ -29,6 +31,5 @@ export default function PredictForm({ func }) {
</Form.Group>
</Form>
</>

)
}

0 comments on commit e66c85b

Please sign in to comment.