Skip to content

Commit

Permalink
fix(validation): remove buggy OPAL validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jusa3 committed May 13, 2024
1 parent ccac778 commit 6049c24
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions frontend/src/components/import/ImportExcel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,43 +44,43 @@ export default (props: {
}).then((res) => res.json());
});

const {
data: columnCheck,
mutate: checkColumns,
isSuccess: isSuccessColumnCheck,
isLoading: isLoadingColumnCheck,
isError: isErrorColumnCheck
} = useMutation(() => {
const file = new FormData();
file.append("file", props.files);
return fetch(`/api/instrument/columnCheck`, {
method: "POST",
body: file,
}).then((res) => res.json());
});
// const {
// data: columnCheck,
// mutate: checkColumns,
// isSuccess: isSuccessColumnCheck,
// isLoading: isLoadingColumnCheck,
// isError: isErrorColumnCheck
// } = useMutation(() => {
// const file = new FormData();
// file.append("file", props.files);
// return fetch(`/api/instrument/columnCheck`, {
// method: "POST",
// body: file,
// }).then((res) => res.json());
// });

const pick = () => {
if (props.hasFile) {
get_columns();
}
};

const check_columns = () => {
if (props.hasFile) {
checkColumns();
}
};

const displayColumnCheck = (item: any) => {
return (
item ?
item.length > 1 ?
item.map((element: string, i: any) =>
<dd key={i}>{element}</dd>)
: item
: "-"
)
}
// const check_columns = () => {
// if (props.hasFile) {
// checkColumns();
// }
// };
//
// const displayColumnCheck = (item: any) => {
// return (
// item ?
// item.length > 1 ?
// item.map((element: string, i: any) =>
// <dd key={i}>{element}</dd>)
// : item
// : "-"
// )
// }

return (
<>
Expand Down Expand Up @@ -126,7 +126,7 @@ export default (props: {
<EuiButton
onClick={() => {
pick();
check_columns()
// check_columns()
}}
isDisabled={!props.hasFile}
>
Expand All @@ -137,14 +137,14 @@ export default (props: {
{isError &&
<EuiTextColor color="danger">The file could not be validated. Try again, use another format
or report via the blue feedback button.</EuiTextColor>}
{isLoadingColumnCheck && <EuiLoadingSpinner/>}
{/*{isLoadingColumnCheck && <EuiLoadingSpinner/>}*/}

{columnCheck && columnCheck.length == 0 &&
<EuiTextColor color="success">OPAL format validated</EuiTextColor>
}
{columnCheck && columnCheck.length != 0 &&
<EuiTextColor color="danger">The following columns are required for the OPAL
format: {displayColumnCheck(columnCheck)}</EuiTextColor>}
{/*{columnCheck && columnCheck.length == 0 &&*/}
{/* <EuiTextColor color="success">OPAL format validated</EuiTextColor>*/}
{/*}*/}
{/*{columnCheck && columnCheck.length != 0 &&*/}
{/* <EuiTextColor color="danger">The following columns are required for the OPAL*/}
{/* format: {displayColumnCheck(columnCheck)}</EuiTextColor>}*/}
</>
</EuiFormRow>
</EuiDescribedFormGroup>
Expand Down

0 comments on commit 6049c24

Please sign in to comment.