CollapsedFilters.jsx 1.62 KB
Newer Older
1
import React from "react";
2
import { Chip } from "@material-ui/core";
3
4
import { useStyles } from "../../styles";
import { useTranslation } from "react-i18next";
5
6
7


export const CollapsedFilters = (props) => {
8
    const { input } = props;
9

10
11
12
    const { t, i18n } = useTranslation();

    const classes = useStyles();
13
14

    return (
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
        <>
            {/*Chip for mode*/}
            <Chip label={input.mode === "archaeoSites"
                ? "Archaeological Sites"
                : "Objects"}
            />

            {/*Chip for for string query*/}
            {input.searchStr !== ""
            && <Chip variant="outlined" label={`Search term: ${input.searchStr}`}/>}

            {/*Chip for filter by period*/}
            {input.chronOntologyTerm !== null
            && <Chip variant="outlined" label={`Chronontology term: ${input.chronOntologyTerm}`}/>}

            {/*Chip for filter by region*/}
            {input.sitesMode === "region" && input.regionTitle !== null
            && <Chip variant="outlined"
                     label={`Region: ${input.regionTitle}`}
            />}

            {/*Chip for filter by coordinates*/}
            {(/-?\d{1,2}\.\d+,-?\d{1,3}\.\d+/.test(input.boundingBoxCorner1) && (/-?\d{1,2}\.\d+,-?\d{1,3}\.\d+/.test(input.boundingBoxCorner2)))
            && <Chip variant="outlined"
                     label={`Bounding box: [${input.boundingBoxCorner1}], [${input.boundingBoxCorner2}]`}/>}

            {/*Chip for filter by catalogs*/}
            {input.checkedCatalogLabels.length !== 0
            && <Chip variant="outlined" label={`Catalog: ${input.checkedCatalogLabels}`}/>}
        </>
    );
46
};