Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Console warnings" #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion src/components/ArrowedPopper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
import { Popper, Fade, Paper } from "@mui/material";
import { Popper, Fade, Paper, Box, styled } from "@mui/material";
import { useState } from "react";

const StyledPopper = styled(Popper)(({ theme }) => ({
// You can replace with `PopperUnstyled` for lower bundle size.
'&[data-popper-placement*="bottom"] .arrow': {
top: 0,
left: 0,
marginTop: "-0.9em",
width: "3em",
height: "1em",
"&::before": {
borderWidth: "0 1em 1em 1em",
borderColor: `transparent transparent ${theme.palette.background.paper} transparent`,
},
},
'&[data-popper-placement*="top"] .arrow': {
bottom: 0,
left: 0,
marginBottom: "-0.9em",
width: "3em",
height: "1em",
"&::before": {
borderWidth: "1em 1em 0 1em",
borderColor: `${theme.palette.background.paper} transparent transparent transparent`,
},
},
'&[data-popper-placement*="right"] .arrow': {
left: 0,
marginLeft: "-0.9em",
height: "3em",
width: "1em",
"&::before": {
borderWidth: "1em 1em 1em 0",
borderColor: `transparent ${theme.palette.background.paper} transparent transparent`,
},
},
'&[data-popper-placement*="left"] .arrow': {
right: 0,
marginRight: "-0.9em",
height: "3em",
width: "1em",
"&::before": {
borderWidth: "1em 0 1em 1em",
borderColor: `transparent transparent transparent ${theme.palette.background.paper}`,
},
},
}));

function ArrowedPopper({ anchorEl, open, placement, children }) {
const [arrowRef, setArrowRef] = useState(null);

return (
<Popper
elevation={8}
Expand Down Expand Up @@ -33,6 +82,9 @@ function ArrowedPopper({ anchorEl, open, placement, children }) {
{
name: "arrow",
enabled: false,
options: {
element: arrowRef,
},
},
]}
>
Expand All @@ -41,6 +93,25 @@ function ArrowedPopper({ anchorEl, open, placement, children }) {
<Paper elevation={8} sx={{ p: 2 }}>
{children}
</Paper>
{/* <Box
component="span"
className="arrow"
ref={setArrowRef}
style={{
position: "absolute",
fontSize: 7,
width: "3em",
height: "3em",
"&::before": {
content: '""',
margin: "auto",
display: "block",
width: 0,
height: 0,
borderStyle: "solid",
},
}}
/> */}
</Fade>
)}
</Popper>
Expand Down
6 changes: 5 additions & 1 deletion src/components/MakeMeJSON.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useState } from "react";
import DragDrop from "./DragDrop";
import { Paper } from "@mui/material";
import { useHistory } from "react-router-dom";
import InlineFeedback from "./InlineFeedback";
import { ToastContainer } from "react-toastify";
import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import pdfTableExtractor from "../utilities/pdf-table-extractor";

Expand All @@ -13,8 +14,11 @@ export default function MakeMeJSON({
existingInstruments,
ReactGA,
}) {
const [loading, setLoading] = useState(false);
const [parseError, setParseError] = useState(false);
const [matchError, setMatchError] = useState(false);
const [grouping, setGrouping] = useState("");
const history = useHistory();

function saveFile(blob, filename) {
if (window.navigator.msSaveOrOpenBlob) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ResultsOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function ResultsOptions({
setSearchTerm(resultsOptions.searchTerm);
}, [resultsOptions]);

useMemo((resultsOptions, setResultsOptions) => {
useMemo(() => {
let thisOptions = { ...resultsOptions };
thisOptions.searchTerm = debouncedSearchTerm;
setResultsOptions(thisOptions);
Expand Down
22 changes: 15 additions & 7 deletions src/components/Upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
AddCircleOutline as AddCircleOutlineIcon,
Delete as DeleteIcon,
ExpandMore as ExpandMoreIcon,
Rowing,
} from "@mui/icons-material";
import { useHistory } from "react-router-dom";
import InlineFeedback from "./InlineFeedback";
Expand All @@ -40,7 +41,7 @@ export default function Upload({
const [loading, setLoading] = useState(false);
const [parseError, setParseError] = useState(false);
const [matchError, setMatchError] = useState(false);
const [grouping] = useState("");
const [grouping, setGrouping] = useState("");
const [expanded, setExpanded] = useState(false);
const dirty = useRef(false);
const localFileInfos = useRef();
Expand All @@ -61,11 +62,20 @@ export default function Upload({
localFileInfos.current = fi;
}, []);

const syncFileInfos = useCallback((setAppFileInfos) => {
const syncFileInfos = useCallback(() => {
console.log("syncing fileinfo");
setAppFileInfos(localFileInfos.current);
dirty.current = false;
}, []);
});

const getFileInfo = useCallback(
(instrument_id) => {
return fileInfos.filter((fi) => {
return fi.instrument_id === instrument_id;
})[0];
},
[fileInfos]
);

function filesReceiver(fileList) {
const files = Array.from(fileList);
Expand Down Expand Up @@ -172,12 +182,10 @@ export default function Upload({
!existingInstrumentIDs.includes(fi.instrument_id)
) {
return fi;
} else {
return null
}
})
.filter((i) => {
return i !== null;
return i;
});

// add in any selected which are not already in there
Expand Down Expand Up @@ -366,7 +374,7 @@ export default function Upload({
const FileInfo = ({ fi }) => {
const instrument_id = fi.instrument_id;
const fileInfo = fi;
const [, rerender] = useState();
const [_, rerender] = useState();
console.log("rendering " + instrument_id + fileInfo.instrument_name);
return (
<Accordion
Expand Down
28 changes: 12 additions & 16 deletions src/contexts/DataContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export function DataProvider({ children }) {
harmonisation.uid = currentUser.uid;
// if docID is specified check it is owned by current user
if (docID) {
const docu = await getDoc(doc(db, "harmonisations", docID));
if (docu.exists() && docu.data.uid !== currentUser.uid) {
const doc = await getDoc(doc(db, "harmonisations", docID));
if (doc.exists() && doc.data.uid != currentUser.uid) {
Promise.reject(Error(`Specified docID is not owned by current user`));
}
harmonisation.updated = serverTimestamp();
Expand Down Expand Up @@ -117,28 +117,24 @@ export function DataProvider({ children }) {
return addDoc(collection(db, "mismatches"), m);
};
const prepForFireStore = (harmonisation) => {
harmonisation.apiData.instruments.map((instrument) => (
instrument.questions.map((question) => (
harmonisation.apiData.instruments.map((instrument) => {
instrument.questions.map((question) => {
//This is a circular reference but can't be stored
delete question["instrument"]
)
)
)
);
delete question["instrument"];
});
});
harmonisation.apiData = JSON.parse(JSON.stringify(harmonisation.apiData));
console.log("prepped");
console.log(harmonisation);
return harmonisation;
};
const undoPrepForFireStore = (harmonisation) => {
harmonisation.apiData.instruments.map((instrument) => (
instrument.questions.map((question) => (
harmonisation.apiData.instruments.map((instrument) => {
instrument.questions.map((question) => {
//This is a circular reference but can't be stored
question["instrument"] = instrument
)
)
)
);
question["instrument"] = instrument;
});
});
console.log("unprepped");
console.log(harmonisation);
return harmonisation;
Expand Down
Loading
Loading