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