Skip to content

Commit 0a94a9a

Browse files
author
Juarez Mota
committed
refactor: streamline choice card state management in ContributionsEpicCtasContainer
1 parent f56398d commit 0a94a9a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

dotcom-rendering/src/components/marketing/epics/ctas/ContributionsEpicCtasContainer.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ export const ContributionsEpicCtasContainer: ReactComponent<Props> = ({
4141
isTabletOrAbove,
4242
variant.choiceCardsSettings,
4343
);
44-
const defaultProduct = choiceCards?.find((cc) => cc.isDefault)?.product;
45-
const [
46-
threeTierChoiceCardSelectedProduct,
47-
setThreeTierChoiceCardSelectedProduct,
48-
] = useState<ChoiceCard['product'] | undefined>(defaultProduct);
44+
45+
const defaultChoiceCard = choiceCards?.find((cc) => cc.isDefault);
46+
const [selectedChoiceCard, setSelectedChoiceCard] = useState<
47+
ChoiceCard | undefined
48+
>(defaultChoiceCard);
4949

5050
return (
5151
<>
52-
{choiceCards && threeTierChoiceCardSelectedProduct && (
52+
{choiceCards && selectedChoiceCard && (
5353
<ThreeTierChoiceCards
54-
selectedProduct={threeTierChoiceCardSelectedProduct}
55-
setSelectedProduct={setThreeTierChoiceCardSelectedProduct}
54+
selectedChoiceCard={selectedChoiceCard}
55+
setSelectedChoiceCard={setSelectedChoiceCard}
5656
choices={choiceCards}
5757
id={'epic'}
5858
/>
@@ -76,9 +76,7 @@ export const ContributionsEpicCtasContainer: ReactComponent<Props> = ({
7676
submitComponentEvent={submitComponentEvent}
7777
isReminderActive={isReminderActive}
7878
isSignedIn={Boolean(fetchedEmail)}
79-
threeTierChoiceCardSelectedProduct={
80-
threeTierChoiceCardSelectedProduct
81-
}
79+
threeTierChoiceCardSelectedProduct={selectedChoiceCard?.product}
8280
amountsTestName={amountsTestName}
8381
amountsVariantName={amountsVariantName}
8482
promoCodes={variant.promoCodes ?? []}

0 commit comments

Comments
 (0)