diff --git a/app/src/app/reports/drill-down-chart.tsx b/app/src/app/reports/drill-down-chart.tsx index 5dd3e84fd..300ae64eb 100644 --- a/app/src/app/reports/drill-down-chart.tsx +++ b/app/src/app/reports/drill-down-chart.tsx @@ -92,7 +92,7 @@ export const DrillDownChart = ({ ], }); } - }, [points, onSelect, variable]); + }, [points, onSelect, variable, title]); return
; }; diff --git a/app/src/app/reports/statbus-chart.tsx b/app/src/app/reports/statbus-chart.tsx index af720f2a5..28da87641 100644 --- a/app/src/app/reports/statbus-chart.tsx +++ b/app/src/app/reports/statbus-chart.tsx @@ -1,7 +1,7 @@ "use client"; import { useEffect } from "react"; -import { DrillDown, DrillDownPoint } from "@/app/reports/types/drill-down"; +import { DrillDown } from "@/app/reports/types/drill-down"; import * as highcharts from "highcharts"; import HC_drilldown from "highcharts/modules/drilldown"; import HC_a11y from "highcharts/modules/accessibility"; @@ -10,6 +10,7 @@ import { DrillDownChart } from "@/app/reports/drill-down-chart"; import { useDrillDownData } from "@/app/reports/use-drill-down-data"; import { SearchLink } from "@/app/reports/search-link"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; +import { useCustomConfigContext } from "../use-custom-config-context"; export default function StatBusChart(props: { readonly drillDown: DrillDown }) { const { @@ -20,6 +21,8 @@ export default function StatBusChart(props: { readonly drillDown: DrillDown }) { setActivityCategory, } = useDrillDownData(props.drillDown); + const { statDefinitions } = useCustomConfigContext(); + useEffect(() => { HC_a11y(highcharts); HC_drilldown(highcharts); @@ -31,8 +34,11 @@ export default function StatBusChart(props: { readonly drillDown: DrillDown }) { title: string; }[] = [ { value: "count", label: "Count", title: "Number of enterprises" }, - { value: "employees", label: "Employees", title: "Number of employees" }, - { value: "turnover", label: "Turnover", title: "Total turnover" }, + ...(statDefinitions.map(({ code, name }) => ({ + value: code, + label: code, + title: name, + })) ?? []), ]; return ( @@ -43,6 +49,7 @@ export default function StatBusChart(props: { readonly drillDown: DrillDown }) { {statisticalVariable.label} diff --git a/app/src/app/search/components/statistical-unit-table-header.tsx b/app/src/app/search/components/statistical-unit-table-header.tsx index 4452e139d..670f622b1 100644 --- a/app/src/app/search/components/statistical-unit-table-header.tsx +++ b/app/src/app/search/components/statistical-unit-table-header.tsx @@ -1,7 +1,9 @@ import { TableHead, TableHeader, TableRow } from "@/components/ui/table"; import SortableTableHead from "@/app/search/components/sortable-table-head"; +import { useCustomConfigContext } from "@/app/use-custom-config-context"; export const StatisticalUnitTableHeader = () => { + const { statDefinitions } = useCustomConfigContext(); return ( @@ -13,16 +15,16 @@ export const StatisticalUnitTableHeader = () => { Region - Employees + {statDefinitions?.[0]?.code} - Turnover + {statDefinitions?.[1]?.code} ; @@ -23,6 +23,7 @@ export const StatisticalUnitTableRow = ({ }: SearchResultTableRowProps) => { const { regions, activityCategories } = useSearchContext(); const { selected } = useCartContext(); + const { statDefinitions, externalIdentTypes } = useCustomConfigContext(); const isInBasket = selected.some( (s) => s.unit_id === unit.unit_id && s.unit_type === unit.unit_type @@ -41,9 +42,7 @@ export const StatisticalUnitTableRow = ({ invalid_codes, } = unit as StatisticalUnit; - const tax_ident = external_idents[TAX_IDENT]; - const employees = stats_summary[EMPLOYEES]?.sum; - const turnover = stats_summary[TURNOVER]?.sum; + const external_ident = external_idents[externalIdentTypes?.[0]?.code]; const getRegionByPath = (physical_region_path: unknown) => regions.find(({ path }) => path === physical_region_path); @@ -104,7 +103,7 @@ export const StatisticalUnitTableRow = ({ {name} )} - {tax_ident} + {external_ident} | {prettifyUnitType(type)} {invalid_codes && ( @@ -128,10 +127,10 @@ export const StatisticalUnitTableRow = ({
- {thousandSeparator(employees)} + {thousandSeparator(stats_summary[statDefinitions?.[0]?.code]?.sum)} - {thousandSeparator(turnover)} + {thousandSeparator(stats_summary[statDefinitions?.[1]?.code]?.sum)} >${TAX_IDENT}`]: selected = [] }, + values: { [`external_idents->>${externalIdentType}`]: selected = [] }, }, } = useSearchContext(); @@ -22,13 +23,13 @@ export default function TaxRegIdentFilter({ urlSearchParam }: IProps) { dispatch({ type: "set_query", payload: { - name: `external_idents->>${TAX_IDENT}`, + name: `external_idents->>${externalIdentType}`, query: value ? `eq.${value}` : null, values: value ? [value] : [], }, }); }, - [dispatch] + [dispatch, externalIdentType] ); useEffect(() => {