Skip to content

Commit

Permalink
Fix build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
eatyourgreens committed Feb 28, 2024
1 parent a2f798d commit bc300cf
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 39 deletions.
9 changes: 4 additions & 5 deletions frontend-v2/src/features/data/LoadData.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Alert, Box, Stack, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@mui/material';
import Papa, { ParseError, ParseMeta } from 'papaparse'
import { Alert, Box, Stack } from '@mui/material';
import Papa from 'papaparse'
import { FC, useCallback, useState} from 'react'
import {useDropzone} from 'react-dropzone'
import MapHeaders from './MapHeaders';
import { manditoryHeaders, normaliseHeader, normalisedHeaders } from './normaliseDataHeaders';
import { manditoryHeaders, normaliseHeader } from './normaliseDataHeaders';
import { StepperState } from './LoadDataStepper';

export type Row = {[key: string]: string};
Expand Down Expand Up @@ -62,7 +62,6 @@ const LoadData: FC<ILoadDataProps> = ({state, firstTime}) => {
// Parse the CSV data
const rawCsv = reader.result as string;
const csvData = Papa.parse(rawCsv.trim(), { header: true });
const data = csvData.data as Data;
const fields = csvData.meta.fields || [];
const normalisedFields = fields.map(normaliseHeader);
const errors = csvData.errors.map((e) => e.message).concat(validateNormalisedFields(normalisedFields));
Expand All @@ -77,7 +76,7 @@ const LoadData: FC<ILoadDataProps> = ({state, firstTime}) => {
reader.readAsText(file)
})

}, [])
}, [state])
const {getRootProps, getInputProps} = useDropzone({onDrop})

const setNormalisedFields = (fields: Field[]) => {
Expand Down
4 changes: 2 additions & 2 deletions frontend-v2/src/features/data/LoadDataStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const LoadDataStepper: FC = () => {
if (!isDatasetLoading) {
addDataset();
}
}, [datasets, isDatasetLoading]);
}, [datasets, createDataset, isDatasetLoading]);

useEffect(function onFinished() {
if (isFinished && dataset?.id) {
Expand All @@ -102,7 +102,7 @@ const LoadDataStepper: FC = () => {
console.error(e);
}
}
}, [isFinished])
}, [isFinished, updateDataset, dataset?.id, data])

const handleNext = () => {
setStepState((prevActiveStep) => ({
Expand Down
14 changes: 2 additions & 12 deletions frontend-v2/src/features/data/LoadDataTab.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import * as React from 'react';
import { useState } from 'react';
import Button from '@mui/material/Button';
import Avatar from '@mui/material/Avatar';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemAvatar from '@mui/material/ListItemAvatar';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemText from '@mui/material/ListItemText';
import DialogTitle from '@mui/material/DialogTitle';
import Dialog from '@mui/material/Dialog';
import PersonIcon from '@mui/icons-material/Person';
import AddIcon from '@mui/icons-material/Add';
import Typography from '@mui/material/Typography';
import { blue } from '@mui/material/colors';
import LoadDataStepper from './LoadDataStepper';
import { DialogContent } from '@mui/material';

Expand All @@ -38,7 +28,7 @@ function LoadDataDialog(props: LoadDataDialogProps) {
}

export default function LoadDataTab() {
const [open, setOpen] = React.useState(false);
const [open, setOpen] = useState(false);

const handleClickOpen = () => {
setOpen(true);
Expand Down
29 changes: 20 additions & 9 deletions frontend-v2/src/features/data/MapDosing.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import { FC } from 'react';
import { Box, Select, FormControl, MenuItem, InputLabel, Stack, Table, TableHead, TableRow, TableCell, TableBody, Typography, SelectChangeEvent } from "@mui/material";
import { Field, Data } from "./LoadData";
import {
Box,
Select,
FormControl,
MenuItem,
InputLabel,
Table,
TableHead,
TableRow,
TableCell,
TableBody,
Typography,
SelectChangeEvent
} from "@mui/material";
import { StepperState } from "./LoadDataStepper";
import { useSelector } from "react-redux";
import { RootState } from "../../app/store";
Expand All @@ -16,24 +28,24 @@ interface IMapDosing {
state: StepperState;
firstTime: boolean;
}
const MapDosing: FC<IMapDosing> = ({state, firstTime}: IMapDosing) => {

const MapDosing: FC<IMapDosing> = ({ state, firstTime }: IMapDosing) => {
const projectId = useSelector(
(state: RootState) => state.main.selectedProject,
);
const projectIdOrZero = projectId || 0;
const { data: project, isLoading: isProjectLoading } =
const { data: project } =
useProjectRetrieveQuery({ id: projectId || 0 }, { skip: !projectId });
const { data: models = [], isLoading: isModelsLoading } =
const { data: models = [] } =
useCombinedModelListQuery(
{ projectId: projectIdOrZero },
{ skip: !projectId },
);
const { data: units, isLoading: isLoadingUnits } = useUnitListQuery(
const { data: units } = useUnitListQuery(
{ compoundId: project?.compound },
{ skip: !project || !project.compound },
);
const [ model ] = models;
const [model] = models;
const { data: variables } = useVariableListQuery(
{ dosedPkModelId: model?.id || 0 },
{ skip: !model?.id },
Expand Down Expand Up @@ -200,4 +212,3 @@ const MapDosing: FC<IMapDosing> = ({state, firstTime}: IMapDosing) => {

export default MapDosing;


7 changes: 4 additions & 3 deletions frontend-v2/src/features/data/MapHeaders.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TableContainer, Table, TableHead, TableRow, TableCell, TableBody, Select, FormControl, MenuItem, InputLabel, Typography } from "@mui/material";
import LoadData, { Data, Field } from "./LoadData";
import { FC } from "react";
import { Table, TableHead, TableRow, TableCell, TableBody, Select, FormControl, MenuItem, InputLabel, Typography } from "@mui/material";
import { Data, Field } from "./LoadData";
import { normalisedHeaders } from "./normaliseDataHeaders";

interface IMapHeaders {
Expand All @@ -9,7 +10,7 @@ interface IMapHeaders {
setNormalisedFields: (fields: Field[]) => void;
}

const MapHeaders: React.FC<IMapHeaders> = ({data, fields, normalisedFields, setNormalisedFields}: IMapHeaders) => {
const MapHeaders: FC<IMapHeaders> = ({data, fields, normalisedFields, setNormalisedFields}: IMapHeaders) => {

const normalisedHeadersOptions = normalisedHeaders.map((header) => ({value: header, label: header}));

Expand Down
13 changes: 6 additions & 7 deletions frontend-v2/src/features/data/MapObservations.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FC } from 'react';
import { Box, Select, FormControl, MenuItem, InputLabel, Stack, Table, TableHead, TableRow, TableCell, TableBody, Typography, SelectChangeEvent } from "@mui/material";
import { Field, Data } from "./LoadData";
import { Box, Select, FormControl, MenuItem, InputLabel, Table, TableHead, TableRow, TableCell, TableBody, Typography, SelectChangeEvent } from "@mui/material";
import { StepperState } from "./LoadDataStepper";
import { useSelector } from "react-redux";
import { RootState } from "../../app/store";
Expand All @@ -16,14 +15,14 @@ interface IMapObservations {
firstTime: boolean;
}

const MapObservations: FC<IMapObservations> = ({state, firstTime}: IMapObservations) => {
const MapObservations: FC<IMapObservations> = ({state}: IMapObservations) => {
const projectId = useSelector(
(state: RootState) => state.main.selectedProject,
);
const projectIdOrZero = projectId || 0;
const { data: project, isLoading: isProjectLoading } =
const { data: project } =
useProjectRetrieveQuery({ id: projectId || 0 }, { skip: !projectId });
const { data: models = [], isLoading: isModelsLoading } =
const { data: models = [] } =
useCombinedModelListQuery(
{ projectId: projectIdOrZero },
{ skip: !projectId },
Expand All @@ -33,7 +32,7 @@ const MapObservations: FC<IMapObservations> = ({state, firstTime}: IMapObservati
{ dosedPkModelId: model?.id || 0 },
{ skip: !model?.id },
);
const { data: units, isLoading: isLoadingUnits } = useUnitListQuery(
const { data: units } = useUnitListQuery(
{ compoundId: project?.compound },
{ skip: !project || !project.compound },
);
Expand Down Expand Up @@ -114,7 +113,7 @@ const MapObservations: FC<IMapObservations> = ({state, firstTime}: IMapObservati
</TableRow>
</TableHead>
<TableBody>
{uniqueObservationIds.map((obsId, index) => {
{uniqueObservationIds.map((obsId) => {
const currentRow = state.data.find(row => observationIdField ? row[observationIdField] === obsId : true);
const selectedVariable = variables?.find(variable => variable.qname === currentRow?.['Observation Variable']);
const compatibleUnits = units?.find(unit => unit.id === selectedVariable?.unit)?.compatible_units;
Expand Down
1 change: 0 additions & 1 deletion frontend-v2/src/features/data/PreviewData.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FC } from 'react';
import { Box, Table, TableHead, TableRow, TableCell, TableBody, Typography } from "@mui/material";
import LoadData, { Data, Field } from "./LoadData";
import { StepperState } from "./LoadDataStepper";

interface IPreviewData {
Expand Down

0 comments on commit bc300cf

Please sign in to comment.