@propeller-commerce/propeller-v2-react-ui 0.7.0 → 0.7.1

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.
package/dist/index.js CHANGED
@@ -868,6 +868,25 @@ function useCart(options) {
868
868
  }, [graphqlClient, language, configuration, user]);
869
869
  return { cart, cartId, loading, error, checkoutAllowed, resolveCart, addItem, updateItemQuantity, updateItemNotes, deleteItem, addActionCode, removeActionCode, requestAuthorization, processCart, getCrossupsells, getMinQuantity, getStep };
870
870
  }
871
+ function buildAddressInput(type, addr) {
872
+ return {
873
+ type,
874
+ firstName: addr.firstName || "",
875
+ lastName: addr.lastName || "",
876
+ street: addr.street || "",
877
+ postalCode: addr.postalCode || "",
878
+ city: addr.city || "",
879
+ ...addr.company && { company: addr.company },
880
+ ...addr.gender && { gender: addr.gender },
881
+ ...addr.middleName && { middleName: addr.middleName },
882
+ ...addr.number && { number: addr.number },
883
+ ...addr.numberExtension && { numberExtension: addr.numberExtension },
884
+ ...addr.country && { country: addr.country },
885
+ ...addr.email && { email: addr.email },
886
+ ...addr.mobile && { mobile: addr.mobile },
887
+ ...addr.phone && { phone: addr.phone }
888
+ };
889
+ }
871
890
  function useCheckout(options) {
872
891
  const { graphqlClient, user, companyId } = options;
873
892
  const language = options.language ?? "NL";
@@ -908,26 +927,9 @@ function useCheckout(options) {
908
927
  if (!hasInvoice) {
909
928
  const defaultInvoice = getUserDefaultAddress("invoice");
910
929
  if (defaultInvoice) {
911
- const input = {
912
- type: CartAddressType.INVOICE,
913
- firstName: defaultInvoice.firstName || "",
914
- lastName: defaultInvoice.lastName || "",
915
- street: defaultInvoice.street || "",
916
- postalCode: defaultInvoice.postalCode || "",
917
- city: defaultInvoice.city || "",
918
- company: defaultInvoice.company,
919
- gender: defaultInvoice.gender,
920
- middleName: defaultInvoice.middleName,
921
- number: defaultInvoice.number,
922
- numberExtension: defaultInvoice.numberExtension,
923
- country: defaultInvoice.country,
924
- email: defaultInvoice.email,
925
- mobile: defaultInvoice.mobile,
926
- phone: defaultInvoice.phone
927
- };
928
930
  updatedCart = await cartService.updateCartAddress({
929
931
  id: updatedCart.cartId,
930
- input,
932
+ input: buildAddressInput(CartAddressType.INVOICE, defaultInvoice),
931
933
  imageVariantFilters,
932
934
  imageSearchFilters,
933
935
  language
@@ -937,26 +939,9 @@ function useCheckout(options) {
937
939
  if (!hasDelivery) {
938
940
  const defaultDelivery = getUserDefaultAddress("delivery");
939
941
  if (defaultDelivery) {
940
- const input = {
941
- type: CartAddressType.DELIVERY,
942
- firstName: defaultDelivery.firstName || "",
943
- lastName: defaultDelivery.lastName || "",
944
- street: defaultDelivery.street || "",
945
- postalCode: defaultDelivery.postalCode || "",
946
- city: defaultDelivery.city || "",
947
- company: defaultDelivery.company,
948
- gender: defaultDelivery.gender,
949
- middleName: defaultDelivery.middleName,
950
- number: defaultDelivery.number,
951
- numberExtension: defaultDelivery.numberExtension,
952
- country: defaultDelivery.country,
953
- email: defaultDelivery.email,
954
- mobile: defaultDelivery.mobile,
955
- phone: defaultDelivery.phone
956
- };
957
942
  updatedCart = await cartService.updateCartAddress({
958
943
  id: updatedCart.cartId,
959
- input,
944
+ input: buildAddressInput(CartAddressType.DELIVERY, defaultDelivery),
960
945
  imageVariantFilters,
961
946
  imageSearchFilters,
962
947
  language
@@ -5045,6 +5030,7 @@ function AddToFavorite(rawProps) {
5045
5030
  ] }) }) : null });
5046
5031
  }
5047
5032
  var AddToFavorite_default = AddToFavorite;
5033
+ var EMAIL_PATTERN = "[^@\\s]+@[^@\\s.]+(?:\\.[^@\\s.]+)*\\.[A-Za-z]{2,}";
5048
5034
  var AddressCardContext = React6.createContext(null);
5049
5035
  function useAddressCardContext() {
5050
5036
  const ctx = React6.useContext(AddressCardContext);
@@ -5490,10 +5476,7 @@ function AddressCard(rawProps) {
5490
5476
  ] }),
5491
5477
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
5492
5478
  /* @__PURE__ */ jsxs("div", { children: [
5493
- /* @__PURE__ */ jsxs("label", { className: "block text-sm font-medium mb-1", children: [
5494
- getLabel(props.labels, "email", "Email"),
5495
- " *"
5496
- ] }),
5479
+ /* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: getLabel(props.labels, "email", "Email") }),
5497
5480
  /* @__PURE__ */ jsx(
5498
5481
  "input",
5499
5482
  {
@@ -5503,7 +5486,7 @@ function AddressCard(rawProps) {
5503
5486
  onChange: (e) => {
5504
5487
  setEditEmail(e.target.value);
5505
5488
  },
5506
- required: true
5489
+ pattern: EMAIL_PATTERN
5507
5490
  }
5508
5491
  )
5509
5492
  ] }),
@@ -5783,10 +5766,7 @@ function AddressCard(rawProps) {
5783
5766
  ] }),
5784
5767
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
5785
5768
  /* @__PURE__ */ jsxs("div", { children: [
5786
- /* @__PURE__ */ jsxs("label", { className: "block text-sm font-medium mb-1", children: [
5787
- getLabel(props.labels, "email", "Email"),
5788
- " *"
5789
- ] }),
5769
+ /* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: getLabel(props.labels, "email", "Email") }),
5790
5770
  /* @__PURE__ */ jsx(
5791
5771
  "input",
5792
5772
  {
@@ -5796,7 +5776,7 @@ function AddressCard(rawProps) {
5796
5776
  onChange: (e) => {
5797
5777
  setEditEmail(e.target.value);
5798
5778
  },
5799
- required: true
5779
+ pattern: EMAIL_PATTERN
5800
5780
  }
5801
5781
  )
5802
5782
  ] }),