denver comp

This commit is contained in:
Evan Lanham
2022-04-02 17:13:50 -06:00
parent 0659a9736e
commit d238d52a4f
21 changed files with 241 additions and 61 deletions
+6 -5
View File
@@ -33,6 +33,7 @@ const InputPage = () => {
.put({
// _id: new Date().toISOString(),
_id: "match_" + values.match_number + "_team_" + values.team_number,
type: "match",
...values,
})
.then((result) => {
@@ -40,7 +41,7 @@ const InputPage = () => {
console.log(result);
console.log(localdb);
localdb.replicate.to(remotedb, {
live: true,
retry: true,
});
})
.catch((err) => {
@@ -48,7 +49,7 @@ const InputPage = () => {
alert(err);
});
// alert(JSON.stringify(values, null, 2));
// resetForm(); //Hah tobad
resetForm(); //Hah tobad
setSubmitting(false);
// }, 400);
updateProcessedDataBucket(localdb, setProcessedDataBucket);
@@ -76,7 +77,7 @@ const InputPage = () => {
lower_hub_auto: "0",
upper_hub_teleop: "0",
lower_hub_teleop: "0",
climb_level: "",
climb_level: "0",
alliance: "",
defence: "0",
disabled: false,
@@ -148,12 +149,12 @@ const InputPage = () => {
</Box>
<Box sx={{ ...panel_sx, display: "flex", flexDirection: "column" }}>
<h2>What they _______</h2>
{/* <h2>What they _______</h2>
<Box sx={{ display: "flex", flexDirection: "row", gap: 2, p: 0, m: 0 }}>
<FastField type="input" as={TextField} multiline rows={3} name="team_abilities_well" label="did well" />
<FastField type="input" as={TextField} multiline rows={3} name="team_abilities_struggle" label="struggled with" />
<FastField type="input" as={TextField} multiline rows={3} name="team_abilities_cant" label="can't do" />
</Box>
</Box> */}
<Button type="submit" disabled={isSubmitting}>
Submit
</Button>
+13
View File
@@ -0,0 +1,13 @@
.maxwidth {
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
text-align: center;
margin: auto;
max-width: fit-content;
/* max-width: 100% */
}
.smallfeild {
max-width: 25%;
}
+101
View File
@@ -0,0 +1,101 @@
import React, { useCallback } from "react";
import { useLocalDb, useRemoteDb } from "../DbContext";
import "./NotesPage.css";
import { Formik, FastField, Form, useFormikContext } from "formik";
import { TextField, Button, Grid, FormRow, Divider, Checkbox, Radio, FormControlLabel, FormControl, FormLabel, RadioGroup, IconButton, NotesAdornment, Box } from "@mui/material";
import { useProcessedDataBucket } from "../ProcessedDataBucketContext";
import { getProcessedDataBucket, updateProcessedDataBucket } from "../ProcessedDataBucket";
import NotesList from "../components/NotesList";
const NotesPage = () => {
let { localdb, setLocaldb } = useLocalDb();
let { remotedb, setRemotedb } = useRemoteDb();
const { processedDataBucket, setProcessedDataBucket } = useProcessedDataBucket();
let panel_sx = {
display: "flex",
flexDirection: "column",
alignItems: { xs: "center", sm: "center" },
justifyContent: { xs: "flex-start", sm: "center" },
bgcolor: "background.paper",
p: 2,
m: 1,
gap: 2,
maxWidth: "fit-content",
borderRadius: "10px",
boxShadow: 7,
};
const onSubmit = useCallback(
(values, { setSubmitting, resetForm }) => {
// setTimeout(() => {
localdb
.put({
// _id: new Date().toISOString(),
_id: "notes_team_" + values.team_number + (new Date().toISOString()),
type: "notes",
...values,
})
.then((result) => {
alert("Notes Saved Successfully!");
console.log(result);
console.log(localdb);
localdb.replicate.to(remotedb, {
retry: true,
});
})
.catch((err) => {
console.log("Failed To Save Notes!");
alert(err);
});
// alert(JSON.stringify(values, null, 2));
resetForm(); //Hah tobad
setSubmitting(false);
// }, 400);
updateProcessedDataBucket(localdb, setProcessedDataBucket);
},
[localdb, remotedb, setProcessedDataBucket, updateProcessedDataBucket]
);
return (
<div>
<br />
<Formik
initialValues={{
team_number: "",
notes: ""
}}
validateOnChange="false"
onSubmit={onSubmit}
>
{({ values, setValues, errors, touched, handleChange, handleBlur, handleSubmit, isSubmitting }) => (
<Form>
<Box sx={{ display: "flex", flexDirection: "column", alignItems: "center" }}>
{/* <Box sx={{ display: "flex", flexDirection: "row", gap: 2, p: 0, m: 0 }}> */}
{/* <Box sx={{...panel_sx, flexDirection: "column"}} fullWidth> */}
<Box sx={panel_sx} >
<FastField type="input" as={TextField} name="team_number" label="Team #" />
<FastField type="input" as={TextField} multiline rows={3} name="notes" label="Notes" />
<Button type="submit" disabled={isSubmitting}>
Submit
</Button>
</Box>
<Box sx={panel_sx} >
<NotesList/>
{/* {
processedDataBucket[] .map((item, index)=>{
return <h1 key={index}>{item}</h1>
})
} */}
</Box>
</Box>
<div />
</Form>
)}
</Formik>
</div>
);
};
export default NotesPage;
+1 -1
View File
@@ -2,7 +2,7 @@ import React from "react";
import "./WelcomePage.css";
import "../App.css";
import DbChooser from "../components/DbChooser";
import { Box } from "@mui/material";
import { Box, Button } from "@mui/material";
const WelcomePage = () => {
return (