Skip to content

Commit 09cd250

Browse files
@W-19143871 Email Footer Marketing Consent capture. Return immediately if feature is not enabled.
1 parent a6928ba commit 09cd250

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/template-retail-react-app/app/components/subscription/hooks/use-email-subscription.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ export const useEmailSubscription = ({tag} = {}) => {
8686
)
8787

8888
const handleSignUp = useCallback(async () => {
89+
// return immediately if feature is not enabled.
90+
if (!isFeatureEnabled) {
91+
console.error('[useEmailSubscription] Feature not enabled. Subscribe action ignored.')
92+
return
93+
}
94+
95+
// Clear any prior validation messages
96+
setMessage(null)
97+
8998
// Validate email using the utility validator
9099
const validation = validateEmail(email)
91100

@@ -95,13 +104,7 @@ export const useEmailSubscription = ({tag} = {}) => {
95104
return
96105
}
97106

98-
if (!isFeatureEnabled) {
99-
return
100-
}
101-
102107
try {
103-
setMessage(null)
104-
105108
// Fetch subscriptions on-demand when submitting
106109
const {data: freshSubscriptionsData} = await fetchSubscriptions()
107110
const allSubscriptions = freshSubscriptionsData?.data || []

0 commit comments

Comments
 (0)