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.
@@ -4835,9 +4835,12 @@ const RegistrationFormContent = _ref => {
4835
4835
  },
4836
4836
  errors: []
4837
4837
  });
4838
+ const [hasTicketData, setHasTicketData] = (0,external_react_.useState)(false);
4838
4839
  const [ticketDataError, setTicketDataError] = (0,external_react_.useState)(false);
4839
- const [ticketDataLoaded, setTicketDataLoaded] = (0,external_react_.useState)(false);
4840
4840
  const [unappliedCodeWarning, setUnappliedCodeWarning] = (0,external_react_.useState)(null);
4841
+ const isAuthenticated = !!profileData;
4842
+ const summitId = summitData?.id;
4843
+ const userId = profileData?.id;
4841
4844
  const {
4842
4845
  values: formValues,
4843
4846
  errors: formErrors
@@ -4852,12 +4855,12 @@ const RegistrationFormContent = _ref => {
4852
4855
  publicKey,
4853
4856
  provider
4854
4857
  } = (0,utils/* getCurrentProvider */.U5)(summitData);
4855
- 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) : [];
4856
- const noAvailableTickets = (0,external_react_.useMemo)(() => profileData && ticketDataLoaded && !ticketDataError && allowedTicketTypes.length === 0 && step !== constants.STEP_COMPLETE, [profileData, ticketDataLoaded, ticketDataError, allowedTicketTypes, step]);
4857
- const alreadyOwnedTickets = (0,external_react_.useMemo)(() => profileData && ticketDataLoaded && !ticketDataError && allowedTicketTypes.length > 0 && ownedTickets.length > 0, [profileData, ticketDataLoaded, ticketDataError, allowedTicketTypes, ownedTickets]);
4858
+ 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]);
4859
+ const noAvailableTickets = (0,external_react_.useMemo)(() => isAuthenticated && hasTicketData && !ticketDataError && allowedTicketTypes.length === 0 && step !== constants.STEP_COMPLETE, [isAuthenticated, hasTicketData, ticketDataError, allowedTicketTypes, step]);
4860
+ const alreadyOwnedTickets = (0,external_react_.useMemo)(() => isAuthenticated && hasTicketData && !ticketDataError && allowedTicketTypes.length > 0 && ownedTickets.length > 0, [isAuthenticated, hasTicketData, ticketDataError, allowedTicketTypes, ownedTickets]);
4858
4861
  (0,external_react_.useEffect)(() => {
4859
4862
  if (profileData) loadProfileData(profileData);
4860
- }, [profileData]);
4863
+ }, [userId]);
4861
4864
  (0,external_react_.useEffect)(() => {
4862
4865
  loadSession(registration_form_objectSpread(registration_form_objectSpread({}, rest), {}, {
4863
4866
  summitData,
@@ -4869,12 +4872,12 @@ const RegistrationFormContent = _ref => {
4869
4872
  }
4870
4873
  }, []);
4871
4874
  (0,external_react_.useEffect)(() => {
4872
- if (summitData && profileData) {
4873
- const ensureInvitation = () => summitData.invite_only_registration ? getMyInvitation(summitData.id) : Promise.resolve();
4875
+ if (summitId && isAuthenticated) {
4876
+ const ensureInvitation = () => summitData.invite_only_registration ? getMyInvitation(summitId) : Promise.resolve();
4874
4877
 
4875
- ensureInvitation().catch(e => console.log(e)).finally(() => handleGetTicketTypesAndTaxes(summitData.id));
4878
+ ensureInvitation().catch(e => console.log(e)).finally(() => handleGetTicketTypesAndTaxes(summitId));
4876
4879
  }
4877
- }, [summitData?.id, profileData]);
4880
+ }, [summitId, isAuthenticated]);
4878
4881
  (0,external_react_.useEffect)(() => {
4879
4882
  if (step > constants.STEP_SELECT_TICKET_TYPE && !registrationForm.values?.ticketType && !reservation) {
4880
4883
  changeStep(constants.STEP_SELECT_TICKET_TYPE);
@@ -4885,10 +4888,10 @@ const RegistrationFormContent = _ref => {
4885
4888
  }, [step]); // Discovery: fetch qualifying promo codes after auth
4886
4889
 
4887
4890
  (0,external_react_.useEffect)(() => {
4888
- if (profileData && summitData?.id) {
4889
- discoverPromoCodes(summitData.id);
4891
+ if (isAuthenticated && summitId) {
4892
+ discoverPromoCodes(summitId);
4890
4893
  }
4891
- }, [profileData, summitData?.id]);
4894
+ }, [isAuthenticated, summitId]);
4892
4895
  const handleFormPromoCodeChange = (0,external_react_.useCallback)(code => mergeFormValues({
4893
4896
  promoCode: code
4894
4897
  }), [mergeFormValues]);
@@ -4901,7 +4904,7 @@ const RegistrationFormContent = _ref => {
4901
4904
  removePromoCode,
4902
4905
  validatePromoCode,
4903
4906
  setFormPromoCode: handleFormPromoCodeChange,
4904
- ticketDataLoaded: ticketDataLoaded && !ticketDataError,
4907
+ ticketDataLoaded: hasTicketData && !ticketDataError,
4905
4908
  hasTickets: allowedTicketTypes.length > 0
4906
4909
  }); // Local destructure for readability at call sites.
4907
4910
 
@@ -4960,8 +4963,9 @@ const RegistrationFormContent = _ref => {
4960
4963
 
4961
4964
  const handleGetTicketTypesAndTaxes = summitId => {
4962
4965
  setTicketDataError(false);
4963
- setTicketDataLoaded(false);
4964
- getTicketTypesAndTaxes(summitId).catch(error => {
4966
+ getTicketTypesAndTaxes(summitId).then(() => {
4967
+ setHasTicketData(true);
4968
+ }).catch(error => {
4965
4969
  let {
4966
4970
  message
4967
4971
  } = error;
@@ -4972,8 +4976,6 @@ const RegistrationFormContent = _ref => {
4972
4976
  }
4973
4977
 
4974
4978
  setTicketDataError(true);
4975
- }).finally(() => {
4976
- setTicketDataLoaded(true);
4977
4979
  });
4978
4980
  };
4979
4981
 
@@ -5021,12 +5023,11 @@ const RegistrationFormContent = _ref => {
5021
5023
  trackEvent(constants.PURCHASE_COMPLETE, {
5022
5024
  order
5023
5025
  });
5024
- }; // If user is logged in but ticket data hasn't loaded yet (and no error occurred),
5025
- // don't render to avoid flash. Uses local state instead of Redux to prevent
5026
- // race conditions with redux-persist rehydration.
5026
+ }; // Authenticated first-load: wait until ticket data is in before rendering
5027
+ // to avoid a flash of empty/wrong state.
5027
5028
 
5028
5029
 
5029
- if (profileData && !ticketDataLoaded && !ticketDataError) return null;
5030
+ if (isAuthenticated && !hasTicketData && !ticketDataError) return null;
5030
5031
  return /*#__PURE__*/external_react_default().createElement("div", {
5031
5032
  className: "summit-registration-lite"
5032
5033
  }, /*#__PURE__*/external_react_default().createElement((ajaxloader_default()), {