@lodashventure/medusa-quotation 1.5.1 → 1.5.2
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.
|
@@ -375,10 +375,11 @@ const useDeleteQuote = (id, options) => {
|
|
|
375
375
|
return { mutate, mutateAsync: mutate, isPending, error };
|
|
376
376
|
};
|
|
377
377
|
const useQuoteStore = () => {
|
|
378
|
-
const [
|
|
378
|
+
const [store, setStore] = react.useState(null);
|
|
379
379
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
380
380
|
const [error, setError] = react.useState(null);
|
|
381
381
|
const fetchQuoteStore = react.useCallback(async () => {
|
|
382
|
+
var _a;
|
|
382
383
|
try {
|
|
383
384
|
setIsLoading(true);
|
|
384
385
|
setError(null);
|
|
@@ -386,9 +387,16 @@ const useQuoteStore = () => {
|
|
|
386
387
|
`/admin/quote-store`,
|
|
387
388
|
{}
|
|
388
389
|
);
|
|
389
|
-
|
|
390
|
+
setStore((response == null ? void 0 : response.store) ?? null);
|
|
390
391
|
} catch (err) {
|
|
391
|
-
|
|
392
|
+
setStore(null);
|
|
393
|
+
const status = ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.status) ?? (err == null ? void 0 : err.status) ?? null;
|
|
394
|
+
if (status === 404) {
|
|
395
|
+
setStore(null);
|
|
396
|
+
setError(null);
|
|
397
|
+
} else {
|
|
398
|
+
setError(err);
|
|
399
|
+
}
|
|
392
400
|
} finally {
|
|
393
401
|
setIsLoading(false);
|
|
394
402
|
}
|
|
@@ -397,7 +405,7 @@ const useQuoteStore = () => {
|
|
|
397
405
|
fetchQuoteStore();
|
|
398
406
|
}, [fetchQuoteStore]);
|
|
399
407
|
return {
|
|
400
|
-
|
|
408
|
+
store,
|
|
401
409
|
isLoading,
|
|
402
410
|
error,
|
|
403
411
|
refetch: fetchQuoteStore
|
|
@@ -815,13 +823,13 @@ const SequenceManagementModal = ({
|
|
|
815
823
|
const isLoading = createSequence.isPending || updateSequence.isPending || deleteSequence.isPending;
|
|
816
824
|
if (!quote_config) {
|
|
817
825
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.FocusModal.Content, { children: [
|
|
818
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", children: "Manage Quote Sequences" }) }),
|
|
826
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", children: "Manage Quote Sequences" }) }) }),
|
|
819
827
|
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Body, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6 text-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", children: "Please configure quote settings first before managing sequences." }) }) })
|
|
820
828
|
] }) });
|
|
821
829
|
}
|
|
822
830
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
823
831
|
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.FocusModal.Content, { children: [
|
|
824
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-between items-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", children: "Manage Quote Sequences" }) }) }),
|
|
832
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-between items-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", children: "Manage Quote Sequences" }) }) }) }),
|
|
825
833
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.FocusModal.Body, { children: [
|
|
826
834
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end mt-6 pr-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: handleCreate, disabled: isLoadingSequences, children: "Create New Sequence" }) }),
|
|
827
835
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: isLoadingSequences ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center py-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", children: "Loading sequences..." }) }) : /* @__PURE__ */ jsxRuntime.jsxs(ui.Table, { children: [
|
|
@@ -886,10 +894,10 @@ const SequenceManagementModal = ({
|
|
|
886
894
|
] })
|
|
887
895
|
] }) }),
|
|
888
896
|
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal, { open: formOpen, onOpenChange: setFormOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.FocusModal.Content, { children: [
|
|
889
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Heading, { level: "h2", children: [
|
|
897
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Heading, { level: "h2", children: [
|
|
890
898
|
editingSequence ? "Update" : "Create",
|
|
891
899
|
" Quote Sequence"
|
|
892
|
-
] }) }),
|
|
900
|
+
] }) }) }),
|
|
893
901
|
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
894
902
|
"form",
|
|
895
903
|
{
|
|
@@ -1155,10 +1163,10 @@ const QuotationConfig = () => {
|
|
|
1155
1163
|
}
|
|
1156
1164
|
),
|
|
1157
1165
|
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.FocusModal.Content, { children: [
|
|
1158
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsxs("h2", { className: "text-xl font-semibold", children: [
|
|
1166
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs("h2", { className: "text-xl font-semibold", children: [
|
|
1159
1167
|
hasExistingConfig ? "Update" : "Create",
|
|
1160
1168
|
" Quotation Sequence Configuration"
|
|
1161
|
-
] }) }),
|
|
1169
|
+
] }) }) }),
|
|
1162
1170
|
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1163
1171
|
"form",
|
|
1164
1172
|
{
|
|
@@ -1305,7 +1313,7 @@ const StoreConfig = () => {
|
|
|
1305
1313
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1306
1314
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => setOpen(true), children: store ? "Edit Store Information" : "Configure Store Information" }),
|
|
1307
1315
|
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.FocusModal.Content, { children: [
|
|
1308
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-xl font-semibold", children: store ? "Edit Store Information" : "Configure Store Information" }) }),
|
|
1316
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-xl font-semibold", children: store ? "Edit Store Information" : "Configure Store Information" }) }) }),
|
|
1309
1317
|
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1310
1318
|
"form",
|
|
1311
1319
|
{
|
|
@@ -2281,7 +2289,12 @@ const QuoteDetails = () => {
|
|
|
2281
2289
|
const { generatePdf, downloadPdf, pdfUrl } = useQuotePdf();
|
|
2282
2290
|
const { store } = useQuoteStore();
|
|
2283
2291
|
const draftOrderId = quote == null ? void 0 : quote.draft_order_id;
|
|
2284
|
-
const {
|
|
2292
|
+
const {
|
|
2293
|
+
order: preview,
|
|
2294
|
+
isLoading: isPreviewLoading,
|
|
2295
|
+
error: previewError,
|
|
2296
|
+
refetch: refetchPreview
|
|
2297
|
+
} = useOrderPreview(
|
|
2285
2298
|
draftOrderId,
|
|
2286
2299
|
{
|
|
2287
2300
|
fields: DEFAULT_ORDER_FIELDS
|
|
@@ -2478,9 +2491,8 @@ const QuoteDetails = () => {
|
|
|
2478
2491
|
if (isPreviewLoading) {
|
|
2479
2492
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
2480
2493
|
}
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
}
|
|
2494
|
+
const previewUnavailable = !isPreviewLoading && (!preview || !!previewError || !draftOrderId);
|
|
2495
|
+
const previewErrorMessage = previewError instanceof Error ? previewError.message : "Unable to load the latest order preview.";
|
|
2484
2496
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-3", children: [
|
|
2485
2497
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-x-4 lg:flex-row xl:items-start", children: [
|
|
2486
2498
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full flex-col gap-y-3", children: [
|
|
@@ -2503,7 +2515,19 @@ const QuoteDetails = () => {
|
|
|
2503
2515
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", children: "Quote Summary" }),
|
|
2504
2516
|
/* @__PURE__ */ jsxRuntime.jsx(StatusDisplay, { status: quote.status })
|
|
2505
2517
|
] }),
|
|
2506
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2518
|
+
previewUnavailable ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-2 px-6 py-4", children: [
|
|
2519
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", children: draftOrderId ? previewErrorMessage : "No order preview is available for this quote." }),
|
|
2520
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle text-sm", children: "The quote details are still accessible, but totals may be outdated until the preview can be reloaded." }),
|
|
2521
|
+
draftOrderId && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2522
|
+
ui.Button,
|
|
2523
|
+
{
|
|
2524
|
+
size: "small",
|
|
2525
|
+
variant: "secondary",
|
|
2526
|
+
onClick: () => refetchPreview(),
|
|
2527
|
+
children: "Retry loading preview"
|
|
2528
|
+
}
|
|
2529
|
+
) })
|
|
2530
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(QuoteItems, { order: quote.draft_order, preview }),
|
|
2507
2531
|
/* @__PURE__ */ jsxRuntime.jsx(TotalsBreakdown, { order: quote.draft_order }),
|
|
2508
2532
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: " flex flex-col gap-y-2 px-6 py-4", children: [
|
|
2509
2533
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
|
|
@@ -3335,7 +3359,7 @@ const ManageQuoteForm = ({ order }) => {
|
|
|
3335
3359
|
) }) })
|
|
3336
3360
|
] }),
|
|
3337
3361
|
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal, { open: openProductModal, onOpenChange: setOpenProductModal, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.FocusModal.Content, { children: [
|
|
3338
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, {
|
|
3362
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", children: "Add Product" }) }) }),
|
|
3339
3363
|
/* @__PURE__ */ jsxRuntime.jsx(ui.FocusModal.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3340
3364
|
ProductSelector,
|
|
3341
3365
|
{
|
|
@@ -371,10 +371,11 @@ const useDeleteQuote = (id, options) => {
|
|
|
371
371
|
return { mutate, mutateAsync: mutate, isPending, error };
|
|
372
372
|
};
|
|
373
373
|
const useQuoteStore = () => {
|
|
374
|
-
const [
|
|
374
|
+
const [store, setStore] = useState(null);
|
|
375
375
|
const [isLoading, setIsLoading] = useState(true);
|
|
376
376
|
const [error, setError] = useState(null);
|
|
377
377
|
const fetchQuoteStore = useCallback(async () => {
|
|
378
|
+
var _a;
|
|
378
379
|
try {
|
|
379
380
|
setIsLoading(true);
|
|
380
381
|
setError(null);
|
|
@@ -382,9 +383,16 @@ const useQuoteStore = () => {
|
|
|
382
383
|
`/admin/quote-store`,
|
|
383
384
|
{}
|
|
384
385
|
);
|
|
385
|
-
|
|
386
|
+
setStore((response == null ? void 0 : response.store) ?? null);
|
|
386
387
|
} catch (err) {
|
|
387
|
-
|
|
388
|
+
setStore(null);
|
|
389
|
+
const status = ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.status) ?? (err == null ? void 0 : err.status) ?? null;
|
|
390
|
+
if (status === 404) {
|
|
391
|
+
setStore(null);
|
|
392
|
+
setError(null);
|
|
393
|
+
} else {
|
|
394
|
+
setError(err);
|
|
395
|
+
}
|
|
388
396
|
} finally {
|
|
389
397
|
setIsLoading(false);
|
|
390
398
|
}
|
|
@@ -393,7 +401,7 @@ const useQuoteStore = () => {
|
|
|
393
401
|
fetchQuoteStore();
|
|
394
402
|
}, [fetchQuoteStore]);
|
|
395
403
|
return {
|
|
396
|
-
|
|
404
|
+
store,
|
|
397
405
|
isLoading,
|
|
398
406
|
error,
|
|
399
407
|
refetch: fetchQuoteStore
|
|
@@ -811,13 +819,13 @@ const SequenceManagementModal = ({
|
|
|
811
819
|
const isLoading = createSequence.isPending || updateSequence.isPending || deleteSequence.isPending;
|
|
812
820
|
if (!quote_config) {
|
|
813
821
|
return /* @__PURE__ */ jsx(FocusModal, { open, onOpenChange, children: /* @__PURE__ */ jsxs(FocusModal.Content, { children: [
|
|
814
|
-
/* @__PURE__ */ jsx(FocusModal.Header, { children: /* @__PURE__ */ jsx(Heading, { level: "h2", children: "Manage Quote Sequences" }) }),
|
|
822
|
+
/* @__PURE__ */ jsx(FocusModal.Header, { children: /* @__PURE__ */ jsx(FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { level: "h2", children: "Manage Quote Sequences" }) }) }),
|
|
815
823
|
/* @__PURE__ */ jsx(FocusModal.Body, { children: /* @__PURE__ */ jsx("div", { className: "p-6 text-center", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "Please configure quote settings first before managing sequences." }) }) })
|
|
816
824
|
] }) });
|
|
817
825
|
}
|
|
818
826
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
819
827
|
/* @__PURE__ */ jsx(FocusModal, { open, onOpenChange, children: /* @__PURE__ */ jsxs(FocusModal.Content, { children: [
|
|
820
|
-
/* @__PURE__ */ jsx(FocusModal.Header, { children: /* @__PURE__ */ jsx("div", { className: "flex justify-between items-center", children: /* @__PURE__ */ jsx(Heading, { level: "h2", children: "Manage Quote Sequences" }) }) }),
|
|
828
|
+
/* @__PURE__ */ jsx(FocusModal.Header, { children: /* @__PURE__ */ jsx("div", { className: "flex justify-between items-center", children: /* @__PURE__ */ jsx(FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { level: "h2", children: "Manage Quote Sequences" }) }) }) }),
|
|
821
829
|
/* @__PURE__ */ jsxs(FocusModal.Body, { children: [
|
|
822
830
|
/* @__PURE__ */ jsx("div", { className: "flex justify-end mt-6 pr-6", children: /* @__PURE__ */ jsx(Button, { onClick: handleCreate, disabled: isLoadingSequences, children: "Create New Sequence" }) }),
|
|
823
831
|
/* @__PURE__ */ jsx("div", { className: "p-6", children: isLoadingSequences ? /* @__PURE__ */ jsx("div", { className: "text-center py-6", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "Loading sequences..." }) }) : /* @__PURE__ */ jsxs(Table, { children: [
|
|
@@ -882,10 +890,10 @@ const SequenceManagementModal = ({
|
|
|
882
890
|
] })
|
|
883
891
|
] }) }),
|
|
884
892
|
/* @__PURE__ */ jsx(FocusModal, { open: formOpen, onOpenChange: setFormOpen, children: /* @__PURE__ */ jsxs(FocusModal.Content, { children: [
|
|
885
|
-
/* @__PURE__ */ jsx(FocusModal.Header, { children: /* @__PURE__ */ jsxs(Heading, { level: "h2", children: [
|
|
893
|
+
/* @__PURE__ */ jsx(FocusModal.Header, { children: /* @__PURE__ */ jsx(FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxs(Heading, { level: "h2", children: [
|
|
886
894
|
editingSequence ? "Update" : "Create",
|
|
887
895
|
" Quote Sequence"
|
|
888
|
-
] }) }),
|
|
896
|
+
] }) }) }),
|
|
889
897
|
/* @__PURE__ */ jsx(FocusModal.Body, { children: /* @__PURE__ */ jsxs(
|
|
890
898
|
"form",
|
|
891
899
|
{
|
|
@@ -1151,10 +1159,10 @@ const QuotationConfig = () => {
|
|
|
1151
1159
|
}
|
|
1152
1160
|
),
|
|
1153
1161
|
/* @__PURE__ */ jsx(FocusModal, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(FocusModal.Content, { children: [
|
|
1154
|
-
/* @__PURE__ */ jsx(FocusModal.Header, { children: /* @__PURE__ */ jsxs("h2", { className: "text-xl font-semibold", children: [
|
|
1162
|
+
/* @__PURE__ */ jsx(FocusModal.Header, { children: /* @__PURE__ */ jsx(FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxs("h2", { className: "text-xl font-semibold", children: [
|
|
1155
1163
|
hasExistingConfig ? "Update" : "Create",
|
|
1156
1164
|
" Quotation Sequence Configuration"
|
|
1157
|
-
] }) }),
|
|
1165
|
+
] }) }) }),
|
|
1158
1166
|
/* @__PURE__ */ jsx(FocusModal.Body, { children: /* @__PURE__ */ jsxs(
|
|
1159
1167
|
"form",
|
|
1160
1168
|
{
|
|
@@ -1301,7 +1309,7 @@ const StoreConfig = () => {
|
|
|
1301
1309
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1302
1310
|
/* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => setOpen(true), children: store ? "Edit Store Information" : "Configure Store Information" }),
|
|
1303
1311
|
/* @__PURE__ */ jsx(FocusModal, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(FocusModal.Content, { children: [
|
|
1304
|
-
/* @__PURE__ */ jsx(FocusModal.Header, { children: /* @__PURE__ */ jsx(Text, { className: "text-xl font-semibold", children: store ? "Edit Store Information" : "Configure Store Information" }) }),
|
|
1312
|
+
/* @__PURE__ */ jsx(FocusModal.Header, { children: /* @__PURE__ */ jsx(FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Text, { className: "text-xl font-semibold", children: store ? "Edit Store Information" : "Configure Store Information" }) }) }),
|
|
1305
1313
|
/* @__PURE__ */ jsx(FocusModal.Body, { children: /* @__PURE__ */ jsxs(
|
|
1306
1314
|
"form",
|
|
1307
1315
|
{
|
|
@@ -2277,7 +2285,12 @@ const QuoteDetails = () => {
|
|
|
2277
2285
|
const { generatePdf, downloadPdf, pdfUrl } = useQuotePdf();
|
|
2278
2286
|
const { store } = useQuoteStore();
|
|
2279
2287
|
const draftOrderId = quote == null ? void 0 : quote.draft_order_id;
|
|
2280
|
-
const {
|
|
2288
|
+
const {
|
|
2289
|
+
order: preview,
|
|
2290
|
+
isLoading: isPreviewLoading,
|
|
2291
|
+
error: previewError,
|
|
2292
|
+
refetch: refetchPreview
|
|
2293
|
+
} = useOrderPreview(
|
|
2281
2294
|
draftOrderId,
|
|
2282
2295
|
{
|
|
2283
2296
|
fields: DEFAULT_ORDER_FIELDS
|
|
@@ -2474,9 +2487,8 @@ const QuoteDetails = () => {
|
|
|
2474
2487
|
if (isPreviewLoading) {
|
|
2475
2488
|
return /* @__PURE__ */ jsx(Fragment, {});
|
|
2476
2489
|
}
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
}
|
|
2490
|
+
const previewUnavailable = !isPreviewLoading && (!preview || !!previewError || !draftOrderId);
|
|
2491
|
+
const previewErrorMessage = previewError instanceof Error ? previewError.message : "Unable to load the latest order preview.";
|
|
2480
2492
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-3", children: [
|
|
2481
2493
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-x-4 lg:flex-row xl:items-start", children: [
|
|
2482
2494
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-3", children: [
|
|
@@ -2499,7 +2511,19 @@ const QuoteDetails = () => {
|
|
|
2499
2511
|
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "Quote Summary" }),
|
|
2500
2512
|
/* @__PURE__ */ jsx(StatusDisplay, { status: quote.status })
|
|
2501
2513
|
] }),
|
|
2502
|
-
/* @__PURE__ */
|
|
2514
|
+
previewUnavailable ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2 px-6 py-4", children: [
|
|
2515
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: draftOrderId ? previewErrorMessage : "No order preview is available for this quote." }),
|
|
2516
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-sm", children: "The quote details are still accessible, but totals may be outdated until the preview can be reloaded." }),
|
|
2517
|
+
draftOrderId && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
2518
|
+
Button,
|
|
2519
|
+
{
|
|
2520
|
+
size: "small",
|
|
2521
|
+
variant: "secondary",
|
|
2522
|
+
onClick: () => refetchPreview(),
|
|
2523
|
+
children: "Retry loading preview"
|
|
2524
|
+
}
|
|
2525
|
+
) })
|
|
2526
|
+
] }) : /* @__PURE__ */ jsx(QuoteItems, { order: quote.draft_order, preview }),
|
|
2503
2527
|
/* @__PURE__ */ jsx(TotalsBreakdown, { order: quote.draft_order }),
|
|
2504
2528
|
/* @__PURE__ */ jsxs("div", { className: " flex flex-col gap-y-2 px-6 py-4", children: [
|
|
2505
2529
|
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
|
|
@@ -3331,7 +3355,7 @@ const ManageQuoteForm = ({ order }) => {
|
|
|
3331
3355
|
) }) })
|
|
3332
3356
|
] }),
|
|
3333
3357
|
/* @__PURE__ */ jsx(FocusModal, { open: openProductModal, onOpenChange: setOpenProductModal, children: /* @__PURE__ */ jsxs(FocusModal.Content, { children: [
|
|
3334
|
-
/* @__PURE__ */ jsx(FocusModal.Header, {
|
|
3358
|
+
/* @__PURE__ */ jsx(FocusModal.Header, { children: /* @__PURE__ */ jsx(FocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { level: "h2", children: "Add Product" }) }) }),
|
|
3335
3359
|
/* @__PURE__ */ jsx(FocusModal.Body, { children: /* @__PURE__ */ jsx(
|
|
3336
3360
|
ProductSelector,
|
|
3337
3361
|
{
|
|
@@ -24,7 +24,8 @@ const GET = async (req, res) => {
|
|
|
24
24
|
const storeService = req.scope.resolve(utils_1.Modules.STORE);
|
|
25
25
|
const stores = await storeService.listStores();
|
|
26
26
|
if (!stores.length) {
|
|
27
|
-
|
|
27
|
+
// Allow admin UI to render even when no stores exist yet
|
|
28
|
+
return res.status(200).json({ store: null });
|
|
28
29
|
}
|
|
29
30
|
const storeId = stores[0].id;
|
|
30
31
|
// Try to find existing store details
|
|
@@ -32,10 +33,10 @@ const GET = async (req, res) => {
|
|
|
32
33
|
store_id: storeId
|
|
33
34
|
});
|
|
34
35
|
if (storeDetails.length > 0) {
|
|
35
|
-
return res.json({ store: storeDetails[0] });
|
|
36
|
+
return res.status(200).json({ store: storeDetails[0] });
|
|
36
37
|
}
|
|
37
|
-
// Return empty
|
|
38
|
-
return res.status(
|
|
38
|
+
// Return explicit empty payload so admin UI can prompt for configuration
|
|
39
|
+
return res.status(200).json({ store: null });
|
|
39
40
|
}
|
|
40
41
|
catch (error) {
|
|
41
42
|
res.status(500).json({ error: error.message });
|
|
@@ -91,4 +92,4 @@ const POST = async (req, res) => {
|
|
|
91
92
|
}
|
|
92
93
|
};
|
|
93
94
|
exports.POST = POST;
|
|
94
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
95
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm91dGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvYXBpL2FkbWluL3F1b3RlLXN0b3JlL3JvdXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUVBLHFEQUFvRDtBQUNwRCw2QkFBd0I7QUFDeEIsa0RBQXNEO0FBR3RELG1CQUFtQjtBQUNuQixNQUFNLFdBQVcsR0FBRyxPQUFDLENBQUMsTUFBTSxDQUFDO0lBQzNCLElBQUksRUFBRSxPQUFDLENBQUMsTUFBTSxFQUFFLENBQUMsR0FBRyxDQUFDLENBQUMsRUFBRSxrQkFBa0IsQ0FBQztJQUMzQyxRQUFRLEVBQUUsT0FBQyxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsQ0FBQyxDQUFDLEVBQUUscUJBQXFCLENBQUM7SUFDbEQsUUFBUSxFQUFFLE9BQUMsQ0FBQyxN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