-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from MO-RISE/radar-two-out
Radar two out
- Loading branch information
Showing
8 changed files
with
353 additions
and
393 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
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,59 @@ | ||
import React from "react" | ||
import { useFormik } from "formik" | ||
import * as yup from "yup" | ||
import { Grid, TextField, Stack, Button } from "@mui/material" | ||
import { useRecoilState } from "recoil" | ||
import { AtomOSRadarSetting } from "../../../recoil/atoms" | ||
|
||
const validationSchema = yup.object({ | ||
range_change: yup.number().required("Required"), | ||
}) | ||
|
||
|
||
export default function RadarOSRangeChange() { | ||
const [OSRadarRangeChange, setShoreRadarRangeChange] = useRecoilState(AtomOSRadarSetting) | ||
|
||
const formik = useFormik({ | ||
validationSchema: validationSchema, | ||
initialValues: OSRadarRangeChange, | ||
|
||
onChange: values => { | ||
onFormChange(values) | ||
}, | ||
onSubmit: values => { | ||
onFormSubmit(values) | ||
}, | ||
}) | ||
|
||
const onFormChange = values => { | ||
console.log("Change", values) | ||
setShoreRadarRangeChange( values) | ||
} | ||
|
||
const onFormSubmit = values => { | ||
console.log("Submit", values) | ||
setShoreRadarRangeChange(values) | ||
} | ||
|
||
return ( | ||
<div> | ||
<form onSubmit={formik.handleSubmit}> | ||
<TextField | ||
sx={{width: "6rem"}} | ||
id="range_change" | ||
label="Shore Range Change " | ||
type="number" | ||
variant="filled" | ||
size="small" | ||
defaultValue={formik.values.range_change} | ||
onChange={formik.handleChange} | ||
error={formik.touched.range_change && Boolean(formik.errors.range_change)} | ||
helperText={formik.touched.range_change && formik.errors.range_change} | ||
/> | ||
<Button type="submit" variant="contained" color="success" sx={{ marginTop: "0.4rem" }}> | ||
Submit | ||
</Button> | ||
</form> | ||
</div> | ||
) | ||
} |
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,62 @@ | ||
import React from "react" | ||
import { useFormik } from "formik" | ||
import * as yup from "yup" | ||
import { Grid, TextField, Stack, Button } from "@mui/material" | ||
import { useRecoilState } from "recoil" | ||
import { AtomShoreRadarSetting } from "../../../recoil/atoms" | ||
|
||
const validationSchema = yup.object({ | ||
range_change: yup.number().required("Required"), | ||
}) | ||
|
||
const initFormValuesManual = { | ||
range_change: 500, | ||
} | ||
|
||
export default function RadarRangeChange() { | ||
const [shoreRadarRangeChange, setShoreRadarRangeChange] = useRecoilState(AtomShoreRadarSetting) | ||
|
||
const formik = useFormik({ | ||
validationSchema: validationSchema, | ||
initialValues: shoreRadarRangeChange, | ||
|
||
onChange: values => { | ||
onFormChange(values) | ||
}, | ||
onSubmit: values => { | ||
onFormSubmit(values) | ||
}, | ||
}) | ||
|
||
const onFormChange = values => { | ||
console.log("Change", values) | ||
setShoreRadarRangeChange( values) | ||
} | ||
|
||
const onFormSubmit = values => { | ||
console.log("Submit", values) | ||
setShoreRadarRangeChange(values) | ||
} | ||
|
||
return ( | ||
<div> | ||
<form onSubmit={formik.handleSubmit}> | ||
<TextField | ||
sx={{width: "6rem"}} | ||
id="range_change" | ||
label="Shore Range Change " | ||
type="number" | ||
variant="filled" | ||
size="small" | ||
defaultValue={formik.values.range_change} | ||
onChange={formik.handleChange} | ||
error={formik.touched.range_change && Boolean(formik.errors.range_change)} | ||
helperText={formik.touched.range_change && formik.errors.range_change} | ||
/> | ||
<Button type="submit" variant="contained" color="success" sx={{ marginTop: "0.4rem" }}> | ||
Submit | ||
</Button> | ||
</form> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.