|
1 | 1 | import { useReadAtom } from "@ouestware/atoms"; |
| 2 | +import { isNil } from "lodash"; |
2 | 3 | import { FC } from "react"; |
3 | 4 | import { useTranslation } from "react-i18next"; |
4 | 5 |
|
| 6 | +import { useFilters, useGraphDataset, usePreferences } from "../../core/context/dataContexts"; |
5 | 7 | import { filteredGraphsAtom } from "../../core/graph"; |
6 | 8 |
|
7 | | -export const FilteredGraphSummary: FC<{ filterIndex: number }> = ({ filterIndex }) => { |
| 9 | +export const FilteredGraphSummary: FC<{ filterIndex?: number }> = ({ filterIndex }) => { |
8 | 10 | const { t } = useTranslation(); |
| 11 | + const { locale } = usePreferences(); |
| 12 | + const { fullGraph } = useGraphDataset(); |
| 13 | + const { filters } = useFilters(); |
9 | 14 | const filteredGraphs = useReadAtom(filteredGraphsAtom); |
10 | | - const relatedGraph = filteredGraphs[filterIndex]?.graph; |
| 15 | + const relatedGraph = !isNil(filterIndex) ? filteredGraphs[filterIndex]?.graph : fullGraph; |
11 | 16 |
|
12 | 17 | return ( |
13 | | - <div> |
14 | | - {relatedGraph.order} {t("graph.model.nodes", { count: relatedGraph.order })}, {relatedGraph.size}{" "} |
15 | | - {t("graph.model.edges", { count: relatedGraph.size })} |
16 | | - </div> |
| 18 | + <section className="filter-graph"> |
| 19 | + {isNil(filterIndex) && <div>{t("filters.full_graph")}</div>} |
| 20 | + {filterIndex === filters.length - 1 && <div>{t("filters.visible_graph")}</div>} |
| 21 | + <div> |
| 22 | + {relatedGraph.order.toLocaleString(locale)} {t("graph.model.nodes", { count: relatedGraph.order })},{" "} |
| 23 | + {relatedGraph.size.toLocaleString(locale)} {t("graph.model.edges", { count: relatedGraph.size })} |
| 24 | + </div> |
| 25 | + </section> |
17 | 26 | ); |
18 | 27 | }; |
0 commit comments