Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyl committed Sep 3, 2023
1 parent 8ec0703 commit 3ad3c2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 6 additions & 8 deletions frontend/src/components/uploader/report-config/MetricConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ArrowDownIcon, ArrowUpIcon } from "@heroicons/react/24/outline";
import {
Text
} from "@tremor/react";
import { useState } from "react";
import { useEffect, useState } from "react";
import {
AggregationType,
ColumnType,
Expand All @@ -15,21 +15,21 @@ type Props = {
selectedColumns: { [key: string]: { type: string } };
onSelectMetrics: (metrics: string[], type: ColumnType) => void;
onSelectMetricAggregationOption: (metric: string, option: AggregationType) => void;
targetDirection: TargetDirection;
setTargetDirection: (direction: TargetDirection) => void;
}


const MetricConfig = (props: Props) => {
const { getValidMetricColumns, selectedColumns, onSelectMetrics, onSelectMetricAggregationOption } = props;
const [targetDirection, setTargetDirection] =
useState<TargetDirection>("increasing");
const { getValidMetricColumns, selectedColumns, onSelectMetrics, onSelectMetricAggregationOption, targetDirection, setTargetDirection } = props;
const [metricType, setMetricType] = useState<AggregationType>("sum");
const [metricColumn, setMetricColumn] = useState<string>("");

const updateMetric = () => {
useEffect(() => {
if (metricColumn !== "") {
onSelectMetricAggregationOption(metricColumn, metricType);
}
}
}, [metricColumn, metricType, onSelectMetricAggregationOption]);

return (
<>
Expand All @@ -44,7 +44,6 @@ const MetricConfig = (props: Props) => {
selectedValue={metricType}
onValueChange={(metric) => {
setMetricType(metric as AggregationType);
updateMetric();
}}
/>

Expand All @@ -68,7 +67,6 @@ const MetricConfig = (props: Props) => {
onValueChange={(metric) => {
setMetricColumn(metric);
onSelectMetrics([metric], "metric");
updateMetric();
}}
/>
<SingleSelector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ function ReportConfig({
selectedColumns={selectedColumns}
onSelectMetrics={onSelectMetrics}
onSelectMetricAggregationOption={onSelectMetricAggregationOption}
targetDirection={targetDirection}
setTargetDirection={setTargetDirection}
/>
{/* Dimension columns multi selector */}
{(!prefilledConfigs || Object.keys(selectedColumns).length > 0) && (
Expand Down

0 comments on commit 3ad3c2a

Please sign in to comment.