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