|
1 | | -import { Card, Heading, Link, Stack, Text } from "@chakra-ui/react"; |
| 1 | +import { Card, HStack, Icon, Link, Stack, Text } from "@chakra-ui/react"; |
2 | 2 | import type { ReactNode } from "react"; |
| 3 | +import { LuFolderPlus, LuFolderSearch } from "react-icons/lu"; |
3 | 4 | import { MarkdownHooks } from "react-markdown"; |
4 | 5 | import type { StacCatalog, StacCollection } from "stac-ts"; |
5 | 6 | import useStacMap from "../hooks/stac-map"; |
| 7 | +import { CollectionSearch } from "./search/collection"; |
| 8 | +import Section from "./section"; |
| 9 | + |
| 10 | +export function Children({ value }: { value: StacCatalog | StacCollection }) { |
| 11 | + const { catalogs, collections } = useStacMap(); |
| 12 | + const selfHref = value?.links?.find((link) => link.rel === "self")?.href; |
6 | 13 |
|
7 | | -export function Children({ |
8 | | - heading, |
9 | | - children, |
10 | | -}: { |
11 | | - heading: string; |
12 | | - children: ReactNode; |
13 | | -}) { |
14 | 14 | return ( |
15 | | - <Stack> |
16 | | - <Heading size={"md"}>{heading}</Heading> |
17 | | - {children} |
18 | | - </Stack> |
| 15 | + <> |
| 16 | + {collections && collections?.length > 0 && ( |
| 17 | + <Section |
| 18 | + title={ |
| 19 | + <HStack> |
| 20 | + <Icon> |
| 21 | + <LuFolderSearch></LuFolderSearch> |
| 22 | + </Icon>{" "} |
| 23 | + Collection search |
| 24 | + </HStack> |
| 25 | + } |
| 26 | + > |
| 27 | + <CollectionSearch |
| 28 | + href={selfHref} |
| 29 | + collections={collections} |
| 30 | + ></CollectionSearch> |
| 31 | + </Section> |
| 32 | + )} |
| 33 | + |
| 34 | + {catalogs && catalogs.length > 0 && ( |
| 35 | + <Section title="Catalogs"> |
| 36 | + <Stack> |
| 37 | + {catalogs.map((catalog) => ( |
| 38 | + <ChildCard |
| 39 | + child={catalog} |
| 40 | + key={"catalog-" + catalog.id} |
| 41 | + ></ChildCard> |
| 42 | + ))} |
| 43 | + </Stack> |
| 44 | + </Section> |
| 45 | + )} |
| 46 | + |
| 47 | + {collections && collections.length > 0 && ( |
| 48 | + <Section |
| 49 | + title={ |
| 50 | + <HStack> |
| 51 | + <Icon> |
| 52 | + <LuFolderPlus></LuFolderPlus> |
| 53 | + </Icon>{" "} |
| 54 | + Collections ({collections.length}) |
| 55 | + </HStack> |
| 56 | + } |
| 57 | + > |
| 58 | + <Stack> |
| 59 | + {collections.map((collection) => ( |
| 60 | + <ChildCard |
| 61 | + child={collection} |
| 62 | + key={"collection-" + collection.id} |
| 63 | + ></ChildCard> |
| 64 | + ))} |
| 65 | + </Stack> |
| 66 | + </Section> |
| 67 | + )} |
| 68 | + </> |
19 | 69 | ); |
20 | 70 | } |
21 | 71 |
|
|
0 commit comments