diff --git a/public/index.html b/public/index.html index e4f3981..446d4b8 100644 --- a/public/index.html +++ b/public/index.html @@ -1,29 +1,26 @@ - - - + + + - - - - - - + + + + + + ShowIt - - - -
- + + + +
+ diff --git a/src/assets/no_data.svg b/src/assets/no_data.svg new file mode 100644 index 0000000..370ef77 --- /dev/null +++ b/src/assets/no_data.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/EmptyTerm.tsx b/src/components/EmptyTerm.tsx new file mode 100644 index 0000000..c034c76 --- /dev/null +++ b/src/components/EmptyTerm.tsx @@ -0,0 +1,17 @@ +import React from "react"; +import { Box, Typography } from "@mui/material"; +import { ReactComponent as NoData } from "../assets/no_data.svg"; + +const EmptyTerm: React.FC = () => { + return ( + + + + + Víc informací bohužel není k dispozici + + + + ); +}; +export default EmptyTerm; diff --git a/src/components/Hierarchy.tsx b/src/components/Hierarchy.tsx index e822ef6..7e8ede9 100644 --- a/src/components/Hierarchy.tsx +++ b/src/components/Hierarchy.tsx @@ -19,7 +19,7 @@ export const Hierarchy: React.FC = ({ term }) => { const currIndex = term.parentTerms ? 1 : 0; return ( - + Související pojmy diff --git a/src/components/TermPage.tsx b/src/components/TermPage.tsx index 16edd01..db1a329 100644 --- a/src/components/TermPage.tsx +++ b/src/components/TermPage.tsx @@ -8,6 +8,8 @@ import { Hierarchy } from "./Hierarchy"; import useURLTerm from "../hooks/useURLTerm"; import Loader from "./Loader"; import ErrorPage from "./ErrorPage"; +import EmptyTerm from "./EmptyTerm"; +import { isTermEmpty } from "../utils/TermUtils"; const TermPage: React.FC = () => { const term = useURLTerm(); @@ -18,15 +20,22 @@ const TermPage: React.FC = () => { if (isError || !data) return ; if (isSuccess) { - return ( - - + const content = isTermEmpty(data) ? ( + + ) : ( + <> + + ); + return ( + + + {content} ); } + return ; }; - export default TermPage; diff --git a/src/utils/TermUtils.ts b/src/utils/TermUtils.ts new file mode 100644 index 0000000..8b1678a --- /dev/null +++ b/src/utils/TermUtils.ts @@ -0,0 +1,11 @@ +import { TermInterface } from "../api/data/terms"; + +//Checks whether term consists only of information which is displayed in the header (TermPage) +export const isTermEmpty = (term: TermInterface) => { + return ( + !term.parentTerms.length && + !term.subTerms.length && + !term.definition && + !term.source + ); +};