Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit ca7e05b

Browse files
committed
add identifier
1 parent e398f7c commit ca7e05b

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/components/Form/FormControllers/MetricsFormController/MetricsFormController.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,35 @@ export const MetricsFormController: React.FC<MetricsFormControllerProps> = ({ na
3131
render={({ field: { value, onChange } }) => {
3232
const selectedMetrics = value || [];
3333

34-
const handleToggleMetric = (title: string) => {
35-
const newValue = selectedMetrics.includes(title)
36-
? selectedMetrics.filter((t: string) => t !== title)
37-
: [...selectedMetrics, title];
34+
const handleToggleMetric = (identifier: string) => {
35+
const newValue = selectedMetrics.includes(identifier)
36+
? selectedMetrics.filter((t: string) => t !== identifier)
37+
: [...selectedMetrics, identifier];
3838
onChange(newValue);
3939
};
4040

41-
const isMetricSelected = (title: string) => selectedMetrics.includes(title);
41+
const isMetricSelected = (identifier: string) => selectedMetrics.includes(identifier);
4242

4343
return (
4444
<div className="space-y-6">
4545
{metrics.map((metric) => (
4646
<MetricCard
47-
key={metric.title}
47+
key={metric.identifier}
4848
{...metric}
49-
onClick={() => handleToggleMetric(metric.title)}
49+
onClick={() => handleToggleMetric(metric.identifier)}
5050
className="w-full"
5151
customButton={
52-
isMetricSelected(metric.title) ? (
52+
isMetricSelected(metric.identifier) ? (
5353
<Button
5454
value={"Added to Round"}
55-
onClick={() => handleToggleMetric(metric.title)}
55+
onClick={() => handleToggleMetric(metric.identifier)}
5656
className="flex items-center gap-2 rounded bg-moss-100 px-4 py-2 text-sm font-medium text-moss-700 hover:bg-moss-50"
5757
icon={<Icon className="size-4" type={IconType.CHECK} />}
5858
/>
5959
) : (
6060
<Button
6161
value={"Add to Round"}
62-
onClick={() => handleToggleMetric(metric.title)}
62+
onClick={() => handleToggleMetric(metric.identifier)}
6363
variant="light-purple"
6464
icon={<Icon className="size-4" type={IconType.CHECK} />}
6565
/>

src/components/GenericProgressForm/mocks/RoundSetup.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import moment from "moment";
2+
import { title } from "process";
23

34
import { FormField, FormStep } from "@/types";
45

@@ -107,16 +108,19 @@ const metrics = [
107108
{
108109
title: "Metric 1",
109110
description: "Description for Metric 1",
111+
identifier: "metric-1",
110112
onReadMore: () => void 0,
111113
},
112114
{
113115
title: "Metric 2",
114116
description: "Description for Metric 2",
117+
identifier: "metric-2",
115118
onReadMore: () => void 0,
116119
},
117120
{
118121
title: "Metric 3",
119122
description: "Description for Metric 3",
123+
identifier: "metric-3",
120124
onReadMore: () => void 0,
121125
},
122126
];

src/features/retrofunding/components/MetricCard/MetricCard.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const metricCardVariants = tv({
3232

3333
export interface MetricCardProps {
3434
title: string;
35+
identifier: string;
3536
description: string;
3637
variant?: "metric" | "ballot";
3738
isAdded?: boolean;

0 commit comments

Comments
 (0)