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

Commit d876841

Browse files
committed
add identifier
1 parent e398f7c commit d876841

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
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

+6-3
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,21 @@ const roundDescriptionAndRequirementsArgs = {
105105
};
106106
const metrics = [
107107
{
108-
title: "Metric 1",
108+
name: "Metric 1",
109109
description: "Description for Metric 1",
110+
identifier: "metric-1",
110111
onReadMore: () => void 0,
111112
},
112113
{
113-
title: "Metric 2",
114+
name: "Metric 2",
114115
description: "Description for Metric 2",
116+
identifier: "metric-2",
115117
onReadMore: () => void 0,
116118
},
117119
{
118-
title: "Metric 3",
120+
name: "Metric 3",
119121
description: "Description for Metric 3",
122+
identifier: "metric-3",
120123
onReadMore: () => void 0,
121124
},
122125
];

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ const metricCardVariants = tv({
3131
});
3232

3333
export interface MetricCardProps {
34-
title: string;
34+
name: string;
35+
identifier: string;
3536
description: string;
3637
variant?: "metric" | "ballot";
3738
isAdded?: boolean;
@@ -81,7 +82,7 @@ const MetricCardLoading: React.FC<{ hideButton: boolean }> = ({ hideButton }) =>
8182
};
8283

8384
const MetricCardState: React.FC<MetricCardProps> = ({
84-
title,
85+
name,
8586
description,
8687
variant = "metric",
8788
isAdded = false,
@@ -143,7 +144,7 @@ const MetricCardState: React.FC<MetricCardProps> = ({
143144
<div className={cn(base(), background, className)}>
144145
<div className={content()}>
145146
<div className={cn(leftSection(), hideButton && "w-full")}>
146-
<h3 className={headingClass()}>{title}</h3>
147+
<h3 className={headingClass()}>{name}</h3>
147148
<div className={paragraphClass()}>{description}</div>
148149
</div>
149150
{!hideButton && <div className={buttonContainer()}>{renderButton()}</div>}

0 commit comments

Comments
 (0)