@vendure/dashboard 3.7.2 → 3.7.3-master-202608050305

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.
Files changed (108) hide show
  1. package/dist/bundle/chunks/{2SSKDMRQ-CMBxVbIh.js → 2SSKDMRQ-KZUCTCnr.js} +2 -2
  2. package/dist/bundle/chunks/{AP7HFJJL-PAkY4fBC.js → AP7HFJJL-kxZStlpP.js} +1 -1
  3. package/dist/bundle/chunks/{WDYDFRGG-xJgIWAuv.js → WDYDFRGG-BZRK2ITZ.js} +2 -2
  4. package/dist/bundle/chunks/ar-C8HyGurR.js +4 -0
  5. package/dist/bundle/chunks/bg--aJe6weI.js +4 -0
  6. package/dist/bundle/chunks/cs-DiORN27q.js +4 -0
  7. package/dist/bundle/chunks/de-BIbDqHi0.js +4 -0
  8. package/dist/bundle/chunks/en-BIXvudTL.js +4 -0
  9. package/dist/bundle/chunks/es-CtrB4rBI.js +4 -0
  10. package/dist/bundle/chunks/fa-psHxNGfe.js +4 -0
  11. package/dist/bundle/chunks/fr-C5nCJ4dT.js +4 -0
  12. package/dist/bundle/chunks/he-Bf9mrxS9.js +4 -0
  13. package/dist/bundle/chunks/hr-ukhxxcHj.js +4 -0
  14. package/dist/bundle/chunks/hu-C5Rw37rH.js +4 -0
  15. package/dist/bundle/chunks/it-9Wz02yYH.js +4 -0
  16. package/dist/bundle/chunks/ja-Dws9HYMD.js +4 -0
  17. package/dist/bundle/chunks/ko-BvE54r17.js +4 -0
  18. package/dist/bundle/chunks/{locale-BSCAi77j.js → locale-CJZpQnsu.js} +1 -1
  19. package/dist/bundle/chunks/{main-D8aGWlid.js → main-Df4f8P5A.js} +169 -40
  20. package/dist/bundle/chunks/nb-C5b8s5AZ.js +4 -0
  21. package/dist/bundle/chunks/ne-DidgSoes.js +4 -0
  22. package/dist/bundle/chunks/nl-Bs2EmoET.js +4 -0
  23. package/dist/bundle/chunks/pl-ByMSgi7e.js +4 -0
  24. package/dist/bundle/chunks/pt_BR-CTGGI34p.js +4 -0
  25. package/dist/bundle/chunks/pt_PT-BMabWU8-.js +4 -0
  26. package/dist/bundle/chunks/ro-DLijHEde.js +4 -0
  27. package/dist/bundle/chunks/ru-sL_M_iwR.js +4 -0
  28. package/dist/bundle/chunks/sv-C6w42jAh.js +4 -0
  29. package/dist/bundle/chunks/tr-Lr8P315q.js +4 -0
  30. package/dist/bundle/chunks/uk-5I_XIBoN.js +4 -0
  31. package/dist/bundle/chunks/{use-job-queue-polling-D8i6-8rR.js → use-job-queue-polling-BjEkkz66.js} +291 -70
  32. package/dist/bundle/chunks/uz-BjRS1co1.js +4 -0
  33. package/dist/bundle/chunks/zh_Hans-Bqmum3_n.js +4 -0
  34. package/dist/bundle/chunks/zh_Hant-pqbmvylJ.js +4 -0
  35. package/dist/bundle/dashboard.css +12 -0
  36. package/dist/bundle/lib.js +2 -2
  37. package/dist/bundle/main.js +2 -2
  38. package/package.json +3 -3
  39. package/src/app/routes/_authenticated/_orders/components/customer-address-selector.tsx +172 -41
  40. package/src/app/routes/_authenticated/_orders/orders_.$id_.modify.tsx +22 -0
  41. package/src/app/routes/_authenticated/_orders/orders_.draft.$id.tsx +61 -38
  42. package/src/app/routes/_authenticated/_orders/utils/use-modify-order.ts +26 -0
  43. package/src/i18n/locales/ar.po +69 -9
  44. package/src/i18n/locales/bg.po +69 -9
  45. package/src/i18n/locales/cs.po +69 -9
  46. package/src/i18n/locales/de.po +69 -9
  47. package/src/i18n/locales/en.po +69 -9
  48. package/src/i18n/locales/es.po +69 -9
  49. package/src/i18n/locales/fa.po +69 -9
  50. package/src/i18n/locales/fr.po +69 -9
  51. package/src/i18n/locales/he.po +69 -9
  52. package/src/i18n/locales/hr.po +69 -9
  53. package/src/i18n/locales/hu.po +69 -9
  54. package/src/i18n/locales/it.po +69 -9
  55. package/src/i18n/locales/ja.po +69 -9
  56. package/src/i18n/locales/ko.po +69 -9
  57. package/src/i18n/locales/nb.po +69 -9
  58. package/src/i18n/locales/ne.po +69 -9
  59. package/src/i18n/locales/nl.po +69 -9
  60. package/src/i18n/locales/pl.po +69 -9
  61. package/src/i18n/locales/pt_BR.po +69 -9
  62. package/src/i18n/locales/pt_PT.po +69 -9
  63. package/src/i18n/locales/ro.po +69 -9
  64. package/src/i18n/locales/ru.po +69 -9
  65. package/src/i18n/locales/sv.po +69 -9
  66. package/src/i18n/locales/tr.po +69 -9
  67. package/src/i18n/locales/uk.po +69 -9
  68. package/src/i18n/locales/uz.po +69 -9
  69. package/src/i18n/locales/zh_Hans.po +69 -9
  70. package/src/i18n/locales/zh_Hant.po +69 -9
  71. package/src/lib/components/shared/assign-to-channel-dialog.tsx +56 -31
  72. package/src/lib/components/shared/assign-to-channels.spec.ts +45 -0
  73. package/src/lib/components/shared/assign-to-channels.ts +31 -0
  74. package/src/lib/components/shared/customer-address-form.tsx +51 -36
  75. package/src/lib/components/shared/customer-selector.tsx +221 -39
  76. package/src/lib/framework/form-engine/form-schema-tools.spec.ts +48 -0
  77. package/src/lib/framework/form-engine/form-schema-tools.ts +1 -1
  78. package/src/lib/framework/page/list-page.spec.tsx +62 -0
  79. package/src/lib/framework/page/list-page.tsx +27 -0
  80. package/src/lib/graphql/common-operations.ts +33 -0
  81. package/dist/bundle/chunks/ar-DATX7H2x.js +0 -4
  82. package/dist/bundle/chunks/bg-DHS8PDKd.js +0 -4
  83. package/dist/bundle/chunks/cs-CGhaHD2Z.js +0 -4
  84. package/dist/bundle/chunks/de-BMtF5EY3.js +0 -4
  85. package/dist/bundle/chunks/en-DucAVNrv.js +0 -4
  86. package/dist/bundle/chunks/es-FBktM7AP.js +0 -4
  87. package/dist/bundle/chunks/fa-Dl5QN-Zp.js +0 -4
  88. package/dist/bundle/chunks/fr-TPBsPGD2.js +0 -4
  89. package/dist/bundle/chunks/he-CvNLNPHS.js +0 -4
  90. package/dist/bundle/chunks/hr-7QRa6pq0.js +0 -4
  91. package/dist/bundle/chunks/hu-BUCwangz.js +0 -4
  92. package/dist/bundle/chunks/it-DcVNes47.js +0 -4
  93. package/dist/bundle/chunks/ja-C-C3Z-2D.js +0 -4
  94. package/dist/bundle/chunks/ko-B41VP-2G.js +0 -4
  95. package/dist/bundle/chunks/nb-q5my_SIJ.js +0 -4
  96. package/dist/bundle/chunks/ne-DksEv0gd.js +0 -4
  97. package/dist/bundle/chunks/nl-BEWvhJPb.js +0 -4
  98. package/dist/bundle/chunks/pl-DRf5xQAy.js +0 -4
  99. package/dist/bundle/chunks/pt_BR-DEOQ9Vgg.js +0 -4
  100. package/dist/bundle/chunks/pt_PT-DvDBycjC.js +0 -4
  101. package/dist/bundle/chunks/ro-CNbK5V7l.js +0 -4
  102. package/dist/bundle/chunks/ru-BJ395nXO.js +0 -4
  103. package/dist/bundle/chunks/sv-Bxi6B55d.js +0 -4
  104. package/dist/bundle/chunks/tr-D2FNyrS9.js +0 -4
  105. package/dist/bundle/chunks/uk-C3iewRAE.js +0 -4
  106. package/dist/bundle/chunks/uz-DDVd9bpR.js +0 -4
  107. package/dist/bundle/chunks/zh_Hans-DFK1UiKv.js +0 -4
  108. package/dist/bundle/chunks/zh_Hant-BWs2-32i.js +0 -4
@@ -9,8 +9,8 @@ import * as ReactDOM from "react-dom";
9
9
  import ReactDOM__default, { unstable_batchedUpdates, createPortal } from "react-dom";
10
10
  import { useBlocker, Link as Link$2, useRouter, useRouterState, useNavigate, Outlet, createRoute, createRouter } from "@tanstack/react-router";
11
11
  import { uiConfig } from "virtual:vendure-ui-config";
12
- import { schemaInfo } from "virtual:admin-api-schema";
13
12
  import { i18n } from "@lingui/core";
13
+ import { schemaInfo } from "virtual:admin-api-schema";
14
14
  import { runDashboardExtensions } from "virtual:dashboard-extensions";
15
15
  const toKebabCase$1 = (string2) => string2.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
16
16
  const mergeClasses$1 = (...classes) => classes.filter((className, index2, array2) => {
@@ -39294,7 +39294,7 @@ function useDayPickerLocale() {
39294
39294
  } = useDisplayLocale();
39295
39295
  const [calendarLocale, setCalendarLocale] = useState(void 0);
39296
39296
  useEffect(() => {
39297
- import("./locale-BSCAi77j.js").then((mod) => {
39297
+ import("./locale-CJZpQnsu.js").then((mod) => {
39298
39298
  setCalendarLocale(bcpTagToDatePickerLocale(bcp47Tag, mod));
39299
39299
  });
39300
39300
  }, [bcp47Tag]);
@@ -88684,7 +88684,7 @@ function useSortedLanguages(availableLanguages) {
88684
88684
  label: formatLanguageName(code)
88685
88685
  })).sort((a2, b2) => a2.label.localeCompare(b2.label)), [availableLanguages, formatLanguageName]);
88686
88686
  }
88687
- const localeMessages = /* @__PURE__ */ Object.assign({ "../../i18n/locales/ar.po": () => import("./ar-DATX7H2x.js"), "../../i18n/locales/bg.po": () => import("./bg-DHS8PDKd.js"), "../../i18n/locales/cs.po": () => import("./cs-CGhaHD2Z.js"), "../../i18n/locales/de.po": () => import("./de-BMtF5EY3.js"), "../../i18n/locales/en.po": () => import("./en-DucAVNrv.js"), "../../i18n/locales/es.po": () => import("./es-FBktM7AP.js"), "../../i18n/locales/fa.po": () => import("./fa-Dl5QN-Zp.js"), "../../i18n/locales/fr.po": () => import("./fr-TPBsPGD2.js"), "../../i18n/locales/he.po": () => import("./he-CvNLNPHS.js"), "../../i18n/locales/hr.po": () => import("./hr-7QRa6pq0.js"), "../../i18n/locales/hu.po": () => import("./hu-BUCwangz.js"), "../../i18n/locales/it.po": () => import("./it-DcVNes47.js"), "../../i18n/locales/ja.po": () => import("./ja-C-C3Z-2D.js"), "../../i18n/locales/ko.po": () => import("./ko-B41VP-2G.js"), "../../i18n/locales/nb.po": () => import("./nb-q5my_SIJ.js"), "../../i18n/locales/ne.po": () => import("./ne-DksEv0gd.js"), "../../i18n/locales/nl.po": () => import("./nl-BEWvhJPb.js"), "../../i18n/locales/pl.po": () => import("./pl-DRf5xQAy.js"), "../../i18n/locales/pt_BR.po": () => import("./pt_BR-DEOQ9Vgg.js"), "../../i18n/locales/pt_PT.po": () => import("./pt_PT-DvDBycjC.js"), "../../i18n/locales/ro.po": () => import("./ro-CNbK5V7l.js"), "../../i18n/locales/ru.po": () => import("./ru-BJ395nXO.js"), "../../i18n/locales/sv.po": () => import("./sv-Bxi6B55d.js"), "../../i18n/locales/tr.po": () => import("./tr-D2FNyrS9.js"), "../../i18n/locales/uk.po": () => import("./uk-C3iewRAE.js"), "../../i18n/locales/uz.po": () => import("./uz-DDVd9bpR.js"), "../../i18n/locales/zh_Hans.po": () => import("./zh_Hans-DFK1UiKv.js"), "../../i18n/locales/zh_Hant.po": () => import("./zh_Hant-BWs2-32i.js") });
88687
+ const localeMessages = /* @__PURE__ */ Object.assign({ "../../i18n/locales/ar.po": () => import("./ar-C8HyGurR.js"), "../../i18n/locales/bg.po": () => import("./bg--aJe6weI.js"), "../../i18n/locales/cs.po": () => import("./cs-DiORN27q.js"), "../../i18n/locales/de.po": () => import("./de-BIbDqHi0.js"), "../../i18n/locales/en.po": () => import("./en-BIXvudTL.js"), "../../i18n/locales/es.po": () => import("./es-CtrB4rBI.js"), "../../i18n/locales/fa.po": () => import("./fa-psHxNGfe.js"), "../../i18n/locales/fr.po": () => import("./fr-C5nCJ4dT.js"), "../../i18n/locales/he.po": () => import("./he-Bf9mrxS9.js"), "../../i18n/locales/hr.po": () => import("./hr-ukhxxcHj.js"), "../../i18n/locales/hu.po": () => import("./hu-C5Rw37rH.js"), "../../i18n/locales/it.po": () => import("./it-9Wz02yYH.js"), "../../i18n/locales/ja.po": () => import("./ja-Dws9HYMD.js"), "../../i18n/locales/ko.po": () => import("./ko-BvE54r17.js"), "../../i18n/locales/nb.po": () => import("./nb-C5b8s5AZ.js"), "../../i18n/locales/ne.po": () => import("./ne-DidgSoes.js"), "../../i18n/locales/nl.po": () => import("./nl-Bs2EmoET.js"), "../../i18n/locales/pl.po": () => import("./pl-ByMSgi7e.js"), "../../i18n/locales/pt_BR.po": () => import("./pt_BR-CTGGI34p.js"), "../../i18n/locales/pt_PT.po": () => import("./pt_PT-BMabWU8-.js"), "../../i18n/locales/ro.po": () => import("./ro-DLijHEde.js"), "../../i18n/locales/ru.po": () => import("./ru-sL_M_iwR.js"), "../../i18n/locales/sv.po": () => import("./sv-C6w42jAh.js"), "../../i18n/locales/tr.po": () => import("./tr-Lr8P315q.js"), "../../i18n/locales/uk.po": () => import("./uk-5I_XIBoN.js"), "../../i18n/locales/uz.po": () => import("./uz-BjRS1co1.js"), "../../i18n/locales/zh_Hans.po": () => import("./zh_Hans-Bqmum3_n.js"), "../../i18n/locales/zh_Hant.po": () => import("./zh_Hant-pqbmvylJ.js") });
88688
88688
  async function loadI18nMessages(locale2) {
88689
88689
  const loader = localeMessages[`../../i18n/locales/${locale2}.po`];
88690
88690
  if (!loader) {
@@ -103005,6 +103005,26 @@ function AssetPreviewDialog({
103005
103005
  /* @__PURE__ */ jsx("div", { className: "h-full p-6", children: /* @__PURE__ */ jsx(AssetPreview, { asset, assets, customFields, onAssetUpdated }) })
103006
103006
  ] }) });
103007
103007
  }
103008
+ async function assignToChannels(channelIds, buildInput, mutationFn) {
103009
+ const result = {
103010
+ succeeded: [],
103011
+ failed: []
103012
+ };
103013
+ for (const channelId of channelIds) {
103014
+ try {
103015
+ await mutationFn({
103016
+ input: buildInput(channelId)
103017
+ });
103018
+ result.succeeded.push(channelId);
103019
+ } catch (reason) {
103020
+ result.failed.push({
103021
+ channelId,
103022
+ reason
103023
+ });
103024
+ }
103025
+ }
103026
+ return result;
103027
+ }
103008
103028
  function AssignToChannelDialog({
103009
103029
  open,
103010
103030
  onOpenChange,
@@ -103020,7 +103040,6 @@ function AssignToChannelDialog({
103020
103040
  _: _t
103021
103041
  } = useLingui();
103022
103042
  const [selectedChannelIds, setSelectedChannelIds] = useState([]);
103023
- const [isAssigning, setIsAssigning] = useState(false);
103024
103043
  const {
103025
103044
  channels,
103026
103045
  activeChannel
@@ -103035,53 +103054,98 @@ function AssignToChannelDialog({
103035
103054
  label: ch.code,
103036
103055
  display: /* @__PURE__ */ jsx(ChannelCodeLabel, { code: ch.code })
103037
103056
  }));
103038
- const handleAssign = async () => {
103039
- setIsAssigning(true);
103040
- try {
103041
- const results = await Promise.allSettled(selectedChannelIds.map((channelId) => mutationFn({
103042
- input: buildInput(channelId, additionalData)
103043
- })));
103044
- const failedChannelIds = results.flatMap((r2, i2) => r2.status === "rejected" ? [selectedChannelIds[i2]] : []);
103045
- const succeededCount = results.length - failedChannelIds.length;
103046
- if (succeededCount > 0) {
103047
- onSuccess?.();
103057
+ const {
103058
+ mutate: mutate2,
103059
+ isPending
103060
+ } = useMutation({
103061
+ mutationFn: () => assignToChannels(selectedChannelIds, (channelId) => buildInput(channelId, additionalData), mutationFn),
103062
+ onSuccess: ({
103063
+ succeeded,
103064
+ failed
103065
+ }) => {
103066
+ if (failed.length) {
103067
+ console.error("Failed to assign to channels", failed);
103048
103068
  }
103049
- if (failedChannelIds.length === 0) {
103050
- toast.success(_t(
103069
+ const failedCodes = failed.map((f2) => channels.find((c2) => c2.id === f2.channelId)?.code ?? f2.channelId).join(", ");
103070
+ if (failed.length === 0) {
103071
+ toast.success(i18n._(
103051
103072
  /*i18n*/
103052
103073
  {
103053
- id: "IvR5Dq",
103074
+ id: "4bwknQ",
103054
103075
  values: {
103055
- 0: selectedChannelIds.length,
103076
+ 0: succeeded.length,
103077
+ 1: succeeded.length,
103078
+ 2: succeeded.length,
103056
103079
  entityIdsLength,
103057
103080
  entityType
103058
103081
  }
103059
103082
  }
103060
103083
  ));
103084
+ setSelectedChannelIds([]);
103085
+ onSuccess?.();
103061
103086
  onOpenChange(false);
103087
+ } else if (succeeded.length === 0) {
103088
+ toast.error(i18n._(
103089
+ /*i18n*/
103090
+ {
103091
+ id: "mqhntj",
103092
+ values: {
103093
+ 0: failed.length,
103094
+ 1: failed.length,
103095
+ 2: failed.length,
103096
+ entityIdsLength,
103097
+ entityType
103098
+ }
103099
+ }
103100
+ ), {
103101
+ description: failedCodes
103102
+ });
103062
103103
  } else {
103063
- const firstRejected = results.find((r2) => r2.status === "rejected");
103064
- const firstReason = firstRejected?.status === "rejected" ? firstRejected.reason : void 0;
103065
- const description = firstReason instanceof Error ? firstReason.message : void 0;
103066
- setSelectedChannelIds(failedChannelIds);
103067
- toast.error(_t(
103104
+ toast.warning(i18n._(
103068
103105
  /*i18n*/
103069
103106
  {
103070
- id: "KCydxK",
103107
+ id: "4bwknQ",
103071
103108
  values: {
103072
- 0: failedChannelIds.length,
103073
- 1: selectedChannelIds.length,
103109
+ 0: succeeded.length,
103110
+ 1: succeeded.length,
103111
+ 2: succeeded.length,
103074
103112
  entityIdsLength,
103075
103113
  entityType
103076
103114
  }
103077
103115
  }
103078
103116
  ), {
103079
- description
103117
+ description: _t(
103118
+ /*i18n*/
103119
+ {
103120
+ id: "Ll4uCx",
103121
+ values: {
103122
+ failedCodes
103123
+ }
103124
+ }
103125
+ )
103080
103126
  });
103127
+ setSelectedChannelIds(failed.map((f2) => f2.channelId));
103128
+ onSuccess?.();
103081
103129
  }
103082
- } finally {
103083
- setIsAssigning(false);
103130
+ },
103131
+ onError: () => {
103132
+ toast.error(_t(
103133
+ /*i18n*/
103134
+ {
103135
+ id: "Grk2SU",
103136
+ values: {
103137
+ entityIdsLength,
103138
+ entityType
103139
+ }
103140
+ }
103141
+ ));
103084
103142
  }
103143
+ });
103144
+ const handleAssign = () => {
103145
+ if (selectedChannelIds.length === 0) {
103146
+ return;
103147
+ }
103148
+ mutate2();
103085
103149
  };
103086
103150
  return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [
103087
103151
  /* @__PURE__ */ jsxs(DialogHeader, { children: [
@@ -103117,7 +103181,7 @@ function AssignToChannelDialog({
103117
103181
  {
103118
103182
  id: "PLeYjq"
103119
103183
  }
103120
- ), className: "w-full" })
103184
+ ), showSearch: true, className: "w-full" })
103121
103185
  ] }),
103122
103186
  additionalFields
103123
103187
  ] }),
@@ -103126,7 +103190,7 @@ function AssignToChannelDialog({
103126
103190
  {
103127
103191
  id: "dEgA5A"
103128
103192
  } }) }),
103129
- /* @__PURE__ */ jsx(Button$1, { onClick: handleAssign, disabled: selectedChannelIds.length === 0 || isAssigning, children: /* @__PURE__ */ jsx(Trans, { .../*i18n*/
103193
+ /* @__PURE__ */ jsx(Button$1, { onClick: handleAssign, disabled: selectedChannelIds.length === 0 || isPending, children: /* @__PURE__ */ jsx(Trans, { .../*i18n*/
103130
103194
  {
103131
103195
  id: "kaEPzR"
103132
103196
  } }) })
@@ -103839,7 +103903,9 @@ function CustomerAddressForm({
103839
103903
  address,
103840
103904
  setValuesForUpdate,
103841
103905
  onSubmit,
103842
- onCancel
103906
+ onCancel,
103907
+ hideDefaultAddressFlags = false,
103908
+ submitLabel
103843
103909
  }) {
103844
103910
  const {
103845
103911
  _: _t
@@ -103918,7 +103984,7 @@ function CustomerAddressForm({
103918
103984
  id: "dJW40d"
103919
103985
  } }), render: ({
103920
103986
  field
103921
- }) => /* @__PURE__ */ jsx(Input$2, { placeholder: "Postal Code", ...field, value: field.value || "" }) }),
103987
+ }) => /* @__PURE__ */ jsx(Input$2, { placeholder: "Postal Code (optional)", ...field, value: field.value || "" }) }),
103922
103988
  /* @__PURE__ */ jsx(FormFieldWrapper, { control: form.control, name: "countryCode", label: /* @__PURE__ */ jsx(Trans, { .../*i18n*/
103923
103989
  {
103924
103990
  id: "JNCzPW"
@@ -103941,7 +104007,7 @@ function CustomerAddressForm({
103941
104007
  }) => /* @__PURE__ */ jsx(Input$2, { placeholder: "Phone (optional)", ...field, value: field.value || "" }) })
103942
104008
  ] }),
103943
104009
  /* @__PURE__ */ jsx(CustomFieldsForm, { entityType: "Address", control: form.control }),
103944
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4 pt-2", children: [
104010
+ !hideDefaultAddressFlags && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4 pt-2", children: [
103945
104011
  /* @__PURE__ */ jsx(Controller, { control: form.control, name: "defaultShippingAddress", render: ({
103946
104012
  field
103947
104013
  }) => /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-start space-x-3", children: [
@@ -103978,7 +104044,7 @@ function CustomerAddressForm({
103978
104044
  {
103979
104045
  id: "dEgA5A"
103980
104046
  } }) }),
103981
- /* @__PURE__ */ jsx(Button$1, { type: "submit", children: /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104047
+ /* @__PURE__ */ jsx(Button$1, { type: "submit", children: submitLabel ?? /* @__PURE__ */ jsx(Trans, { .../*i18n*/
103982
104048
  {
103983
104049
  id: "nm+muM"
103984
104050
  } }) })
@@ -103998,8 +104064,26 @@ const customersDocument = graphql(`
103998
104064
  }
103999
104065
  }
104000
104066
  `);
104001
- function CustomerSelector(props) {
104002
- const [open, setOpen] = useState(false);
104067
+ const createCustomerFormSchema = objectType({
104068
+ title: stringType().optional(),
104069
+ firstName: stringType().min(1, {
104070
+ message: "First name is required"
104071
+ }),
104072
+ lastName: stringType().min(1, {
104073
+ message: "Last name is required"
104074
+ }),
104075
+ emailAddress: stringType().min(1, {
104076
+ message: "Email address is required"
104077
+ }).email(),
104078
+ phoneNumber: stringType().optional(),
104079
+ customFields: anyType().optional()
104080
+ });
104081
+ function CustomerSearch({
104082
+ onSelect
104083
+ }) {
104084
+ const {
104085
+ _: _t
104086
+ } = useLingui();
104003
104087
  const [searchTerm, setSearchTerm] = useState("");
104004
104088
  const debouncedSearchTerm = useDebounce(searchTerm, 300);
104005
104089
  const {
@@ -104029,40 +104113,157 @@ function CustomerSelector(props) {
104029
104113
  staleTime: 1e3 * 60
104030
104114
  // 1 minute
104031
104115
  });
104032
- const handleSearch = (value2) => {
104033
- setSearchTerm(value2);
104034
- };
104035
- return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
104036
- /* @__PURE__ */ jsxs(PopoverTrigger2, { render: /* @__PURE__ */ jsx(Button$1, { variant: "outline", size: "sm", type: "button", disabled: props.readOnly, className: "gap-2" }), children: [
104037
- /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
104038
- props.label ?? /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104116
+ return /* @__PURE__ */ jsxs(Command, { shouldFilter: false, children: [
104117
+ /* @__PURE__ */ jsx(CommandInput, { placeholder: _t(
104118
+ /*i18n*/
104039
104119
  {
104040
- id: "C0uyNO"
104041
- } })
104120
+ id: "6Q2qjr"
104121
+ }
104122
+ ), onValueChange: setSearchTerm, className: "h-10 flex-1 bg-transparent outline-none placeholder:text-muted-foreground" }),
104123
+ /* @__PURE__ */ jsxs(CommandList, { children: [
104124
+ /* @__PURE__ */ jsx(CommandEmpty, { children: isLoading ? /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104125
+ {
104126
+ id: "Z3FXyt"
104127
+ } }) : /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104128
+ {
104129
+ id: "BLXWJv"
104130
+ } }) }),
104131
+ data?.customers.items.map((customer) => /* @__PURE__ */ jsxs(CommandItem, { onSelect: () => onSelect(customer), className: "flex flex-col items-start", children: [
104132
+ /* @__PURE__ */ jsxs("div", { className: "font-medium", children: [
104133
+ customer.firstName,
104134
+ " ",
104135
+ customer.lastName
104136
+ ] }),
104137
+ /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: customer.emailAddress })
104138
+ ] }, customer.id))
104139
+ ] })
104140
+ ] });
104141
+ }
104142
+ function CreateCustomerForm({
104143
+ onSubmit,
104144
+ onCancel
104145
+ }) {
104146
+ const form = useForm({
104147
+ resolver: a$1(createCustomerFormSchema),
104148
+ defaultValues: {
104149
+ title: "",
104150
+ firstName: "",
104151
+ lastName: "",
104152
+ emailAddress: "",
104153
+ phoneNumber: "",
104154
+ customFields: {}
104155
+ },
104156
+ mode: "onChange"
104157
+ });
104158
+ return /* @__PURE__ */ jsx(Form, { ...form, children: /* @__PURE__ */ jsxs("form", { onSubmit: (e3) => {
104159
+ e3.stopPropagation();
104160
+ form.handleSubmit(onSubmit)(e3).catch(() => void 0);
104161
+ }, className: "space-y-4", children: [
104162
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4", children: [
104163
+ /* @__PURE__ */ jsx(FormFieldWrapper, { control: form.control, name: "title", label: /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104164
+ {
104165
+ id: "MHrjPM"
104166
+ } }), render: ({
104167
+ field
104168
+ }) => /* @__PURE__ */ jsx(Input$2, { ...field, value: field.value || "" }) }),
104169
+ /* @__PURE__ */ jsx(FormFieldWrapper, { control: form.control, name: "firstName", label: /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104170
+ {
104171
+ id: "V1EGGU"
104172
+ } }), render: ({
104173
+ field
104174
+ }) => /* @__PURE__ */ jsx(Input$2, { ...field, value: field.value || "" }) }),
104175
+ /* @__PURE__ */ jsx(FormFieldWrapper, { control: form.control, name: "lastName", label: /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104176
+ {
104177
+ id: "1ZaQUH"
104178
+ } }), render: ({
104179
+ field
104180
+ }) => /* @__PURE__ */ jsx(Input$2, { ...field, value: field.value || "" }) }),
104181
+ /* @__PURE__ */ jsx(FormFieldWrapper, { control: form.control, name: "emailAddress", label: /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104182
+ {
104183
+ id: "ATGYL1"
104184
+ } }), render: ({
104185
+ field
104186
+ }) => /* @__PURE__ */ jsx(Input$2, { ...field, value: field.value || "" }) }),
104187
+ /* @__PURE__ */ jsx(FormFieldWrapper, { control: form.control, name: "phoneNumber", label: /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104188
+ {
104189
+ id: "ZuLy43"
104190
+ } }), render: ({
104191
+ field
104192
+ }) => /* @__PURE__ */ jsx(Input$2, { ...field, value: field.value || "" }) })
104042
104193
  ] }),
104043
- /* @__PURE__ */ jsx(PopoverContent, { className: "p-0 w-[350px]", align: "start", children: /* @__PURE__ */ jsxs(Command, { shouldFilter: false, children: [
104044
- /* @__PURE__ */ jsx(CommandInput, { placeholder: "Search customers...", onValueChange: handleSearch, className: "h-10 flex-1 bg-transparent outline-none placeholder:text-muted-foreground" }),
104045
- /* @__PURE__ */ jsxs(CommandList, { children: [
104046
- /* @__PURE__ */ jsx(CommandEmpty, { children: isLoading ? /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104047
- {
104048
- id: "Z3FXyt"
104049
- } }) : /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104050
- {
104051
- id: "BLXWJv"
104052
- } }) }),
104053
- data?.customers.items.map((customer) => /* @__PURE__ */ jsxs(CommandItem, { onSelect: () => {
104054
- props.onSelect(customer);
104055
- setOpen(false);
104056
- }, className: "flex flex-col items-start", children: [
104057
- /* @__PURE__ */ jsxs("div", { className: "font-medium", children: [
104058
- customer.firstName,
104059
- " ",
104060
- customer.lastName
104061
- ] }),
104062
- /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: customer.emailAddress })
104063
- ] }, customer.id))
104064
- ] })
104065
- ] }) })
104194
+ /* @__PURE__ */ jsx(CustomFieldsForm, { entityType: "Customer", control: form.control }),
104195
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2 pt-2", children: [
104196
+ onCancel && /* @__PURE__ */ jsx(Button$1, { type: "button", variant: "outline", onClick: onCancel, children: /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104197
+ {
104198
+ id: "dEgA5A"
104199
+ } }) }),
104200
+ /* @__PURE__ */ jsx(Button$1, { type: "submit", disabled: !form.formState.isValid, children: /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104201
+ {
104202
+ id: "dxd1/G"
104203
+ } }) })
104204
+ ] })
104205
+ ] }) });
104206
+ }
104207
+ function CustomerSelector(props) {
104208
+ const [open, setOpen] = useState(false);
104209
+ const [activeTab, setActiveTab] = useState("existing");
104210
+ const trigger = /* @__PURE__ */ jsxs(PopoverTrigger2, { render: /* @__PURE__ */ jsx(Button$1, { variant: "outline", size: "sm", type: "button", disabled: props.readOnly, className: "gap-2" }), children: [
104211
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
104212
+ props.label ?? /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104213
+ {
104214
+ id: "C0uyNO"
104215
+ } })
104216
+ ] });
104217
+ if (!props.allowCreateNew) {
104218
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
104219
+ trigger,
104220
+ /* @__PURE__ */ jsx(PopoverContent, { className: "p-0 w-[350px]", align: "start", children: /* @__PURE__ */ jsx(CustomerSearch, { onSelect: (customer) => {
104221
+ props.onSelect(customer);
104222
+ setOpen(false);
104223
+ } }) })
104224
+ ] });
104225
+ }
104226
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: (isOpen, eventDetails) => {
104227
+ if (!isOpen && activeTab === "new") {
104228
+ return eventDetails.cancel();
104229
+ }
104230
+ setOpen(isOpen);
104231
+ if (!isOpen) {
104232
+ setActiveTab("existing");
104233
+ }
104234
+ }, children: [
104235
+ trigger,
104236
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-[420px] p-0", align: "start", children: /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxs(Tabs, { value: activeTab, onValueChange: setActiveTab, children: [
104237
+ /* @__PURE__ */ jsxs(TabsList2, { className: "grid w-full grid-cols-2", children: [
104238
+ /* @__PURE__ */ jsxs(TabsTrigger, { value: "existing", children: [
104239
+ /* @__PURE__ */ jsx(Users, { className: "mr-2 h-4 w-4" }),
104240
+ /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104241
+ {
104242
+ id: "LCVmor"
104243
+ } })
104244
+ ] }),
104245
+ /* @__PURE__ */ jsxs(TabsTrigger, { value: "new", children: [
104246
+ /* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
104247
+ /* @__PURE__ */ jsx(Trans, { .../*i18n*/
104248
+ {
104249
+ id: "3naYYC"
104250
+ } })
104251
+ ] })
104252
+ ] }),
104253
+ /* @__PURE__ */ jsx(TabsContent, { value: "existing", children: /* @__PURE__ */ jsx("div", { className: "mt-2 rounded-md border", children: /* @__PURE__ */ jsx(CustomerSearch, { onSelect: (customer) => {
104254
+ props.onSelect(customer);
104255
+ setOpen(false);
104256
+ setActiveTab("existing");
104257
+ } }) }) }),
104258
+ /* @__PURE__ */ jsx(TabsContent, { value: "new", children: /* @__PURE__ */ jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsx(CreateCustomerForm, { onSubmit: async (input) => {
104259
+ await props.onCreateNew?.(input);
104260
+ setOpen(false);
104261
+ setActiveTab("existing");
104262
+ }, onCancel: () => {
104263
+ setOpen(false);
104264
+ setActiveTab("existing");
104265
+ } }) }) })
104266
+ ] }) }) })
104066
104267
  ] });
104067
104268
  }
104068
104269
  function DetailPageButton({
@@ -130149,7 +130350,7 @@ function applyCustomFieldModifiers(zodType, customField) {
130149
130350
  if (customField.list) {
130150
130351
  modifiedType = arrayType(modifiedType);
130151
130352
  }
130152
- if (customField.nullable !== false) {
130353
+ if (customField.nullable !== false || customField.readonly) {
130153
130354
  modifiedType = modifiedType.optional().nullable();
130154
130355
  }
130155
130356
  if (customField.readonly) {
@@ -130676,6 +130877,9 @@ function ListPage({
130676
130877
  children,
130677
130878
  rowActions,
130678
130879
  transformData,
130880
+ transformQueryKey,
130881
+ disableViewOptions,
130882
+ includeSelectionColumn,
130679
130883
  setTableOptions,
130680
130884
  bulkActions,
130681
130885
  registerRefresher,
@@ -130770,6 +130974,9 @@ function ListPage({
130770
130974
  bulkActions,
130771
130975
  setTableOptions,
130772
130976
  transformData,
130977
+ transformQueryKey,
130978
+ disableViewOptions,
130979
+ includeSelectionColumn,
130773
130980
  registerRefresher
130774
130981
  };
130775
130982
  return /* @__PURE__ */ jsxs(Page, { pageId, children: [
@@ -130879,6 +131086,20 @@ const getEntityDuplicatorsDocument = graphql(`
130879
131086
  }
130880
131087
  }
130881
131088
  `, [configArgDefinitionFragment]);
131089
+ graphql(`
131090
+ mutation CreateCustomerInputTypeRef($input: CreateCustomerInput!) {
131091
+ createCustomer(input: $input) {
131092
+ __typename
131093
+ }
131094
+ }
131095
+ `);
131096
+ graphql(`
131097
+ mutation CreateAddressInputTypeRef($customerId: ID!, $input: CreateAddressInput!) {
131098
+ createCustomerAddress(customerId: $customerId, input: $input) {
131099
+ __typename
131100
+ }
131101
+ }
131102
+ `);
130882
131103
  function useGroupedPermissions() {
130883
131104
  const serverConfig = useServerConfig();
130884
131105
  const permissionDefinitions = serverConfig?.permissions ?? [];