order-management 0.0.25 → 0.0.26
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/.medusa/server/src/admin/index.js +199 -288
- package/.medusa/server/src/admin/index.mjs +200 -289
- package/.medusa/server/src/api/admin/swaps/[id]/prepare-exchange/route.js +84 -0
- package/.medusa/server/src/api/admin/swaps/[id]/route.js +2 -1
- package/.medusa/server/src/api/admin/swaps/validators.js +2 -9
- package/.medusa/server/src/workflows/index.js +2 -4
- package/.medusa/server/src/workflows/steps/swap/create-medusa-exchange-step.js +223 -20
- package/package.json +1 -1
- package/.medusa/server/src/api/admin/swaps/[id]/approve/route.js +0 -150
- package/.medusa/server/src/api/admin/swaps/[id]/shipping-options/route.js +0 -105
- package/.medusa/server/src/workflows/swaps/approve-swap-workflow.js +0 -84
- package/.medusa/server/src/workflows/swaps/execute-swap-workflow.js +0 -58
|
@@ -775,10 +775,6 @@ const SwapDetailPage = () => {
|
|
|
775
775
|
const [error, setError] = react.useState(null);
|
|
776
776
|
const [updateError, setUpdateError] = react.useState(null);
|
|
777
777
|
const [updateSuccess, setUpdateSuccess] = react.useState(false);
|
|
778
|
-
const [showShippingModal, setShowShippingModal] = react.useState(false);
|
|
779
|
-
const [shippingOptions, setShippingOptions] = react.useState([]);
|
|
780
|
-
const [selectedShippingOptionId, setSelectedShippingOptionId] = react.useState("");
|
|
781
|
-
const [isLoadingShippingOptions, setIsLoadingShippingOptions] = react.useState(false);
|
|
782
778
|
const availableStatuses = ["requested", "approved", "rejected"];
|
|
783
779
|
react.useEffect(() => {
|
|
784
780
|
if (!id) {
|
|
@@ -853,67 +849,32 @@ const SwapDetailPage = () => {
|
|
|
853
849
|
if (!id) {
|
|
854
850
|
return;
|
|
855
851
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
setUpdateError(null);
|
|
859
|
-
try {
|
|
860
|
-
setIsLoadingShippingOptions(true);
|
|
861
|
-
const response = await fetch(`/admin/swaps/${id}/shipping-options`, {
|
|
862
|
-
credentials: "include"
|
|
863
|
-
});
|
|
864
|
-
if (!response.ok) {
|
|
865
|
-
const message = await response.text();
|
|
866
|
-
throw new Error(message || "Unable to fetch shipping options");
|
|
867
|
-
}
|
|
868
|
-
const payload = await response.json();
|
|
869
|
-
setShippingOptions(payload.shipping_options || []);
|
|
870
|
-
} catch (fetchError) {
|
|
871
|
-
const message = fetchError instanceof Error ? fetchError.message : "Unable to fetch shipping options";
|
|
872
|
-
setUpdateError(message);
|
|
873
|
-
setShowShippingModal(false);
|
|
874
|
-
} finally {
|
|
875
|
-
setIsLoadingShippingOptions(false);
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
const handleApproveConfirm = async () => {
|
|
879
|
-
if (!id || !selectedShippingOptionId) {
|
|
880
|
-
setUpdateError("Please select a shipping option");
|
|
852
|
+
if (!swap || !swap.order_id) {
|
|
853
|
+
setUpdateError("Swap must have an order_id to create exchange");
|
|
881
854
|
return;
|
|
882
855
|
}
|
|
883
856
|
try {
|
|
884
857
|
setIsApproving(true);
|
|
885
858
|
setUpdateError(null);
|
|
886
859
|
setUpdateSuccess(false);
|
|
887
|
-
const response = await fetch(`/admin/swaps/${id}/
|
|
860
|
+
const response = await fetch(`/admin/swaps/${id}/prepare-exchange`, {
|
|
888
861
|
method: "POST",
|
|
889
862
|
headers: {
|
|
890
863
|
"Content-Type": "application/json"
|
|
891
864
|
},
|
|
892
|
-
credentials: "include"
|
|
893
|
-
body: JSON.stringify({
|
|
894
|
-
shipping_option_id: selectedShippingOptionId
|
|
895
|
-
})
|
|
865
|
+
credentials: "include"
|
|
896
866
|
});
|
|
897
867
|
if (!response.ok) {
|
|
898
|
-
const errorData = await response.json().catch(() => ({ message: "Unable to
|
|
899
|
-
throw new Error(errorData.message || errorData.error || "Unable to
|
|
868
|
+
const errorData = await response.json().catch(() => ({ message: "Unable to prepare swap for exchange creation" }));
|
|
869
|
+
throw new Error(errorData.message || errorData.error || "Unable to prepare swap for exchange creation");
|
|
900
870
|
}
|
|
901
871
|
const payload = await response.json();
|
|
902
872
|
setSwap(payload.swap);
|
|
903
873
|
setUpdateSuccess(true);
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
setTimeout(() => setUpdateSuccess(false), 5e3);
|
|
907
|
-
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
908
|
-
credentials: "include"
|
|
909
|
-
});
|
|
910
|
-
if (detailResponse.ok) {
|
|
911
|
-
const detailPayload = await detailResponse.json();
|
|
912
|
-
setSwap(detailPayload.swap);
|
|
913
|
-
setOrder(detailPayload.order || null);
|
|
914
|
-
}
|
|
874
|
+
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
875
|
+
window.location.href = `/app/orders/${swap.order_id}`;
|
|
915
876
|
} catch (updateErr) {
|
|
916
|
-
const message = updateErr instanceof Error ? updateErr.message : "Unable to
|
|
877
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to prepare swap for exchange creation";
|
|
917
878
|
setUpdateError(message);
|
|
918
879
|
} finally {
|
|
919
880
|
setIsApproving(false);
|
|
@@ -968,276 +929,226 @@ const SwapDetailPage = () => {
|
|
|
968
929
|
] }) }) });
|
|
969
930
|
}
|
|
970
931
|
const statusHistory = ((_a = swap.metadata) == null ? void 0 : _a.status_history) || [];
|
|
971
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
972
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
973
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
974
|
-
|
|
975
|
-
|
|
932
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: [
|
|
933
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
934
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
935
|
+
ui.Button,
|
|
936
|
+
{
|
|
937
|
+
variant: "transparent",
|
|
938
|
+
size: "small",
|
|
939
|
+
onClick: () => navigate("/swaps"),
|
|
940
|
+
className: "w-fit",
|
|
941
|
+
children: [
|
|
942
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
|
|
943
|
+
"Back to list"
|
|
944
|
+
]
|
|
945
|
+
}
|
|
946
|
+
),
|
|
947
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
948
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
949
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Swap Details" }),
|
|
950
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
951
|
+
] }),
|
|
952
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
953
|
+
ui.Badge,
|
|
976
954
|
{
|
|
977
|
-
variant: "transparent",
|
|
978
955
|
size: "small",
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
children: [
|
|
982
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
|
|
983
|
-
"Back to list"
|
|
984
|
-
]
|
|
956
|
+
className: `uppercase ${getStatusBadgeClass(swap.status)}`,
|
|
957
|
+
children: swap.status.replace(/_/g, " ")
|
|
985
958
|
}
|
|
986
|
-
)
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
959
|
+
)
|
|
960
|
+
] })
|
|
961
|
+
] }),
|
|
962
|
+
swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
|
|
963
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
964
|
+
ui.Button,
|
|
965
|
+
{
|
|
966
|
+
variant: "primary",
|
|
967
|
+
onClick: handleApproveClick,
|
|
968
|
+
disabled: isApproving || isRejecting,
|
|
969
|
+
isLoading: isApproving,
|
|
970
|
+
children: "Approve Swap"
|
|
971
|
+
}
|
|
972
|
+
),
|
|
973
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
974
|
+
ui.Button,
|
|
975
|
+
{
|
|
976
|
+
variant: "secondary",
|
|
977
|
+
onClick: handleReject,
|
|
978
|
+
disabled: isApproving || isRejecting,
|
|
979
|
+
isLoading: isRejecting,
|
|
980
|
+
children: "Reject Swap"
|
|
981
|
+
}
|
|
982
|
+
)
|
|
983
|
+
] }),
|
|
984
|
+
swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
985
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
|
|
986
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
|
|
987
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
988
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "mb-2 block text-sm font-medium text-ui-fg-base", children: "New Status" }),
|
|
989
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
990
|
+
"select",
|
|
994
991
|
{
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
992
|
+
value: selectedStatus,
|
|
993
|
+
onChange: (event) => setSelectedStatus(event.target.value),
|
|
994
|
+
className: "h-9 w-full rounded-md border border-ui-border-base bg-transparent px-3 text-sm text-ui-fg-base outline-none transition focus:ring-2 focus:ring-ui-fg-interactive",
|
|
995
|
+
children: [
|
|
996
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Select new status" }),
|
|
997
|
+
availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
998
|
+
]
|
|
998
999
|
}
|
|
999
1000
|
)
|
|
1000
|
-
] })
|
|
1001
|
-
] }),
|
|
1002
|
-
swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
|
|
1001
|
+
] }),
|
|
1003
1002
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1004
1003
|
ui.Button,
|
|
1005
1004
|
{
|
|
1006
1005
|
variant: "primary",
|
|
1007
|
-
onClick:
|
|
1008
|
-
disabled:
|
|
1009
|
-
isLoading:
|
|
1010
|
-
children: "
|
|
1006
|
+
onClick: handleStatusUpdate,
|
|
1007
|
+
disabled: !selectedStatus || isUpdating,
|
|
1008
|
+
isLoading: isUpdating,
|
|
1009
|
+
children: "Update Status"
|
|
1011
1010
|
}
|
|
1012
|
-
)
|
|
1013
|
-
|
|
1011
|
+
)
|
|
1012
|
+
] }),
|
|
1013
|
+
updateError && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
|
|
1014
|
+
updateSuccess && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
|
|
1015
|
+
] }),
|
|
1016
|
+
swap.status === "approved" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1017
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
1018
|
+
swap.exchange_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
1019
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1020
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
1021
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
|
|
1022
|
+
] }),
|
|
1023
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1014
1024
|
ui.Button,
|
|
1015
1025
|
{
|
|
1016
1026
|
variant: "secondary",
|
|
1017
|
-
onClick:
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
children: "
|
|
1027
|
+
onClick: () => {
|
|
1028
|
+
window.open(`/app/orders/${swap.order_id}/exchanges/${swap.exchange_id}`, "_blank");
|
|
1029
|
+
},
|
|
1030
|
+
children: "View Exchange"
|
|
1021
1031
|
}
|
|
1022
|
-
)
|
|
1023
|
-
] }),
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
value: selectedStatus,
|
|
1033
|
-
onChange: (event) => setSelectedStatus(event.target.value),
|
|
1034
|
-
className: "h-9 w-full rounded-md border border-ui-border-base bg-transparent px-3 text-sm text-ui-fg-base outline-none transition focus:ring-2 focus:ring-ui-fg-interactive",
|
|
1035
|
-
children: [
|
|
1036
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Select new status" }),
|
|
1037
|
-
availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
1038
|
-
]
|
|
1039
|
-
}
|
|
1040
|
-
)
|
|
1032
|
+
) })
|
|
1033
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange is being created. Please refresh the page to see the exchange details." }) })
|
|
1034
|
+
] }),
|
|
1035
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
1036
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1037
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
|
|
1038
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
1039
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1040
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
|
|
1041
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.id })
|
|
1041
1042
|
] }),
|
|
1042
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1043
|
-
ui.Button,
|
|
1044
|
-
{
|
|
1045
|
-
variant: "primary",
|
|
1046
|
-
onClick: handleStatusUpdate,
|
|
1047
|
-
disabled: !selectedStatus || isUpdating,
|
|
1048
|
-
isLoading: isUpdating,
|
|
1049
|
-
children: "Update Status"
|
|
1050
|
-
}
|
|
1051
|
-
)
|
|
1052
|
-
] }),
|
|
1053
|
-
updateError && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
|
|
1054
|
-
updateSuccess && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
|
|
1055
|
-
] }),
|
|
1056
|
-
swap.status === "approved" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1057
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
1058
|
-
swap.exchange_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
1059
1043
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1060
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1061
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.
|
|
1044
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
1045
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
|
|
1062
1046
|
] }),
|
|
1063
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1064
|
-
ui.Button,
|
|
1065
|
-
{
|
|
1066
|
-
variant: "secondary",
|
|
1067
|
-
onClick: () => {
|
|
1068
|
-
window.open(`/app/orders/${swap.order_id}/exchanges/${swap.exchange_id}`, "_blank");
|
|
1069
|
-
},
|
|
1070
|
-
children: "View Exchange"
|
|
1071
|
-
}
|
|
1072
|
-
) })
|
|
1073
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange is being created. Please refresh the page to see the exchange details." }) })
|
|
1074
|
-
] }),
|
|
1075
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
1076
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1077
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
|
|
1078
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
1079
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1080
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
|
|
1081
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.id })
|
|
1082
|
-
] }),
|
|
1083
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1084
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
1085
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
|
|
1086
|
-
] }),
|
|
1087
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1088
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
1089
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
1090
|
-
] }),
|
|
1091
|
-
swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1092
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
1093
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
|
|
1094
|
-
] }),
|
|
1095
|
-
swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1096
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
1097
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
|
|
1098
|
-
] }),
|
|
1099
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1100
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
1101
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
1102
|
-
] }),
|
|
1103
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1104
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
1105
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
1106
|
-
] }),
|
|
1107
|
-
swap.exchange_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1108
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
1109
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
|
|
1110
|
-
] })
|
|
1111
|
-
] })
|
|
1112
|
-
] }),
|
|
1113
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1114
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Status History" }),
|
|
1115
|
-
statusHistory.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: statusHistory.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1116
|
-
"div",
|
|
1117
|
-
{
|
|
1118
|
-
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
1119
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1120
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1121
|
-
ui.Badge,
|
|
1122
|
-
{
|
|
1123
|
-
size: "2xsmall",
|
|
1124
|
-
className: `uppercase ${getStatusBadgeClass(entry.status)}`,
|
|
1125
|
-
children: entry.status.replace(/_/g, " ")
|
|
1126
|
-
}
|
|
1127
|
-
) }),
|
|
1128
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
1129
|
-
new Date(entry.timestamp).toLocaleString(),
|
|
1130
|
-
entry.admin_id && ` by ${entry.admin_id}`,
|
|
1131
|
-
entry.reason && ` - ${entry.reason}`
|
|
1132
|
-
] })
|
|
1133
|
-
] })
|
|
1134
|
-
},
|
|
1135
|
-
index
|
|
1136
|
-
)) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
1137
|
-
] })
|
|
1138
|
-
] }),
|
|
1139
|
-
order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1140
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
1141
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
1142
1047
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1143
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1144
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
1048
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
1049
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
1050
|
+
] }),
|
|
1051
|
+
swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1052
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
1053
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
|
|
1054
|
+
] }),
|
|
1055
|
+
swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1056
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
1057
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
|
|
1145
1058
|
] }),
|
|
1146
1059
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1147
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1148
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
1060
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
1061
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
1149
1062
|
] }),
|
|
1150
1063
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1151
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1152
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: (
|
|
1064
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
1065
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
1153
1066
|
] }),
|
|
1154
|
-
|
|
1155
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1156
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1157
|
-
order.currency_code || "$",
|
|
1158
|
-
(Number(order.total) / 100).toFixed(2)
|
|
1159
|
-
] })
|
|
1067
|
+
swap.exchange_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1068
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
1069
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
|
|
1160
1070
|
] })
|
|
1161
1071
|
] })
|
|
1162
1072
|
] }),
|
|
1163
|
-
|
|
1164
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "
|
|
1165
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
1188
|
-
] }, item.variant_id || index)) })
|
|
1189
|
-
] }) })
|
|
1073
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1074
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Status History" }),
|
|
1075
|
+
statusHistory.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: statusHistory.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1076
|
+
"div",
|
|
1077
|
+
{
|
|
1078
|
+
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
1079
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1080
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1081
|
+
ui.Badge,
|
|
1082
|
+
{
|
|
1083
|
+
size: "2xsmall",
|
|
1084
|
+
className: `uppercase ${getStatusBadgeClass(entry.status)}`,
|
|
1085
|
+
children: entry.status.replace(/_/g, " ")
|
|
1086
|
+
}
|
|
1087
|
+
) }),
|
|
1088
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
1089
|
+
new Date(entry.timestamp).toLocaleString(),
|
|
1090
|
+
entry.admin_id && ` by ${entry.admin_id}`,
|
|
1091
|
+
entry.reason && ` - ${entry.reason}`
|
|
1092
|
+
] })
|
|
1093
|
+
] })
|
|
1094
|
+
},
|
|
1095
|
+
index
|
|
1096
|
+
)) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
1190
1097
|
] })
|
|
1191
1098
|
] }),
|
|
1192
|
-
|
|
1193
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1194
|
-
|
|
1195
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1200
|
-
ui.
|
|
1201
|
-
{
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
ui.Button,
|
|
1215
|
-
{
|
|
1216
|
-
variant: "secondary",
|
|
1217
|
-
onClick: () => {
|
|
1218
|
-
setShowShippingModal(false);
|
|
1219
|
-
setSelectedShippingOptionId("");
|
|
1220
|
-
setUpdateError(null);
|
|
1221
|
-
},
|
|
1222
|
-
disabled: isApproving,
|
|
1223
|
-
className: "flex-1",
|
|
1224
|
-
children: "Cancel"
|
|
1225
|
-
}
|
|
1226
|
-
),
|
|
1227
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1228
|
-
ui.Button,
|
|
1229
|
-
{
|
|
1230
|
-
variant: "primary",
|
|
1231
|
-
onClick: handleApproveConfirm,
|
|
1232
|
-
disabled: !selectedShippingOptionId || isApproving || isLoadingShippingOptions,
|
|
1233
|
-
isLoading: isApproving,
|
|
1234
|
-
className: "flex-1",
|
|
1235
|
-
children: "Confirm & Approve"
|
|
1236
|
-
}
|
|
1237
|
-
)
|
|
1099
|
+
order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1100
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
1101
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
1102
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1103
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
1104
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.id })
|
|
1105
|
+
] }),
|
|
1106
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1107
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
1108
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.status || "—" })
|
|
1109
|
+
] }),
|
|
1110
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1111
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
1112
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_b = order.customer) == null ? void 0 : _b.email) || order.email || "—" })
|
|
1113
|
+
] }),
|
|
1114
|
+
order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1115
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
1116
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
|
|
1117
|
+
order.currency_code || "$",
|
|
1118
|
+
(Number(order.total) / 100).toFixed(2)
|
|
1119
|
+
] })
|
|
1120
|
+
] })
|
|
1238
1121
|
] })
|
|
1239
|
-
] })
|
|
1240
|
-
|
|
1122
|
+
] }),
|
|
1123
|
+
swap.return_items && swap.return_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1124
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
1125
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
1126
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1127
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
|
|
1128
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
1129
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
1130
|
+
] }) }),
|
|
1131
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1132
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
1133
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
1134
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
1135
|
+
] }, item.id || index)) })
|
|
1136
|
+
] }) })
|
|
1137
|
+
] }),
|
|
1138
|
+
swap.new_items && swap.new_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1139
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
1140
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
1141
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1142
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
1143
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
1144
|
+
] }) }),
|
|
1145
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1146
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
1147
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
1148
|
+
] }, item.variant_id || index)) })
|
|
1149
|
+
] }) })
|
|
1150
|
+
] })
|
|
1151
|
+
] }) });
|
|
1241
1152
|
};
|
|
1242
1153
|
const config = adminSdk.defineRouteConfig({
|
|
1243
1154
|
label: "Swap Details",
|