File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
packages/template-retail-react-app/app/components/subscription/hooks Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff 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 || [ ]
You can’t perform that action at this time.
0 commit comments