summit-registration-lite 7.0.2 → 7.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3863,9 +3863,12 @@ const RegistrationFormContent = _ref => {
3863
3863
  },
3864
3864
  errors: []
3865
3865
  });
3866
+ const [hasTicketData, setHasTicketData] = (0,external_react_.useState)(false);
3866
3867
  const [ticketDataError, setTicketDataError] = (0,external_react_.useState)(false);
3867
- const [ticketDataLoaded, setTicketDataLoaded] = (0,external_react_.useState)(false);
3868
3868
  const [unappliedCodeWarning, setUnappliedCodeWarning] = (0,external_react_.useState)(null);
3869
+ const isAuthenticated = !!profileData;
3870
+ const summitId = summitData?.id;
3871
+ const userId = profileData?.id;
3869
3872
  const {
3870
3873
  values: formValues,
3871
3874
  errors: formErrors
@@ -3880,12 +3883,12 @@ const RegistrationFormContent = _ref => {
3880
3883
  publicKey,
3881
3884
  provider
3882
3885
  } = (0,utils/* getCurrentProvider */.U5)(summitData);
3883
- const allowedTicketTypes = ticketDataLoaded ? ticketTypes.filter(tt => tt.sub_type === constants.TICKET_TYPE_SUBTYPE_PREPAID || tt.sales_start_date === null && tt.sales_end_date === null || nowUtc >= tt.sales_start_date && nowUtc <= tt.sales_end_date) : [];
3884
- const noAvailableTickets = (0,external_react_.useMemo)(() => profileData && ticketDataLoaded && !ticketDataError && allowedTicketTypes.length === 0 && step !== constants.STEP_COMPLETE, [profileData, ticketDataLoaded, ticketDataError, allowedTicketTypes, step]);
3885
- const alreadyOwnedTickets = (0,external_react_.useMemo)(() => profileData && ticketDataLoaded && !ticketDataError && allowedTicketTypes.length > 0 && ownedTickets.length > 0, [profileData, ticketDataLoaded, ticketDataError, allowedTicketTypes, ownedTickets]);
3886
+ const allowedTicketTypes = (0,external_react_.useMemo)(() => hasTicketData ? ticketTypes.filter(tt => tt.sub_type === constants.TICKET_TYPE_SUBTYPE_PREPAID || tt.sales_start_date === null && tt.sales_end_date === null || nowUtc >= tt.sales_start_date && nowUtc <= tt.sales_end_date) : [], [hasTicketData, ticketTypes, nowUtc]);
3887
+ const noAvailableTickets = (0,external_react_.useMemo)(() => isAuthenticated && hasTicketData && !ticketDataError && allowedTicketTypes.length === 0 && step !== constants.STEP_COMPLETE, [isAuthenticated, hasTicketData, ticketDataError, allowedTicketTypes, step]);
3888
+ const alreadyOwnedTickets = (0,external_react_.useMemo)(() => isAuthenticated && hasTicketData && !ticketDataError && allowedTicketTypes.length > 0 && ownedTickets.length > 0, [isAuthenticated, hasTicketData, ticketDataError, allowedTicketTypes, ownedTickets]);
3886
3889
  (0,external_react_.useEffect)(() => {
3887
3890
  if (profileData) loadProfileData(profileData);
3888
- }, [profileData]);
3891
+ }, [userId]);
3889
3892
  (0,external_react_.useEffect)(() => {
3890
3893
  loadSession(registration_form_objectSpread(registration_form_objectSpread({}, rest), {}, {
3891
3894
  summitData,
@@ -3897,12 +3900,12 @@ const RegistrationFormContent = _ref => {
3897
3900
  }
3898
3901
  }, []);
3899
3902
  (0,external_react_.useEffect)(() => {
3900
- if (summitData && profileData) {
3901
- const ensureInvitation = () => summitData.invite_only_registration ? getMyInvitation(summitData.id) : Promise.resolve();
3903
+ if (summitId && isAuthenticated) {
3904
+ const ensureInvitation = () => summitData.invite_only_registration ? getMyInvitation(summitId) : Promise.resolve();
3902
3905
 
3903
- ensureInvitation().catch(e => console.log(e)).finally(() => handleGetTicketTypesAndTaxes(summitData.id));
3906
+ ensureInvitation().catch(e => console.log(e)).finally(() => handleGetTicketTypesAndTaxes(summitId));
3904
3907
  }
3905
- }, [summitData?.id, profileData]);
3908
+ }, [summitId, isAuthenticated]);
3906
3909
  (0,external_react_.useEffect)(() => {
3907
3910
  if (step > constants.STEP_SELECT_TICKET_TYPE && !registrationForm.values?.ticketType && !reservation) {
3908
3911
  changeStep(constants.STEP_SELECT_TICKET_TYPE);
@@ -3913,10 +3916,10 @@ const RegistrationFormContent = _ref => {
3913
3916
  }, [step]); // Discovery: fetch qualifying promo codes after auth
3914
3917
 
3915
3918
  (0,external_react_.useEffect)(() => {
3916
- if (profileData && summitData?.id) {
3917
- discoverPromoCodes(summitData.id);
3919
+ if (isAuthenticated && summitId) {
3920
+ discoverPromoCodes(summitId);
3918
3921
  }
3919
- }, [profileData, summitData?.id]);
3922
+ }, [isAuthenticated, summitId]);
3920
3923
  const handleFormPromoCodeChange = (0,external_react_.useCallback)(code => mergeFormValues({
3921
3924
  promoCode: code
3922
3925
  }), [mergeFormValues]);
@@ -3929,7 +3932,7 @@ const RegistrationFormContent = _ref => {
3929
3932
  removePromoCode,
3930
3933
  validatePromoCode,
3931
3934
  setFormPromoCode: handleFormPromoCodeChange,
3932
- ticketDataLoaded: ticketDataLoaded && !ticketDataError,
3935
+ ticketDataLoaded: hasTicketData && !ticketDataError,
3933
3936
  hasTickets: allowedTicketTypes.length > 0
3934
3937
  }); // Local destructure for readability at call sites.
3935
3938
 
@@ -3988,8 +3991,9 @@ const RegistrationFormContent = _ref => {
3988
3991
 
3989
3992
  const handleGetTicketTypesAndTaxes = summitId => {
3990
3993
  setTicketDataError(false);
3991
- setTicketDataLoaded(false);
3992
- getTicketTypesAndTaxes(summitId).catch(error => {
3994
+ getTicketTypesAndTaxes(summitId).then(() => {
3995
+ setHasTicketData(true);
3996
+ }).catch(error => {
3993
3997
  let {
3994
3998
  message
3995
3999
  } = error;
@@ -4000,8 +4004,6 @@ const RegistrationFormContent = _ref => {
4000
4004
  }
4001
4005
 
4002
4006
  setTicketDataError(true);
4003
- }).finally(() => {
4004
- setTicketDataLoaded(true);
4005
4007
  });
4006
4008
  };
4007
4009
 
@@ -4049,12 +4051,11 @@ const RegistrationFormContent = _ref => {
4049
4051
  trackEvent(constants.PURCHASE_COMPLETE, {
4050
4052
  order
4051
4053
  });
4052
- }; // If user is logged in but ticket data hasn't loaded yet (and no error occurred),
4053
- // don't render to avoid flash. Uses local state instead of Redux to prevent
4054
- // race conditions with redux-persist rehydration.
4054
+ }; // Authenticated first-load: wait until ticket data is in before rendering
4055
+ // to avoid a flash of empty/wrong state.
4055
4056
 
4056
4057
 
4057
- if (profileData && !ticketDataLoaded && !ticketDataError) return null;
4058
+ if (isAuthenticated && !hasTicketData && !ticketDataError) return null;
4058
4059
  return /*#__PURE__*/external_react_default().createElement("div", {
4059
4060
  className: "summit-registration-lite"
4060
4061
  }, /*#__PURE__*/external_react_default().createElement((ajaxloader_default()), {