order-management 0.0.86 → 0.0.88
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.
|
@@ -2,7 +2,7 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
|
|
3
3
|
import { useState, useEffect, useRef, useCallback, useMemo } from "react";
|
|
4
4
|
import { Container, Text, Heading, Badge, Button, Label, Select, Textarea, Input } from "@medusajs/ui";
|
|
5
|
-
import { CashSolid, PencilSquareSolid, Trash, ArrowPath, CreditCard,
|
|
5
|
+
import { CashSolid, PencilSquareSolid, Trash, Receipt, ArrowPath, CreditCard, ArrowLeft, CheckCircle } from "@medusajs/icons";
|
|
6
6
|
import { useNavigate, useParams } from "react-router-dom";
|
|
7
7
|
function roundRectPath(ctx, x, y, w, h, r) {
|
|
8
8
|
ctx.beginPath();
|
|
@@ -865,210 +865,275 @@ const useDebounce$3 = (value, delay) => {
|
|
|
865
865
|
return debouncedValue;
|
|
866
866
|
};
|
|
867
867
|
const getStatusBadgeClass$7 = (status) => {
|
|
868
|
-
const
|
|
869
|
-
if (
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
if (
|
|
873
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
874
|
-
}
|
|
875
|
-
if (statusLower === "rejected") {
|
|
876
|
-
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
877
|
-
}
|
|
878
|
-
if (statusLower === "completed") {
|
|
879
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
880
|
-
}
|
|
881
|
-
if (statusLower === "cancelled") {
|
|
882
|
-
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
883
|
-
}
|
|
868
|
+
const s2 = status.toLowerCase();
|
|
869
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
870
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
871
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
872
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
884
873
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
885
874
|
};
|
|
886
|
-
const
|
|
875
|
+
const RefundsPage = () => {
|
|
887
876
|
const navigate = useNavigate();
|
|
888
877
|
const [items, setItems] = useState([]);
|
|
889
|
-
const [
|
|
890
|
-
const
|
|
891
|
-
const [
|
|
892
|
-
const
|
|
878
|
+
const [orderIdSearch, setOrderIdSearch] = useState("");
|
|
879
|
+
const debouncedOrderId = useDebounce$3(orderIdSearch, 300);
|
|
880
|
+
const [paymentStatusFilter, setPaymentStatusFilter] = useState("all");
|
|
881
|
+
const [providerSearch, setProviderSearch] = useState("");
|
|
882
|
+
const debouncedProvider = useDebounce$3(providerSearch, 300);
|
|
883
|
+
const [currencySearch, setCurrencySearch] = useState("");
|
|
884
|
+
const debouncedCurrency = useDebounce$3(currencySearch, 300);
|
|
885
|
+
const [dateFrom, setDateFrom] = useState("");
|
|
886
|
+
const [dateTo, setDateTo] = useState("");
|
|
887
|
+
const [amountMin, setAmountMin] = useState("");
|
|
888
|
+
const [amountMax, setAmountMax] = useState("");
|
|
893
889
|
const [isLoading, setIsLoading] = useState(true);
|
|
894
890
|
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
895
891
|
const [error, setError] = useState(null);
|
|
896
892
|
const [offset, setOffset] = useState(0);
|
|
897
893
|
const [count, setCount] = useState(0);
|
|
898
894
|
const limit = 50;
|
|
899
|
-
const
|
|
900
|
-
async (nextOffset, replace
|
|
901
|
-
var _a;
|
|
895
|
+
const loadRefunds = useCallback(
|
|
896
|
+
async (nextOffset, replace) => {
|
|
902
897
|
try {
|
|
903
|
-
if (replace)
|
|
904
|
-
|
|
905
|
-
} else {
|
|
906
|
-
setIsFetchingMore(true);
|
|
907
|
-
}
|
|
898
|
+
if (replace) setIsLoading(true);
|
|
899
|
+
else setIsFetchingMore(true);
|
|
908
900
|
setError(null);
|
|
909
901
|
const params = new URLSearchParams();
|
|
910
902
|
params.set("limit", String(limit));
|
|
911
903
|
params.set("offset", String(nextOffset));
|
|
912
|
-
if (
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
if (
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
);
|
|
904
|
+
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
905
|
+
if (paymentStatusFilter !== "all") params.set("payment_status", paymentStatusFilter);
|
|
906
|
+
if (debouncedProvider.trim()) params.set("provider_id", debouncedProvider.trim());
|
|
907
|
+
if (debouncedCurrency.trim()) params.set("currency_code", debouncedCurrency.trim());
|
|
908
|
+
if (dateFrom.trim()) params.set("date_from", dateFrom.trim());
|
|
909
|
+
if (dateTo.trim()) params.set("date_to", dateTo.trim());
|
|
910
|
+
const min = amountMin.trim() ? Number(amountMin) : void 0;
|
|
911
|
+
const max = amountMax.trim() ? Number(amountMax) : void 0;
|
|
912
|
+
if (min != null && !Number.isNaN(min)) params.set("amount_min", String(min));
|
|
913
|
+
if (max != null && !Number.isNaN(max)) params.set("amount_max", String(max));
|
|
914
|
+
const response = await fetch(`/admin/refunds?${params.toString()}`, {
|
|
915
|
+
credentials: "include"
|
|
916
|
+
});
|
|
925
917
|
if (!response.ok) {
|
|
926
|
-
const
|
|
927
|
-
throw new Error(
|
|
918
|
+
const text = await response.text();
|
|
919
|
+
throw new Error(text || "Failed to load refunds");
|
|
928
920
|
}
|
|
929
921
|
const payload = await response.json();
|
|
922
|
+
const list = payload.refunds ?? [];
|
|
930
923
|
setCount(payload.count ?? 0);
|
|
931
|
-
setOffset(nextOffset +
|
|
932
|
-
setItems(
|
|
933
|
-
|
|
934
|
-
);
|
|
935
|
-
} catch (loadError) {
|
|
936
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
|
|
937
|
-
setError(message);
|
|
924
|
+
setOffset(nextOffset + list.length);
|
|
925
|
+
setItems((prev) => replace ? list : [...prev, ...list]);
|
|
926
|
+
} catch (e) {
|
|
927
|
+
setError(e instanceof Error ? e.message : "Failed to load");
|
|
938
928
|
} finally {
|
|
939
929
|
setIsLoading(false);
|
|
940
930
|
setIsFetchingMore(false);
|
|
941
931
|
}
|
|
942
932
|
},
|
|
943
|
-
[
|
|
933
|
+
[
|
|
934
|
+
debouncedOrderId,
|
|
935
|
+
paymentStatusFilter,
|
|
936
|
+
debouncedProvider,
|
|
937
|
+
debouncedCurrency,
|
|
938
|
+
dateFrom,
|
|
939
|
+
dateTo,
|
|
940
|
+
amountMin,
|
|
941
|
+
amountMax
|
|
942
|
+
]
|
|
944
943
|
);
|
|
945
944
|
useEffect(() => {
|
|
946
|
-
void
|
|
947
|
-
}, [
|
|
945
|
+
void loadRefunds(0, true);
|
|
946
|
+
}, [loadRefunds]);
|
|
948
947
|
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
949
|
-
const
|
|
950
|
-
const
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
948
|
+
const displayAmount = (r) => {
|
|
949
|
+
const code = (r.currency_code ?? "USD").toUpperCase();
|
|
950
|
+
return `${code} ${Number(r.amount)}`;
|
|
951
|
+
};
|
|
952
|
+
const displayStatus = (r) => {
|
|
953
|
+
const s2 = r.payment_status ?? "";
|
|
954
|
+
return s2 !== "" ? s2 : "—";
|
|
955
|
+
};
|
|
954
956
|
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
955
957
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
956
958
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
957
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
958
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
959
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refunds" }),
|
|
960
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Refund records — amount, order, payment status" })
|
|
959
961
|
] }),
|
|
960
|
-
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () =>
|
|
962
|
+
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadRefunds(0, true), children: "Refresh" })
|
|
961
963
|
] }),
|
|
962
|
-
/* @__PURE__ */
|
|
964
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
963
965
|
/* @__PURE__ */ jsx(
|
|
964
966
|
Input,
|
|
965
967
|
{
|
|
966
|
-
placeholder: "
|
|
967
|
-
value:
|
|
968
|
-
onChange: (
|
|
969
|
-
className: "md:max-w-
|
|
968
|
+
placeholder: "Order ID",
|
|
969
|
+
value: orderIdSearch,
|
|
970
|
+
onChange: (e) => setOrderIdSearch(e.target.value),
|
|
971
|
+
className: "md:max-w-[180px]",
|
|
972
|
+
"aria-label": "Filter by order ID"
|
|
970
973
|
}
|
|
971
974
|
),
|
|
972
|
-
/* @__PURE__ */
|
|
973
|
-
|
|
974
|
-
"select",
|
|
975
|
-
{
|
|
976
|
-
value: createdByFilter,
|
|
977
|
-
onChange: (event) => setCreatedByFilter(event.target.value),
|
|
978
|
-
className: "h-9 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 md:max-w-xs",
|
|
979
|
-
children: [
|
|
980
|
-
/* @__PURE__ */ jsx("option", { value: "all", children: "All (Created by)" }),
|
|
981
|
-
/* @__PURE__ */ jsx("option", { value: "customer", children: "Customer" }),
|
|
982
|
-
/* @__PURE__ */ jsx("option", { value: "admin", children: "Admin" })
|
|
983
|
-
]
|
|
984
|
-
}
|
|
985
|
-
),
|
|
986
|
-
/* @__PURE__ */ jsxs(
|
|
987
|
-
"select",
|
|
988
|
-
{
|
|
989
|
-
value: statusFilter,
|
|
990
|
-
onChange: (event) => setStatusFilter(event.target.value),
|
|
991
|
-
className: "h-9 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 md:max-w-xs",
|
|
992
|
-
children: [
|
|
993
|
-
/* @__PURE__ */ jsx("option", { value: "all", children: "All Statuses" }),
|
|
994
|
-
availableStatuses.map((status) => /* @__PURE__ */ jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
995
|
-
]
|
|
996
|
-
}
|
|
997
|
-
)
|
|
998
|
-
] })
|
|
999
|
-
] }),
|
|
1000
|
-
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1001
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1002
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1003
|
-
Button,
|
|
975
|
+
/* @__PURE__ */ jsx(
|
|
976
|
+
Input,
|
|
1004
977
|
{
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
978
|
+
placeholder: "Provider",
|
|
979
|
+
value: providerSearch,
|
|
980
|
+
onChange: (e) => setProviderSearch(e.target.value),
|
|
981
|
+
className: "md:max-w-[140px]",
|
|
982
|
+
"aria-label": "Filter by provider"
|
|
1008
983
|
}
|
|
1009
|
-
)
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No exchanges yet" }),
|
|
1013
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Exchange requests created by customers will appear here." })
|
|
1014
|
-
] }) : /* @__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: [
|
|
1015
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1016
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Exchange ID" }),
|
|
1017
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
1018
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
1019
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Difference Due" }),
|
|
1020
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1021
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1022
|
-
] }) }),
|
|
1023
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxs(
|
|
1024
|
-
"tr",
|
|
984
|
+
),
|
|
985
|
+
/* @__PURE__ */ jsx(
|
|
986
|
+
Input,
|
|
1025
987
|
{
|
|
1026
|
-
|
|
1027
|
-
|
|
988
|
+
placeholder: "Currency",
|
|
989
|
+
value: currencySearch,
|
|
990
|
+
onChange: (e) => setCurrencySearch(e.target.value),
|
|
991
|
+
className: "md:max-w-[100px]",
|
|
992
|
+
"aria-label": "Filter by currency"
|
|
993
|
+
}
|
|
994
|
+
),
|
|
995
|
+
/* @__PURE__ */ jsxs(
|
|
996
|
+
"select",
|
|
997
|
+
{
|
|
998
|
+
value: paymentStatusFilter,
|
|
999
|
+
onChange: (e) => setPaymentStatusFilter(e.target.value),
|
|
1000
|
+
className: "h-9 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 md:max-w-[160px]",
|
|
1001
|
+
"aria-label": "Filter by payment status",
|
|
1028
1002
|
children: [
|
|
1029
|
-
/* @__PURE__ */ jsx("
|
|
1030
|
-
/* @__PURE__ */ jsx("
|
|
1031
|
-
/* @__PURE__ */ jsx("
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1003
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
|
|
1004
|
+
/* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
|
|
1005
|
+
/* @__PURE__ */ jsx("option", { value: "requires_more", children: "Requires more" }),
|
|
1006
|
+
/* @__PURE__ */ jsx("option", { value: "error", children: "Error" }),
|
|
1007
|
+
/* @__PURE__ */ jsx("option", { value: "canceled", children: "Canceled" }),
|
|
1008
|
+
/* @__PURE__ */ jsx("option", { value: "authorized", children: "Authorized" }),
|
|
1009
|
+
/* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
|
|
1010
|
+
]
|
|
1011
|
+
}
|
|
1012
|
+
),
|
|
1013
|
+
/* @__PURE__ */ jsx(
|
|
1014
|
+
Input,
|
|
1015
|
+
{
|
|
1016
|
+
type: "date",
|
|
1017
|
+
placeholder: "From",
|
|
1018
|
+
value: dateFrom,
|
|
1019
|
+
onChange: (e) => setDateFrom(e.target.value),
|
|
1020
|
+
className: "md:max-w-[140px]",
|
|
1021
|
+
"aria-label": "Date from"
|
|
1022
|
+
}
|
|
1023
|
+
),
|
|
1024
|
+
/* @__PURE__ */ jsx(
|
|
1025
|
+
Input,
|
|
1026
|
+
{
|
|
1027
|
+
type: "date",
|
|
1028
|
+
placeholder: "To",
|
|
1029
|
+
value: dateTo,
|
|
1030
|
+
onChange: (e) => setDateTo(e.target.value),
|
|
1031
|
+
className: "md:max-w-[140px]",
|
|
1032
|
+
"aria-label": "Date to"
|
|
1033
|
+
}
|
|
1034
|
+
),
|
|
1035
|
+
/* @__PURE__ */ jsx(
|
|
1036
|
+
Input,
|
|
1037
|
+
{
|
|
1038
|
+
placeholder: "Amount min",
|
|
1039
|
+
value: amountMin,
|
|
1040
|
+
onChange: (e) => setAmountMin(e.target.value),
|
|
1041
|
+
type: "number",
|
|
1042
|
+
min: 0,
|
|
1043
|
+
className: "md:max-w-[100px]",
|
|
1044
|
+
"aria-label": "Refund amount minimum"
|
|
1045
|
+
}
|
|
1046
|
+
),
|
|
1047
|
+
/* @__PURE__ */ jsx(
|
|
1048
|
+
Input,
|
|
1049
|
+
{
|
|
1050
|
+
placeholder: "Amount max",
|
|
1051
|
+
value: amountMax,
|
|
1052
|
+
onChange: (e) => setAmountMax(e.target.value),
|
|
1053
|
+
type: "number",
|
|
1054
|
+
min: 0,
|
|
1055
|
+
className: "md:max-w-[100px]",
|
|
1056
|
+
"aria-label": "Refund amount maximum"
|
|
1057
|
+
}
|
|
1058
|
+
)
|
|
1059
|
+
] }) }),
|
|
1060
|
+
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1061
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1062
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadRefunds(0, true), children: "Try again" }) })
|
|
1063
|
+
] }) : null,
|
|
1064
|
+
isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading refunds…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
1065
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No refunds yet" }),
|
|
1066
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Refund records will appear here." })
|
|
1067
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "w-full overflow-x-auto rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "w-full table-fixed divide-y divide-ui-border-base", style: { minWidth: 0 }, children: [
|
|
1068
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1069
|
+
/* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund ID" }),
|
|
1070
|
+
/* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
1071
|
+
/* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment ID" }),
|
|
1072
|
+
/* @__PURE__ */ jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
1073
|
+
/* @__PURE__ */ jsx("th", { className: "w-[6%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Currency" }),
|
|
1074
|
+
/* @__PURE__ */ jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
1075
|
+
/* @__PURE__ */ jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment Status" }),
|
|
1076
|
+
/* @__PURE__ */ jsx("th", { className: "w-[14%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Note" }),
|
|
1077
|
+
/* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1078
|
+
/* @__PURE__ */ jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1079
|
+
] }) }),
|
|
1080
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((r) => /* @__PURE__ */ jsxs(
|
|
1081
|
+
"tr",
|
|
1082
|
+
{
|
|
1083
|
+
className: "cursor-pointer hover:bg-ui-bg-subtle/60",
|
|
1084
|
+
onClick: () => navigate(`/refunds/${r.refund_id}`),
|
|
1085
|
+
children: [
|
|
1086
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-base", title: r.refund_id, children: r.refund_id }),
|
|
1087
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 font-medium text-ui-fg-base", title: r.order_id ?? void 0, children: r.order_id ?? "—" }),
|
|
1088
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-subtle", title: r.payment_id, children: r.payment_id }),
|
|
1089
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", children: displayAmount(r) }),
|
|
1090
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle uppercase", children: r.currency_code || "—" }),
|
|
1091
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.provider_id || void 0, children: r.provider_id || "—" }),
|
|
1092
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsx(
|
|
1093
|
+
Badge,
|
|
1094
|
+
{
|
|
1095
|
+
size: "2xsmall",
|
|
1096
|
+
className: `uppercase ${getStatusBadgeClass$7(displayStatus(r))}`,
|
|
1097
|
+
children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
|
|
1098
|
+
}
|
|
1099
|
+
) }),
|
|
1100
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.note ?? void 0, children: r.note ?? "—" }),
|
|
1101
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle text-xs", children: new Date(r.created_at).toLocaleDateString("en-US", {
|
|
1102
|
+
month: "short",
|
|
1103
|
+
day: "numeric",
|
|
1104
|
+
hour: "numeric",
|
|
1105
|
+
minute: "2-digit",
|
|
1106
|
+
hour12: true
|
|
1107
|
+
}) }),
|
|
1108
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
1109
|
+
/* @__PURE__ */ jsx(
|
|
1110
|
+
Button,
|
|
1111
|
+
{
|
|
1112
|
+
variant: "transparent",
|
|
1113
|
+
size: "small",
|
|
1114
|
+
onClick: (e) => {
|
|
1115
|
+
e.stopPropagation();
|
|
1116
|
+
navigate(`/refunds/${r.refund_id}`);
|
|
1117
|
+
},
|
|
1118
|
+
children: "Details"
|
|
1119
|
+
}
|
|
1120
|
+
),
|
|
1121
|
+
r.order_id ? /* @__PURE__ */ jsx(
|
|
1122
|
+
Button,
|
|
1123
|
+
{
|
|
1124
|
+
variant: "transparent",
|
|
1125
|
+
size: "small",
|
|
1126
|
+
onClick: (e) => {
|
|
1127
|
+
e.stopPropagation();
|
|
1128
|
+
navigate(`/orders/${r.order_id}`);
|
|
1129
|
+
},
|
|
1130
|
+
children: "Order"
|
|
1131
|
+
}
|
|
1132
|
+
) : null
|
|
1133
|
+
] }) })
|
|
1069
1134
|
]
|
|
1070
1135
|
},
|
|
1071
|
-
|
|
1136
|
+
r.refund_id
|
|
1072
1137
|
)) })
|
|
1073
1138
|
] }) }),
|
|
1074
1139
|
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
@@ -1076,15 +1141,15 @@ const SwapsPage = () => {
|
|
|
1076
1141
|
{
|
|
1077
1142
|
variant: "secondary",
|
|
1078
1143
|
isLoading: isFetchingMore,
|
|
1079
|
-
onClick: () =>
|
|
1144
|
+
onClick: () => loadRefunds(offset, false),
|
|
1080
1145
|
children: "Load more"
|
|
1081
1146
|
}
|
|
1082
1147
|
) }) : null
|
|
1083
1148
|
] }) });
|
|
1084
1149
|
};
|
|
1085
1150
|
const config$7 = defineRouteConfig({
|
|
1086
|
-
label: "
|
|
1087
|
-
icon:
|
|
1151
|
+
label: "Refunds",
|
|
1152
|
+
icon: Receipt
|
|
1088
1153
|
});
|
|
1089
1154
|
const useDebounce$2 = (value, delay) => {
|
|
1090
1155
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
@@ -1527,275 +1592,210 @@ const useDebounce = (value, delay) => {
|
|
|
1527
1592
|
return debouncedValue;
|
|
1528
1593
|
};
|
|
1529
1594
|
const getStatusBadgeClass$4 = (status) => {
|
|
1530
|
-
const
|
|
1531
|
-
if (
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
if (
|
|
1595
|
+
const statusLower = status.toLowerCase();
|
|
1596
|
+
if (statusLower === "requested") {
|
|
1597
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1598
|
+
}
|
|
1599
|
+
if (statusLower === "approved") {
|
|
1600
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1601
|
+
}
|
|
1602
|
+
if (statusLower === "rejected") {
|
|
1603
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1604
|
+
}
|
|
1605
|
+
if (statusLower === "completed") {
|
|
1606
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1607
|
+
}
|
|
1608
|
+
if (statusLower === "cancelled") {
|
|
1609
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
1610
|
+
}
|
|
1535
1611
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1536
1612
|
};
|
|
1537
|
-
const
|
|
1613
|
+
const SwapsPage = () => {
|
|
1538
1614
|
const navigate = useNavigate();
|
|
1539
1615
|
const [items, setItems] = useState([]);
|
|
1540
|
-
const [
|
|
1541
|
-
const
|
|
1542
|
-
const [
|
|
1543
|
-
const
|
|
1544
|
-
const debouncedProvider = useDebounce(providerSearch, 300);
|
|
1545
|
-
const [currencySearch, setCurrencySearch] = useState("");
|
|
1546
|
-
const debouncedCurrency = useDebounce(currencySearch, 300);
|
|
1547
|
-
const [dateFrom, setDateFrom] = useState("");
|
|
1548
|
-
const [dateTo, setDateTo] = useState("");
|
|
1549
|
-
const [amountMin, setAmountMin] = useState("");
|
|
1550
|
-
const [amountMax, setAmountMax] = useState("");
|
|
1616
|
+
const [statusFilter, setStatusFilter] = useState("all");
|
|
1617
|
+
const [createdByFilter, setCreatedByFilter] = useState("all");
|
|
1618
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
1619
|
+
const debouncedSearchQuery = useDebounce(searchQuery, 300);
|
|
1551
1620
|
const [isLoading, setIsLoading] = useState(true);
|
|
1552
1621
|
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1553
1622
|
const [error, setError] = useState(null);
|
|
1554
1623
|
const [offset, setOffset] = useState(0);
|
|
1555
1624
|
const [count, setCount] = useState(0);
|
|
1556
1625
|
const limit = 50;
|
|
1557
|
-
const
|
|
1558
|
-
async (nextOffset, replace) => {
|
|
1626
|
+
const loadSwaps = useCallback(
|
|
1627
|
+
async (nextOffset, replace = false) => {
|
|
1628
|
+
var _a;
|
|
1559
1629
|
try {
|
|
1560
|
-
if (replace)
|
|
1561
|
-
|
|
1630
|
+
if (replace) {
|
|
1631
|
+
setIsLoading(true);
|
|
1632
|
+
} else {
|
|
1633
|
+
setIsFetchingMore(true);
|
|
1634
|
+
}
|
|
1562
1635
|
setError(null);
|
|
1563
1636
|
const params = new URLSearchParams();
|
|
1564
1637
|
params.set("limit", String(limit));
|
|
1565
1638
|
params.set("offset", String(nextOffset));
|
|
1566
|
-
if (
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
if (
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
credentials: "include"
|
|
1578
|
-
|
|
1639
|
+
if (statusFilter !== "all") {
|
|
1640
|
+
params.set("status", statusFilter);
|
|
1641
|
+
}
|
|
1642
|
+
if (debouncedSearchQuery.trim()) {
|
|
1643
|
+
params.set("order_id", debouncedSearchQuery.trim());
|
|
1644
|
+
}
|
|
1645
|
+
if (createdByFilter !== "all") {
|
|
1646
|
+
params.set("created_by", createdByFilter);
|
|
1647
|
+
}
|
|
1648
|
+
const response = await fetch(
|
|
1649
|
+
`/admin/swaps?${params.toString()}`,
|
|
1650
|
+
{ credentials: "include" }
|
|
1651
|
+
);
|
|
1579
1652
|
if (!response.ok) {
|
|
1580
|
-
const
|
|
1581
|
-
throw new Error(
|
|
1653
|
+
const message = await response.text();
|
|
1654
|
+
throw new Error(message || "Unable to load swaps");
|
|
1582
1655
|
}
|
|
1583
1656
|
const payload = await response.json();
|
|
1584
|
-
const list = payload.refunds ?? [];
|
|
1585
1657
|
setCount(payload.count ?? 0);
|
|
1586
|
-
setOffset(nextOffset +
|
|
1587
|
-
setItems(
|
|
1588
|
-
|
|
1589
|
-
|
|
1658
|
+
setOffset(nextOffset + (((_a = payload.swaps) == null ? void 0 : _a.length) ?? 0));
|
|
1659
|
+
setItems(
|
|
1660
|
+
(prev) => replace ? payload.swaps ?? [] : [...prev, ...payload.swaps ?? []]
|
|
1661
|
+
);
|
|
1662
|
+
} catch (loadError) {
|
|
1663
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
|
|
1664
|
+
setError(message);
|
|
1590
1665
|
} finally {
|
|
1591
1666
|
setIsLoading(false);
|
|
1592
1667
|
setIsFetchingMore(false);
|
|
1593
1668
|
}
|
|
1594
1669
|
},
|
|
1595
|
-
[
|
|
1596
|
-
debouncedOrderId,
|
|
1597
|
-
paymentStatusFilter,
|
|
1598
|
-
debouncedProvider,
|
|
1599
|
-
debouncedCurrency,
|
|
1600
|
-
dateFrom,
|
|
1601
|
-
dateTo,
|
|
1602
|
-
amountMin,
|
|
1603
|
-
amountMax
|
|
1604
|
-
]
|
|
1670
|
+
[statusFilter, createdByFilter, debouncedSearchQuery]
|
|
1605
1671
|
);
|
|
1606
1672
|
useEffect(() => {
|
|
1607
|
-
void
|
|
1608
|
-
}, [
|
|
1673
|
+
void loadSwaps(0, true);
|
|
1674
|
+
}, [statusFilter, createdByFilter, debouncedSearchQuery, loadSwaps]);
|
|
1609
1675
|
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
1610
|
-
const
|
|
1611
|
-
const
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
const s2 = r.payment_status ?? "";
|
|
1616
|
-
return s2 !== "" ? s2 : "—";
|
|
1617
|
-
};
|
|
1676
|
+
const availableStatuses = useMemo(() => {
|
|
1677
|
+
const statuses = /* @__PURE__ */ new Set();
|
|
1678
|
+
items.forEach((item) => statuses.add(item.status));
|
|
1679
|
+
return Array.from(statuses).sort();
|
|
1680
|
+
}, [items]);
|
|
1618
1681
|
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
1619
1682
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1620
1683
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1621
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
1622
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1684
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchanges" }),
|
|
1685
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer exchange requests" })
|
|
1623
1686
|
] }),
|
|
1624
|
-
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () =>
|
|
1687
|
+
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadSwaps(0, true), children: "Refresh" })
|
|
1625
1688
|
] }),
|
|
1626
|
-
/* @__PURE__ */
|
|
1689
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1627
1690
|
/* @__PURE__ */ jsx(
|
|
1628
1691
|
Input,
|
|
1629
1692
|
{
|
|
1630
|
-
placeholder: "
|
|
1631
|
-
value:
|
|
1632
|
-
onChange: (
|
|
1633
|
-
className: "md:max-w-
|
|
1634
|
-
"aria-label": "Filter by order ID"
|
|
1635
|
-
}
|
|
1636
|
-
),
|
|
1637
|
-
/* @__PURE__ */ jsx(
|
|
1638
|
-
Input,
|
|
1639
|
-
{
|
|
1640
|
-
placeholder: "Provider",
|
|
1641
|
-
value: providerSearch,
|
|
1642
|
-
onChange: (e) => setProviderSearch(e.target.value),
|
|
1643
|
-
className: "md:max-w-[140px]",
|
|
1644
|
-
"aria-label": "Filter by provider"
|
|
1645
|
-
}
|
|
1646
|
-
),
|
|
1647
|
-
/* @__PURE__ */ jsx(
|
|
1648
|
-
Input,
|
|
1649
|
-
{
|
|
1650
|
-
placeholder: "Currency",
|
|
1651
|
-
value: currencySearch,
|
|
1652
|
-
onChange: (e) => setCurrencySearch(e.target.value),
|
|
1653
|
-
className: "md:max-w-[100px]",
|
|
1654
|
-
"aria-label": "Filter by currency"
|
|
1655
|
-
}
|
|
1656
|
-
),
|
|
1657
|
-
/* @__PURE__ */ jsxs(
|
|
1658
|
-
"select",
|
|
1659
|
-
{
|
|
1660
|
-
value: paymentStatusFilter,
|
|
1661
|
-
onChange: (e) => setPaymentStatusFilter(e.target.value),
|
|
1662
|
-
className: "h-9 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 md:max-w-[160px]",
|
|
1663
|
-
"aria-label": "Filter by payment status",
|
|
1664
|
-
children: [
|
|
1665
|
-
/* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
|
|
1666
|
-
/* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
|
|
1667
|
-
/* @__PURE__ */ jsx("option", { value: "requires_more", children: "Requires more" }),
|
|
1668
|
-
/* @__PURE__ */ jsx("option", { value: "error", children: "Error" }),
|
|
1669
|
-
/* @__PURE__ */ jsx("option", { value: "canceled", children: "Canceled" }),
|
|
1670
|
-
/* @__PURE__ */ jsx("option", { value: "authorized", children: "Authorized" }),
|
|
1671
|
-
/* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
|
|
1672
|
-
]
|
|
1673
|
-
}
|
|
1674
|
-
),
|
|
1675
|
-
/* @__PURE__ */ jsx(
|
|
1676
|
-
Input,
|
|
1677
|
-
{
|
|
1678
|
-
type: "date",
|
|
1679
|
-
placeholder: "From",
|
|
1680
|
-
value: dateFrom,
|
|
1681
|
-
onChange: (e) => setDateFrom(e.target.value),
|
|
1682
|
-
className: "md:max-w-[140px]",
|
|
1683
|
-
"aria-label": "Date from"
|
|
1684
|
-
}
|
|
1685
|
-
),
|
|
1686
|
-
/* @__PURE__ */ jsx(
|
|
1687
|
-
Input,
|
|
1688
|
-
{
|
|
1689
|
-
type: "date",
|
|
1690
|
-
placeholder: "To",
|
|
1691
|
-
value: dateTo,
|
|
1692
|
-
onChange: (e) => setDateTo(e.target.value),
|
|
1693
|
-
className: "md:max-w-[140px]",
|
|
1694
|
-
"aria-label": "Date to"
|
|
1695
|
-
}
|
|
1696
|
-
),
|
|
1697
|
-
/* @__PURE__ */ jsx(
|
|
1698
|
-
Input,
|
|
1699
|
-
{
|
|
1700
|
-
placeholder: "Amount min",
|
|
1701
|
-
value: amountMin,
|
|
1702
|
-
onChange: (e) => setAmountMin(e.target.value),
|
|
1703
|
-
type: "number",
|
|
1704
|
-
min: 0,
|
|
1705
|
-
className: "md:max-w-[100px]",
|
|
1706
|
-
"aria-label": "Refund amount minimum"
|
|
1693
|
+
placeholder: "Search by swap ID or order ID",
|
|
1694
|
+
value: searchQuery,
|
|
1695
|
+
onChange: (event) => setSearchQuery(event.target.value),
|
|
1696
|
+
className: "md:max-w-sm"
|
|
1707
1697
|
}
|
|
1708
1698
|
),
|
|
1709
|
-
/* @__PURE__ */
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1699
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
1700
|
+
/* @__PURE__ */ jsxs(
|
|
1701
|
+
"select",
|
|
1702
|
+
{
|
|
1703
|
+
value: createdByFilter,
|
|
1704
|
+
onChange: (event) => setCreatedByFilter(event.target.value),
|
|
1705
|
+
className: "h-9 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 md:max-w-xs",
|
|
1706
|
+
children: [
|
|
1707
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: "All (Created by)" }),
|
|
1708
|
+
/* @__PURE__ */ jsx("option", { value: "customer", children: "Customer" }),
|
|
1709
|
+
/* @__PURE__ */ jsx("option", { value: "admin", children: "Admin" })
|
|
1710
|
+
]
|
|
1711
|
+
}
|
|
1712
|
+
),
|
|
1713
|
+
/* @__PURE__ */ jsxs(
|
|
1714
|
+
"select",
|
|
1715
|
+
{
|
|
1716
|
+
value: statusFilter,
|
|
1717
|
+
onChange: (event) => setStatusFilter(event.target.value),
|
|
1718
|
+
className: "h-9 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 md:max-w-xs",
|
|
1719
|
+
children: [
|
|
1720
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: "All Statuses" }),
|
|
1721
|
+
availableStatuses.map((status) => /* @__PURE__ */ jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
1722
|
+
]
|
|
1723
|
+
}
|
|
1724
|
+
)
|
|
1725
|
+
] })
|
|
1726
|
+
] }),
|
|
1722
1727
|
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1723
1728
|
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1724
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1729
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1730
|
+
Button,
|
|
1731
|
+
{
|
|
1732
|
+
variant: "secondary",
|
|
1733
|
+
onClick: () => loadSwaps(0, true),
|
|
1734
|
+
children: "Try again"
|
|
1735
|
+
}
|
|
1736
|
+
) })
|
|
1725
1737
|
] }) : null,
|
|
1726
|
-
isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading
|
|
1727
|
-
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No
|
|
1728
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "
|
|
1729
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "
|
|
1738
|
+
isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading swaps..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
1739
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No exchanges yet" }),
|
|
1740
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Exchange requests created by customers will appear here." })
|
|
1741
|
+
] }) : /* @__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: [
|
|
1730
1742
|
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1731
|
-
/* @__PURE__ */ jsx("th", { className: "
|
|
1732
|
-
/* @__PURE__ */ jsx("th", { className: "
|
|
1733
|
-
/* @__PURE__ */ jsx("th", { className: "
|
|
1734
|
-
/* @__PURE__ */ jsx("th", { className: "
|
|
1735
|
-
/* @__PURE__ */ jsx("th", { className: "
|
|
1736
|
-
/* @__PURE__ */ jsx("th", { className: "
|
|
1737
|
-
/* @__PURE__ */ jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment Status" }),
|
|
1738
|
-
/* @__PURE__ */ jsx("th", { className: "w-[14%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Note" }),
|
|
1739
|
-
/* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1740
|
-
/* @__PURE__ */ jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1743
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Exchange ID" }),
|
|
1744
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
1745
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
1746
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Difference Due" }),
|
|
1747
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1748
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1741
1749
|
] }) }),
|
|
1742
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((
|
|
1750
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxs(
|
|
1743
1751
|
"tr",
|
|
1744
1752
|
{
|
|
1745
|
-
className: "
|
|
1746
|
-
onClick: () => navigate(`/
|
|
1753
|
+
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1754
|
+
onClick: () => navigate(`/swaps/${swap.id}`),
|
|
1747
1755
|
children: [
|
|
1748
|
-
/* @__PURE__ */ jsx("td", { className: "
|
|
1749
|
-
/* @__PURE__ */ jsx("td", { className: "
|
|
1750
|
-
/* @__PURE__ */ jsx("td", { className: "
|
|
1751
|
-
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", children: displayAmount(r) }),
|
|
1752
|
-
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle uppercase", children: r.currency_code || "—" }),
|
|
1753
|
-
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.provider_id || void 0, children: r.provider_id || "—" }),
|
|
1754
|
-
/* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsx(
|
|
1756
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsx("span", { children: swap.id }) }) }),
|
|
1757
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: swap.order_id }),
|
|
1758
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1755
1759
|
Badge,
|
|
1756
1760
|
{
|
|
1757
1761
|
size: "2xsmall",
|
|
1758
|
-
className: `uppercase ${getStatusBadgeClass$4(
|
|
1759
|
-
children:
|
|
1762
|
+
className: `uppercase ${getStatusBadgeClass$4(swap.status)}`,
|
|
1763
|
+
children: swap.status.replace(/_/g, " ")
|
|
1760
1764
|
}
|
|
1761
1765
|
) }),
|
|
1762
|
-
/* @__PURE__ */ jsx("td", { className: "
|
|
1763
|
-
|
|
1766
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
|
|
1767
|
+
const amount = swap.difference_due;
|
|
1768
|
+
if (amount == null || amount === void 0) {
|
|
1769
|
+
return "—";
|
|
1770
|
+
}
|
|
1771
|
+
const displayAmount = Number(amount) / 100;
|
|
1772
|
+
const currency = swap.currency_code || "$";
|
|
1773
|
+
const sign = displayAmount >= 0 ? "+" : "";
|
|
1774
|
+
return `${sign}${currency}${displayAmount.toFixed(2)}`;
|
|
1775
|
+
})() }),
|
|
1776
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(swap.created_at).toLocaleDateString("en-US", {
|
|
1777
|
+
year: "numeric",
|
|
1764
1778
|
month: "short",
|
|
1765
1779
|
day: "numeric",
|
|
1766
1780
|
hour: "numeric",
|
|
1767
1781
|
minute: "2-digit",
|
|
1768
1782
|
hour12: true
|
|
1769
1783
|
}) }),
|
|
1770
|
-
/* @__PURE__ */ jsx("td", { className: "
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
),
|
|
1783
|
-
r.order_id ? /* @__PURE__ */ jsx(
|
|
1784
|
-
Button,
|
|
1785
|
-
{
|
|
1786
|
-
variant: "transparent",
|
|
1787
|
-
size: "small",
|
|
1788
|
-
onClick: (e) => {
|
|
1789
|
-
e.stopPropagation();
|
|
1790
|
-
navigate(`/orders/${r.order_id}`);
|
|
1791
|
-
},
|
|
1792
|
-
children: "Order"
|
|
1793
|
-
}
|
|
1794
|
-
) : null
|
|
1795
|
-
] }) })
|
|
1784
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1785
|
+
Button,
|
|
1786
|
+
{
|
|
1787
|
+
variant: "transparent",
|
|
1788
|
+
size: "small",
|
|
1789
|
+
onClick: (e) => {
|
|
1790
|
+
e.stopPropagation();
|
|
1791
|
+
navigate(`/app/orders/${swap.order_id}`);
|
|
1792
|
+
},
|
|
1793
|
+
children: "Go to order"
|
|
1794
|
+
}
|
|
1795
|
+
) })
|
|
1796
1796
|
]
|
|
1797
1797
|
},
|
|
1798
|
-
|
|
1798
|
+
swap.id
|
|
1799
1799
|
)) })
|
|
1800
1800
|
] }) }),
|
|
1801
1801
|
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
@@ -1803,294 +1803,207 @@ const RefundsPage = () => {
|
|
|
1803
1803
|
{
|
|
1804
1804
|
variant: "secondary",
|
|
1805
1805
|
isLoading: isFetchingMore,
|
|
1806
|
-
onClick: () =>
|
|
1806
|
+
onClick: () => loadSwaps(offset, false),
|
|
1807
1807
|
children: "Load more"
|
|
1808
1808
|
}
|
|
1809
1809
|
) }) : null
|
|
1810
1810
|
] }) });
|
|
1811
1811
|
};
|
|
1812
1812
|
const config$4 = defineRouteConfig({
|
|
1813
|
-
label: "
|
|
1814
|
-
icon:
|
|
1813
|
+
label: "Exchanges",
|
|
1814
|
+
icon: ArrowPath
|
|
1815
1815
|
});
|
|
1816
1816
|
const getStatusBadgeClass$3 = (status) => {
|
|
1817
|
-
const
|
|
1818
|
-
if (
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
if (
|
|
1822
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1823
|
-
}
|
|
1824
|
-
if (statusLower === "rejected") {
|
|
1825
|
-
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1826
|
-
}
|
|
1827
|
-
if (statusLower === "completed") {
|
|
1828
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1829
|
-
}
|
|
1830
|
-
if (statusLower === "cancelled" || statusLower === "canceled") {
|
|
1831
|
-
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
1832
|
-
}
|
|
1833
|
-
if (statusLower === "pending") {
|
|
1834
|
-
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1835
|
-
}
|
|
1817
|
+
const s2 = status.toLowerCase();
|
|
1818
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1819
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1820
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1821
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1836
1822
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1837
1823
|
};
|
|
1838
|
-
const
|
|
1824
|
+
const formatAmount = (value) => {
|
|
1825
|
+
return String(value);
|
|
1826
|
+
};
|
|
1827
|
+
const RefundDetailPage = () => {
|
|
1839
1828
|
var _a, _b, _c;
|
|
1840
1829
|
const navigate = useNavigate();
|
|
1841
|
-
const
|
|
1842
|
-
const
|
|
1843
|
-
const [
|
|
1844
|
-
const [
|
|
1845
|
-
useState(false);
|
|
1846
|
-
const [isCancelling, setIsCancelling] = useState(false);
|
|
1830
|
+
const params = useParams();
|
|
1831
|
+
const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
|
|
1832
|
+
const [detail, setDetail] = useState(null);
|
|
1833
|
+
const [loading, setLoading] = useState(!!id);
|
|
1847
1834
|
const [error, setError] = useState(null);
|
|
1848
|
-
const [
|
|
1849
|
-
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
1835
|
+
const [gatewayExpanded, setGatewayExpanded] = useState(false);
|
|
1850
1836
|
useEffect(() => {
|
|
1851
1837
|
if (!id) {
|
|
1852
|
-
|
|
1838
|
+
setLoading(false);
|
|
1853
1839
|
return;
|
|
1854
1840
|
}
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
1871
|
-
setError(message);
|
|
1872
|
-
} finally {
|
|
1873
|
-
setIsLoading(false);
|
|
1874
|
-
}
|
|
1841
|
+
let cancelled = false;
|
|
1842
|
+
setLoading(true);
|
|
1843
|
+
setError(null);
|
|
1844
|
+
fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
|
|
1845
|
+
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
1846
|
+
return res.json();
|
|
1847
|
+
}).then((data) => {
|
|
1848
|
+
if (!cancelled) setDetail(data);
|
|
1849
|
+
}).catch((e) => {
|
|
1850
|
+
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
1851
|
+
}).finally(() => {
|
|
1852
|
+
if (!cancelled) setLoading(false);
|
|
1853
|
+
});
|
|
1854
|
+
return () => {
|
|
1855
|
+
cancelled = true;
|
|
1875
1856
|
};
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
const
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
},
|
|
1891
|
-
|
|
1892
|
-
});
|
|
1893
|
-
if (!response.ok) {
|
|
1894
|
-
const message = await response.text();
|
|
1895
|
-
throw new Error(message || "Unable to cancel exchange");
|
|
1896
|
-
}
|
|
1897
|
-
const payload = await response.json();
|
|
1898
|
-
setSwap(payload.swap);
|
|
1899
|
-
setUpdateSuccess(true);
|
|
1900
|
-
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
1901
|
-
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
1902
|
-
credentials: "include"
|
|
1903
|
-
});
|
|
1904
|
-
if (detailResponse.ok) {
|
|
1905
|
-
const detailPayload = await detailResponse.json();
|
|
1906
|
-
setSwap(detailPayload.swap);
|
|
1907
|
-
setOrder(detailPayload.order || null);
|
|
1908
|
-
}
|
|
1909
|
-
} catch (cancelErr) {
|
|
1910
|
-
const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
|
|
1911
|
-
setUpdateError(message);
|
|
1912
|
-
} finally {
|
|
1913
|
-
setIsCancelling(false);
|
|
1914
|
-
}
|
|
1915
|
-
};
|
|
1916
|
-
const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
|
|
1917
|
-
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
1918
|
-
((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
|
|
1919
|
-
);
|
|
1920
|
-
if (isLoading) {
|
|
1921
|
-
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading swap..." }) }) }) });
|
|
1922
|
-
}
|
|
1923
|
-
if (error || !swap) {
|
|
1924
|
-
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1925
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
1926
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
1927
|
-
] }) }) });
|
|
1928
|
-
}
|
|
1929
|
-
const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
|
|
1930
|
-
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: [
|
|
1931
|
-
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
1932
|
-
/* @__PURE__ */ jsxs(
|
|
1933
|
-
Button,
|
|
1934
|
-
{
|
|
1935
|
-
variant: "transparent",
|
|
1936
|
-
size: "small",
|
|
1937
|
-
onClick: () => navigate("/swaps"),
|
|
1938
|
-
className: "w-fit",
|
|
1939
|
-
children: [
|
|
1940
|
-
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
1941
|
-
"Back to list"
|
|
1942
|
-
]
|
|
1943
|
-
}
|
|
1944
|
-
),
|
|
1945
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
1946
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1947
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchange Details" }),
|
|
1948
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
1949
|
-
] }),
|
|
1950
|
-
/* @__PURE__ */ jsx(
|
|
1951
|
-
Badge,
|
|
1952
|
-
{
|
|
1953
|
-
size: "small",
|
|
1954
|
-
className: `uppercase ${getStatusBadgeClass$3(swap.status)}`,
|
|
1955
|
-
children: swap.status.replace(/_/g, " ")
|
|
1956
|
-
}
|
|
1957
|
-
)
|
|
1958
|
-
] })
|
|
1959
|
-
] }),
|
|
1960
|
-
canCancelExchange && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
1961
|
-
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
1962
|
-
Button,
|
|
1963
|
-
{
|
|
1964
|
-
variant: "danger",
|
|
1965
|
-
onClick: handleCancelExchange,
|
|
1966
|
-
disabled: isCancelling,
|
|
1967
|
-
isLoading: isCancelling,
|
|
1968
|
-
children: "Cancel Exchange"
|
|
1969
|
-
}
|
|
1970
|
-
) }),
|
|
1971
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
|
|
1972
|
-
] }),
|
|
1973
|
-
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
1974
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1975
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
1976
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
1857
|
+
}, [id]);
|
|
1858
|
+
const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
|
|
1859
|
+
const hasGatewayData = ((_c = detail == null ? void 0 : detail.payment) == null ? void 0 : _c.payment_data) && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
|
|
1860
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
|
|
1861
|
+
/* @__PURE__ */ jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1862
|
+
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
|
|
1863
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refund details" }),
|
|
1864
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
|
|
1865
|
+
] }) }),
|
|
1866
|
+
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1867
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1868
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
|
|
1869
|
+
] }) : loading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
1870
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
1871
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
|
|
1872
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
1977
1873
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1978
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
1979
|
-
/* @__PURE__ */ jsx(Text, { className: "font-
|
|
1874
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
|
|
1875
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
|
|
1980
1876
|
] }),
|
|
1981
1877
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1982
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
1983
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
1878
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
1879
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
|
|
1984
1880
|
] }),
|
|
1985
1881
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1986
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
1987
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
1882
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
|
|
1883
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
|
|
1988
1884
|
] }),
|
|
1989
|
-
|
|
1990
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
1991
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
1885
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1886
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
|
|
1887
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
|
|
1888
|
+
year: "numeric",
|
|
1889
|
+
month: "short",
|
|
1890
|
+
day: "numeric",
|
|
1891
|
+
hour: "numeric",
|
|
1892
|
+
minute: "2-digit",
|
|
1893
|
+
hour12: true
|
|
1894
|
+
}) })
|
|
1992
1895
|
] }),
|
|
1993
|
-
|
|
1994
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
1995
|
-
/* @__PURE__ */ jsx(Text, { className: "font-
|
|
1896
|
+
detail.refund.created_by ? /* @__PURE__ */ jsxs("div", { children: [
|
|
1897
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
|
|
1898
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
|
|
1899
|
+
] }) : null
|
|
1900
|
+
] })
|
|
1901
|
+
] }),
|
|
1902
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
1903
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
|
|
1904
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
1905
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1906
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
|
|
1907
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
|
|
1996
1908
|
] }),
|
|
1997
1909
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1998
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
1999
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
1910
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
|
|
1911
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
|
|
2000
1912
|
] }),
|
|
2001
1913
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2002
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2003
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
1914
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
|
|
1915
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
|
|
2004
1916
|
] }),
|
|
2005
|
-
|
|
2006
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2007
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2008
|
-
] })
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
/* @__PURE__ */
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
1917
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1918
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
1919
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
|
|
1920
|
+
] }),
|
|
1921
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1922
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
1923
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
1924
|
+
Badge,
|
|
1925
|
+
{
|
|
1926
|
+
size: "2xsmall",
|
|
1927
|
+
className: `uppercase ${getStatusBadgeClass$3(paymentStatus)}`,
|
|
1928
|
+
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
1929
|
+
}
|
|
1930
|
+
) })
|
|
1931
|
+
] }),
|
|
1932
|
+
detail.computed ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1933
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1934
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
|
|
1935
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
|
|
1936
|
+
] }),
|
|
1937
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1938
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
1939
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
1940
|
+
] }),
|
|
1941
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1942
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
1943
|
+
/* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
|
|
1944
|
+
detail.computed.refund_percentage.toFixed(1),
|
|
1945
|
+
"%"
|
|
2030
1946
|
] })
|
|
2031
1947
|
] })
|
|
2032
|
-
}
|
|
2033
|
-
index
|
|
2034
|
-
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2035
|
-
] })
|
|
2036
|
-
] }),
|
|
2037
|
-
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2038
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2039
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2040
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2041
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2042
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
|
|
2043
|
-
] }),
|
|
2044
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2045
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2046
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
|
|
2047
|
-
] }),
|
|
2048
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2049
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2050
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = order.customer) == null ? void 0 : _c.email) || order.email || "—" })
|
|
2051
|
-
] }),
|
|
2052
|
-
order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2053
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2054
|
-
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
2055
|
-
order.currency_code || "$",
|
|
2056
|
-
(Number(order.total) / 100).toFixed(2)
|
|
2057
|
-
] })
|
|
1948
|
+
] }) : null
|
|
2058
1949
|
] })
|
|
1950
|
+
] }),
|
|
1951
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
1952
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
|
|
1953
|
+
detail.order ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
1954
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1955
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
1956
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
1957
|
+
Button,
|
|
1958
|
+
{
|
|
1959
|
+
variant: "transparent",
|
|
1960
|
+
size: "small",
|
|
1961
|
+
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
1962
|
+
children: detail.order.order_number ?? detail.order.order_id
|
|
1963
|
+
}
|
|
1964
|
+
) })
|
|
1965
|
+
] }),
|
|
1966
|
+
detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
|
|
1967
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
1968
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
1969
|
+
] }) : null,
|
|
1970
|
+
detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
|
|
1971
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
1972
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
1973
|
+
] }) : null,
|
|
1974
|
+
detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
|
|
1975
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
1976
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
|
|
1977
|
+
] }) : null,
|
|
1978
|
+
detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
|
|
1979
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
1980
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
1981
|
+
] }) : null
|
|
1982
|
+
] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
1983
|
+
] }),
|
|
1984
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
1985
|
+
/* @__PURE__ */ jsxs(
|
|
1986
|
+
"button",
|
|
1987
|
+
{
|
|
1988
|
+
type: "button",
|
|
1989
|
+
className: "flex w-full items-center justify-between text-left",
|
|
1990
|
+
onClick: () => setGatewayExpanded((prev) => !prev),
|
|
1991
|
+
"aria-expanded": gatewayExpanded,
|
|
1992
|
+
"aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
|
|
1993
|
+
children: [
|
|
1994
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
|
|
1995
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
|
|
1996
|
+
]
|
|
1997
|
+
}
|
|
1998
|
+
),
|
|
1999
|
+
gatewayExpanded && /* @__PURE__ */ jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.payment.payment_data, null, 2) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
|
|
2059
2000
|
] })
|
|
2060
|
-
] })
|
|
2061
|
-
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: [
|
|
2062
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2063
|
-
/* @__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: [
|
|
2064
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2065
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
|
|
2066
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2067
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2068
|
-
] }) }),
|
|
2069
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2070
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2071
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2072
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2073
|
-
] }, item.id || index)) })
|
|
2074
|
-
] }) })
|
|
2075
|
-
] }),
|
|
2076
|
-
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: [
|
|
2077
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
2078
|
-
/* @__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: [
|
|
2079
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2080
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
2081
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
2082
|
-
] }) }),
|
|
2083
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2084
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
2085
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
2086
|
-
] }, item.variant_id || index)) })
|
|
2087
|
-
] }) })
|
|
2088
|
-
] })
|
|
2001
|
+
] }) : null
|
|
2089
2002
|
] }) });
|
|
2090
2003
|
};
|
|
2091
2004
|
const config$3 = defineRouteConfig({
|
|
2092
|
-
label: "
|
|
2093
|
-
icon:
|
|
2005
|
+
label: "Refund details",
|
|
2006
|
+
icon: Receipt
|
|
2094
2007
|
});
|
|
2095
2008
|
const getStatusBadgeClass$2 = (status) => {
|
|
2096
2009
|
const statusLower = status.toLowerCase();
|
|
@@ -2103,105 +2016,109 @@ const getStatusBadgeClass$2 = (status) => {
|
|
|
2103
2016
|
if (statusLower === "rejected") {
|
|
2104
2017
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2105
2018
|
}
|
|
2106
|
-
if (statusLower === "received") {
|
|
2107
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2108
|
-
}
|
|
2109
|
-
if (statusLower === "refunded") {
|
|
2110
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2111
|
-
}
|
|
2112
2019
|
if (statusLower === "completed") {
|
|
2113
2020
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2114
2021
|
}
|
|
2115
|
-
if (statusLower === "cancelled") {
|
|
2022
|
+
if (statusLower === "cancelled" || statusLower === "canceled") {
|
|
2116
2023
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2117
2024
|
}
|
|
2025
|
+
if (statusLower === "pending") {
|
|
2026
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2027
|
+
}
|
|
2118
2028
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2119
2029
|
};
|
|
2120
|
-
const
|
|
2121
|
-
var _a, _b;
|
|
2030
|
+
const SwapDetailPage = () => {
|
|
2031
|
+
var _a, _b, _c;
|
|
2122
2032
|
const navigate = useNavigate();
|
|
2123
2033
|
const { id } = useParams();
|
|
2124
|
-
const [
|
|
2034
|
+
const [swap, setSwap] = useState(null);
|
|
2035
|
+
const [order, setOrder] = useState(null);
|
|
2125
2036
|
const [isLoading, setIsLoading] = useState(true);
|
|
2126
|
-
|
|
2037
|
+
useState(false);
|
|
2038
|
+
const [isCancelling, setIsCancelling] = useState(false);
|
|
2127
2039
|
const [error, setError] = useState(null);
|
|
2128
2040
|
const [updateError, setUpdateError] = useState(null);
|
|
2129
2041
|
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
2130
2042
|
useEffect(() => {
|
|
2131
2043
|
if (!id) {
|
|
2132
|
-
navigate("/
|
|
2044
|
+
navigate("/swaps");
|
|
2133
2045
|
return;
|
|
2134
2046
|
}
|
|
2135
|
-
const
|
|
2047
|
+
const loadSwap = async () => {
|
|
2136
2048
|
try {
|
|
2137
2049
|
setIsLoading(true);
|
|
2138
2050
|
setError(null);
|
|
2139
|
-
const response = await fetch(`/admin/
|
|
2051
|
+
const response = await fetch(`/admin/swaps/${id}`, {
|
|
2140
2052
|
credentials: "include"
|
|
2141
2053
|
});
|
|
2142
2054
|
if (!response.ok) {
|
|
2143
2055
|
const message = await response.text();
|
|
2144
|
-
throw new Error(message || "Unable to load
|
|
2056
|
+
throw new Error(message || "Unable to load swap");
|
|
2145
2057
|
}
|
|
2146
2058
|
const payload = await response.json();
|
|
2147
|
-
|
|
2059
|
+
setSwap(payload.swap);
|
|
2060
|
+
setOrder(payload.order || null);
|
|
2148
2061
|
} catch (loadError) {
|
|
2149
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
2062
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
2150
2063
|
setError(message);
|
|
2151
2064
|
} finally {
|
|
2152
2065
|
setIsLoading(false);
|
|
2153
2066
|
}
|
|
2154
2067
|
};
|
|
2155
|
-
void
|
|
2068
|
+
void loadSwap();
|
|
2156
2069
|
}, [id, navigate]);
|
|
2157
|
-
const
|
|
2070
|
+
const handleCancelExchange = async () => {
|
|
2158
2071
|
if (!id) {
|
|
2159
2072
|
return;
|
|
2160
2073
|
}
|
|
2161
2074
|
try {
|
|
2162
|
-
|
|
2075
|
+
setIsCancelling(true);
|
|
2163
2076
|
setUpdateError(null);
|
|
2164
2077
|
setUpdateSuccess(false);
|
|
2165
|
-
const response = await fetch(`/admin/
|
|
2078
|
+
const response = await fetch(`/admin/swaps/${id}/cancel`, {
|
|
2166
2079
|
method: "POST",
|
|
2167
2080
|
headers: {
|
|
2168
2081
|
"Content-Type": "application/json"
|
|
2169
2082
|
},
|
|
2170
|
-
credentials: "include"
|
|
2171
|
-
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
2083
|
+
credentials: "include"
|
|
2172
2084
|
});
|
|
2173
2085
|
if (!response.ok) {
|
|
2174
2086
|
const message = await response.text();
|
|
2175
|
-
throw new Error(message || "Unable to
|
|
2087
|
+
throw new Error(message || "Unable to cancel exchange");
|
|
2176
2088
|
}
|
|
2177
2089
|
const payload = await response.json();
|
|
2178
|
-
|
|
2090
|
+
setSwap(payload.swap);
|
|
2179
2091
|
setUpdateSuccess(true);
|
|
2180
2092
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2181
|
-
const detailResponse = await fetch(`/admin/
|
|
2093
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
2182
2094
|
credentials: "include"
|
|
2183
2095
|
});
|
|
2184
2096
|
if (detailResponse.ok) {
|
|
2185
2097
|
const detailPayload = await detailResponse.json();
|
|
2186
|
-
|
|
2098
|
+
setSwap(detailPayload.swap);
|
|
2099
|
+
setOrder(detailPayload.order || null);
|
|
2187
2100
|
}
|
|
2188
|
-
} catch (
|
|
2189
|
-
const message =
|
|
2101
|
+
} catch (cancelErr) {
|
|
2102
|
+
const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
|
|
2190
2103
|
setUpdateError(message);
|
|
2191
2104
|
} finally {
|
|
2192
|
-
|
|
2105
|
+
setIsCancelling(false);
|
|
2193
2106
|
}
|
|
2194
2107
|
};
|
|
2108
|
+
const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
|
|
2109
|
+
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
2110
|
+
((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
|
|
2111
|
+
);
|
|
2195
2112
|
if (isLoading) {
|
|
2196
|
-
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading
|
|
2113
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading swap..." }) }) }) });
|
|
2197
2114
|
}
|
|
2198
|
-
if (error || !
|
|
2115
|
+
if (error || !swap) {
|
|
2199
2116
|
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2200
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "
|
|
2201
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/
|
|
2117
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
2118
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
2202
2119
|
] }) }) });
|
|
2203
2120
|
}
|
|
2204
|
-
const statusHistory = ((
|
|
2121
|
+
const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
|
|
2205
2122
|
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: [
|
|
2206
2123
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2207
2124
|
/* @__PURE__ */ jsxs(
|
|
@@ -2209,7 +2126,7 @@ const ReturnDetailPage = () => {
|
|
|
2209
2126
|
{
|
|
2210
2127
|
variant: "transparent",
|
|
2211
2128
|
size: "small",
|
|
2212
|
-
onClick: () => navigate("/
|
|
2129
|
+
onClick: () => navigate("/swaps"),
|
|
2213
2130
|
className: "w-fit",
|
|
2214
2131
|
children: [
|
|
2215
2132
|
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
@@ -2219,81 +2136,67 @@ const ReturnDetailPage = () => {
|
|
|
2219
2136
|
),
|
|
2220
2137
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2221
2138
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2222
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
2223
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2139
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchange Details" }),
|
|
2140
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
2224
2141
|
] }),
|
|
2225
2142
|
/* @__PURE__ */ jsx(
|
|
2226
2143
|
Badge,
|
|
2227
2144
|
{
|
|
2228
2145
|
size: "small",
|
|
2229
|
-
className: `uppercase ${getStatusBadgeClass$2(
|
|
2230
|
-
children:
|
|
2146
|
+
className: `uppercase ${getStatusBadgeClass$2(swap.status)}`,
|
|
2147
|
+
children: swap.status.replace(/_/g, " ")
|
|
2231
2148
|
}
|
|
2232
2149
|
)
|
|
2233
2150
|
] })
|
|
2234
2151
|
] }),
|
|
2235
|
-
|
|
2152
|
+
canCancelExchange && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2236
2153
|
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
2237
2154
|
Button,
|
|
2238
2155
|
{
|
|
2239
2156
|
variant: "danger",
|
|
2240
|
-
onClick:
|
|
2241
|
-
disabled:
|
|
2242
|
-
isLoading:
|
|
2243
|
-
children: "
|
|
2157
|
+
onClick: handleCancelExchange,
|
|
2158
|
+
disabled: isCancelling,
|
|
2159
|
+
isLoading: isCancelling,
|
|
2160
|
+
children: "Cancel Exchange"
|
|
2244
2161
|
}
|
|
2245
2162
|
) }),
|
|
2246
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2247
|
-
] }),
|
|
2248
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2249
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
2250
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2251
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2252
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2253
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
2254
|
-
] }),
|
|
2255
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
2256
|
-
Button,
|
|
2257
|
-
{
|
|
2258
|
-
variant: "secondary",
|
|
2259
|
-
onClick: () => {
|
|
2260
|
-
window.open(
|
|
2261
|
-
`/app/orders/${returnOrder.order_id}`,
|
|
2262
|
-
"_blank"
|
|
2263
|
-
);
|
|
2264
|
-
},
|
|
2265
|
-
children: "View order"
|
|
2266
|
-
}
|
|
2267
|
-
) })
|
|
2268
|
-
] })
|
|
2163
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
|
|
2269
2164
|
] }),
|
|
2270
2165
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2271
2166
|
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2272
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "
|
|
2167
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
2273
2168
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2274
2169
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2275
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
2276
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2170
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2171
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.id })
|
|
2277
2172
|
] }),
|
|
2278
2173
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2279
2174
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2280
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2175
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.status })
|
|
2176
|
+
] }),
|
|
2177
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2178
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
2179
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
2281
2180
|
] }),
|
|
2282
|
-
|
|
2181
|
+
swap.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
2283
2182
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2284
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2183
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.reason })
|
|
2285
2184
|
] }),
|
|
2286
|
-
|
|
2185
|
+
swap.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
2287
2186
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2288
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2187
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.note })
|
|
2289
2188
|
] }),
|
|
2290
2189
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2291
2190
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2292
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
2191
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
2293
2192
|
] }),
|
|
2294
2193
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2295
2194
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2296
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
2195
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
2196
|
+
] }),
|
|
2197
|
+
swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
|
|
2198
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2199
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
|
|
2297
2200
|
] })
|
|
2298
2201
|
] })
|
|
2299
2202
|
] }),
|
|
@@ -2323,31 +2226,31 @@ const ReturnDetailPage = () => {
|
|
|
2323
2226
|
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2324
2227
|
] })
|
|
2325
2228
|
] }),
|
|
2326
|
-
|
|
2229
|
+
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2327
2230
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2328
2231
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2329
2232
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2330
2233
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2331
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2234
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
|
|
2332
2235
|
] }),
|
|
2333
2236
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2334
2237
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2335
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2238
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
|
|
2336
2239
|
] }),
|
|
2337
2240
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2338
2241
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2339
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((
|
|
2242
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = order.customer) == null ? void 0 : _c.email) || order.email || "—" })
|
|
2340
2243
|
] }),
|
|
2341
|
-
|
|
2244
|
+
order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2342
2245
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2343
2246
|
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
2344
|
-
|
|
2345
|
-
(Number(
|
|
2247
|
+
order.currency_code || "$",
|
|
2248
|
+
(Number(order.total) / 100).toFixed(2)
|
|
2346
2249
|
] })
|
|
2347
2250
|
] })
|
|
2348
2251
|
] })
|
|
2349
2252
|
] }),
|
|
2350
|
-
|
|
2253
|
+
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: [
|
|
2351
2254
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2352
2255
|
/* @__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: [
|
|
2353
2256
|
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
@@ -2355,20 +2258,31 @@ const ReturnDetailPage = () => {
|
|
|
2355
2258
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2356
2259
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2357
2260
|
] }) }),
|
|
2358
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
2261
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2359
2262
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2360
2263
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2361
2264
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2362
2265
|
] }, item.id || index)) })
|
|
2363
2266
|
] }) })
|
|
2364
2267
|
] }),
|
|
2365
|
-
|
|
2366
|
-
|
|
2268
|
+
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: [
|
|
2269
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
2270
|
+
/* @__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: [
|
|
2271
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2272
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
2273
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
2274
|
+
] }) }),
|
|
2275
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2276
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
2277
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
2278
|
+
] }, item.variant_id || index)) })
|
|
2279
|
+
] }) })
|
|
2280
|
+
] })
|
|
2367
2281
|
] }) });
|
|
2368
2282
|
};
|
|
2369
2283
|
const config$2 = defineRouteConfig({
|
|
2370
|
-
label: "
|
|
2371
|
-
icon:
|
|
2284
|
+
label: "Swap Details",
|
|
2285
|
+
icon: ArrowPath
|
|
2372
2286
|
});
|
|
2373
2287
|
const getStatusBadgeClass$1 = (status) => {
|
|
2374
2288
|
const s2 = status.toLowerCase();
|
|
@@ -2490,196 +2404,282 @@ const config$1 = defineRouteConfig({
|
|
|
2490
2404
|
icon: CreditCard
|
|
2491
2405
|
});
|
|
2492
2406
|
const getStatusBadgeClass = (status) => {
|
|
2493
|
-
const
|
|
2494
|
-
if (
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
if (
|
|
2407
|
+
const statusLower = status.toLowerCase();
|
|
2408
|
+
if (statusLower === "requested") {
|
|
2409
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2410
|
+
}
|
|
2411
|
+
if (statusLower === "approved") {
|
|
2412
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2413
|
+
}
|
|
2414
|
+
if (statusLower === "rejected") {
|
|
2415
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2416
|
+
}
|
|
2417
|
+
if (statusLower === "received") {
|
|
2418
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2419
|
+
}
|
|
2420
|
+
if (statusLower === "refunded") {
|
|
2421
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2422
|
+
}
|
|
2423
|
+
if (statusLower === "completed") {
|
|
2424
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2425
|
+
}
|
|
2426
|
+
if (statusLower === "cancelled") {
|
|
2427
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2428
|
+
}
|
|
2498
2429
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2499
2430
|
};
|
|
2500
|
-
const
|
|
2501
|
-
|
|
2502
|
-
};
|
|
2503
|
-
const RefundDetailPage = () => {
|
|
2504
|
-
var _a, _b, _c;
|
|
2431
|
+
const ReturnDetailPage = () => {
|
|
2432
|
+
var _a, _b;
|
|
2505
2433
|
const navigate = useNavigate();
|
|
2506
|
-
const
|
|
2507
|
-
const
|
|
2508
|
-
const [
|
|
2509
|
-
const [
|
|
2434
|
+
const { id } = useParams();
|
|
2435
|
+
const [returnOrder, setReturnOrder] = useState(null);
|
|
2436
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
2437
|
+
const [isRejecting, setIsRejecting] = useState(false);
|
|
2510
2438
|
const [error, setError] = useState(null);
|
|
2511
|
-
const [
|
|
2439
|
+
const [updateError, setUpdateError] = useState(null);
|
|
2440
|
+
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
2512
2441
|
useEffect(() => {
|
|
2513
2442
|
if (!id) {
|
|
2514
|
-
|
|
2443
|
+
navigate("/returns");
|
|
2515
2444
|
return;
|
|
2516
2445
|
}
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2446
|
+
const loadReturn = async () => {
|
|
2447
|
+
try {
|
|
2448
|
+
setIsLoading(true);
|
|
2449
|
+
setError(null);
|
|
2450
|
+
const response = await fetch(`/admin/returns/${id}`, {
|
|
2451
|
+
credentials: "include"
|
|
2452
|
+
});
|
|
2453
|
+
if (!response.ok) {
|
|
2454
|
+
const message = await response.text();
|
|
2455
|
+
throw new Error(message || "Unable to load return order");
|
|
2456
|
+
}
|
|
2457
|
+
const payload = await response.json();
|
|
2458
|
+
setReturnOrder(payload.return);
|
|
2459
|
+
} catch (loadError) {
|
|
2460
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
|
|
2461
|
+
setError(message);
|
|
2462
|
+
} finally {
|
|
2463
|
+
setIsLoading(false);
|
|
2464
|
+
}
|
|
2532
2465
|
};
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
const
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2466
|
+
void loadReturn();
|
|
2467
|
+
}, [id, navigate]);
|
|
2468
|
+
const handleReject = async () => {
|
|
2469
|
+
if (!id) {
|
|
2470
|
+
return;
|
|
2471
|
+
}
|
|
2472
|
+
try {
|
|
2473
|
+
setIsRejecting(true);
|
|
2474
|
+
setUpdateError(null);
|
|
2475
|
+
setUpdateSuccess(false);
|
|
2476
|
+
const response = await fetch(`/admin/returns/${id}/reject`, {
|
|
2477
|
+
method: "POST",
|
|
2478
|
+
headers: {
|
|
2479
|
+
"Content-Type": "application/json"
|
|
2480
|
+
},
|
|
2481
|
+
credentials: "include",
|
|
2482
|
+
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
2483
|
+
});
|
|
2484
|
+
if (!response.ok) {
|
|
2485
|
+
const message = await response.text();
|
|
2486
|
+
throw new Error(message || "Unable to reject return");
|
|
2487
|
+
}
|
|
2488
|
+
const payload = await response.json();
|
|
2489
|
+
setReturnOrder(payload.return);
|
|
2490
|
+
setUpdateSuccess(true);
|
|
2491
|
+
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2492
|
+
const detailResponse = await fetch(`/admin/returns/${id}`, {
|
|
2493
|
+
credentials: "include"
|
|
2494
|
+
});
|
|
2495
|
+
if (detailResponse.ok) {
|
|
2496
|
+
const detailPayload = await detailResponse.json();
|
|
2497
|
+
setReturnOrder(detailPayload.return);
|
|
2498
|
+
}
|
|
2499
|
+
} catch (updateErr) {
|
|
2500
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to reject return";
|
|
2501
|
+
setUpdateError(message);
|
|
2502
|
+
} finally {
|
|
2503
|
+
setIsRejecting(false);
|
|
2504
|
+
}
|
|
2505
|
+
};
|
|
2506
|
+
if (isLoading) {
|
|
2507
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading return order..." }) }) }) });
|
|
2508
|
+
}
|
|
2509
|
+
if (error || !returnOrder) {
|
|
2510
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2511
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
|
|
2512
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
|
|
2513
|
+
] }) }) });
|
|
2514
|
+
}
|
|
2515
|
+
const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
|
|
2516
|
+
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: [
|
|
2517
|
+
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2518
|
+
/* @__PURE__ */ jsxs(
|
|
2519
|
+
Button,
|
|
2520
|
+
{
|
|
2521
|
+
variant: "transparent",
|
|
2522
|
+
size: "small",
|
|
2523
|
+
onClick: () => navigate("/returns"),
|
|
2524
|
+
className: "w-fit",
|
|
2525
|
+
children: [
|
|
2526
|
+
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
2527
|
+
"Back to list"
|
|
2528
|
+
]
|
|
2529
|
+
}
|
|
2530
|
+
),
|
|
2531
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2532
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2533
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Return Order Details" }),
|
|
2534
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
|
|
2535
|
+
] }),
|
|
2536
|
+
/* @__PURE__ */ jsx(
|
|
2537
|
+
Badge,
|
|
2538
|
+
{
|
|
2539
|
+
size: "small",
|
|
2540
|
+
className: `uppercase ${getStatusBadgeClass(returnOrder.status)}`,
|
|
2541
|
+
children: returnOrder.status.replace(/_/g, " ")
|
|
2542
|
+
}
|
|
2543
|
+
)
|
|
2544
|
+
] })
|
|
2545
|
+
] }),
|
|
2546
|
+
returnOrder.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2547
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
2548
|
+
Button,
|
|
2549
|
+
{
|
|
2550
|
+
variant: "danger",
|
|
2551
|
+
onClick: handleReject,
|
|
2552
|
+
disabled: isRejecting,
|
|
2553
|
+
isLoading: isRejecting,
|
|
2554
|
+
children: "Reject (Cancel) Return"
|
|
2555
|
+
}
|
|
2556
|
+
) }),
|
|
2557
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: 'Cancel this return request. Use "Mark as received" when items are received.' })
|
|
2558
|
+
] }),
|
|
2559
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2560
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
2561
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2562
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2563
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2564
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
2565
|
+
] }),
|
|
2566
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
2567
|
+
Button,
|
|
2568
|
+
{
|
|
2569
|
+
variant: "secondary",
|
|
2570
|
+
onClick: () => {
|
|
2571
|
+
window.open(
|
|
2572
|
+
`/app/orders/${returnOrder.order_id}`,
|
|
2573
|
+
"_blank"
|
|
2574
|
+
);
|
|
2575
|
+
},
|
|
2576
|
+
children: "View order"
|
|
2577
|
+
}
|
|
2578
|
+
) })
|
|
2579
|
+
] })
|
|
2580
|
+
] }),
|
|
2581
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2582
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2583
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
|
|
2584
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2561
2585
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2562
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2563
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2564
|
-
year: "numeric",
|
|
2565
|
-
month: "short",
|
|
2566
|
-
day: "numeric",
|
|
2567
|
-
hour: "numeric",
|
|
2568
|
-
minute: "2-digit",
|
|
2569
|
-
hour12: true
|
|
2570
|
-
}) })
|
|
2586
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2587
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
2571
2588
|
] }),
|
|
2572
|
-
detail.refund.created_by ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2573
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
|
|
2574
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
|
|
2575
|
-
] }) : null
|
|
2576
|
-
] })
|
|
2577
|
-
] }),
|
|
2578
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2579
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
|
|
2580
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2581
2589
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2582
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2583
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2590
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2591
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
|
|
2584
2592
|
] }),
|
|
2585
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2586
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2587
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2593
|
+
returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
2594
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2595
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
|
|
2588
2596
|
] }),
|
|
2589
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2590
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2591
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2597
|
+
returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
2598
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2599
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
|
|
2592
2600
|
] }),
|
|
2593
2601
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2594
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2595
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2602
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2603
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
|
|
2596
2604
|
] }),
|
|
2597
2605
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2598
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2599
|
-
/* @__PURE__ */ jsx(
|
|
2600
|
-
|
|
2601
|
-
{
|
|
2602
|
-
size: "2xsmall",
|
|
2603
|
-
className: `uppercase ${getStatusBadgeClass(paymentStatus)}`,
|
|
2604
|
-
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
2605
|
-
}
|
|
2606
|
-
) })
|
|
2607
|
-
] }),
|
|
2608
|
-
detail.computed ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2609
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2610
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
|
|
2611
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
|
|
2612
|
-
] }),
|
|
2613
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2614
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
2615
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
2616
|
-
] }),
|
|
2617
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2618
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
2619
|
-
/* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
|
|
2620
|
-
detail.computed.refund_percentage.toFixed(1),
|
|
2621
|
-
"%"
|
|
2622
|
-
] })
|
|
2623
|
-
] })
|
|
2624
|
-
] }) : null
|
|
2606
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2607
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
|
|
2608
|
+
] })
|
|
2625
2609
|
] })
|
|
2626
2610
|
] }),
|
|
2627
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-
|
|
2628
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
2632
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2633
|
-
Button,
|
|
2634
|
-
{
|
|
2635
|
-
variant: "transparent",
|
|
2636
|
-
size: "small",
|
|
2637
|
-
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
2638
|
-
children: detail.order.order_number ?? detail.order.order_id
|
|
2639
|
-
}
|
|
2640
|
-
) })
|
|
2641
|
-
] }),
|
|
2642
|
-
detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2643
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
2644
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
2645
|
-
] }) : null,
|
|
2646
|
-
detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2647
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
2648
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
2649
|
-
] }) : null,
|
|
2650
|
-
detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2651
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
2652
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
|
|
2653
|
-
] }) : null,
|
|
2654
|
-
detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2655
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
2656
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
2657
|
-
] }) : null
|
|
2658
|
-
] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
2659
|
-
] }),
|
|
2660
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2661
|
-
/* @__PURE__ */ jsxs(
|
|
2662
|
-
"button",
|
|
2611
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2612
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Status History" }),
|
|
2613
|
+
statusHistory.length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-2", children: statusHistory.map((entry, index) => /* @__PURE__ */ jsx(
|
|
2614
|
+
"div",
|
|
2663
2615
|
{
|
|
2664
|
-
|
|
2665
|
-
className: "flex
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2616
|
+
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
2617
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2618
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(
|
|
2619
|
+
Badge,
|
|
2620
|
+
{
|
|
2621
|
+
size: "2xsmall",
|
|
2622
|
+
className: `uppercase ${getStatusBadgeClass(entry.status)}`,
|
|
2623
|
+
children: entry.status.replace(/_/g, " ")
|
|
2624
|
+
}
|
|
2625
|
+
) }),
|
|
2626
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
2627
|
+
new Date(entry.timestamp).toLocaleString(),
|
|
2628
|
+
entry.admin_id && ` by ${entry.admin_id}`,
|
|
2629
|
+
entry.reason && ` - ${entry.reason}`
|
|
2630
|
+
] })
|
|
2631
|
+
] })
|
|
2632
|
+
},
|
|
2633
|
+
index
|
|
2634
|
+
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2676
2635
|
] })
|
|
2677
|
-
] })
|
|
2636
|
+
] }),
|
|
2637
|
+
returnOrder.order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2638
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2639
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2640
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2641
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2642
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.id })
|
|
2643
|
+
] }),
|
|
2644
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2645
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2646
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.status || "—" })
|
|
2647
|
+
] }),
|
|
2648
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2649
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2650
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_b = returnOrder.order.customer) == null ? void 0 : _b.email) || returnOrder.order.email || "—" })
|
|
2651
|
+
] }),
|
|
2652
|
+
returnOrder.order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2653
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2654
|
+
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
2655
|
+
returnOrder.order.currency_code || "$",
|
|
2656
|
+
(Number(returnOrder.order.total) / 100).toFixed(2)
|
|
2657
|
+
] })
|
|
2658
|
+
] })
|
|
2659
|
+
] })
|
|
2660
|
+
] }),
|
|
2661
|
+
returnOrder.return_items && returnOrder.return_items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2662
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2663
|
+
/* @__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: [
|
|
2664
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2665
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
|
|
2666
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2667
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2668
|
+
] }) }),
|
|
2669
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2670
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2671
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2672
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2673
|
+
] }, item.id || index)) })
|
|
2674
|
+
] }) })
|
|
2675
|
+
] }),
|
|
2676
|
+
updateError && /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-error bg-ui-bg-error-subtle p-4", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error", children: updateError }) }),
|
|
2677
|
+
updateSuccess && /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-success bg-ui-bg-success-subtle p-4", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-success", children: "Action completed successfully" }) })
|
|
2678
2678
|
] }) });
|
|
2679
2679
|
};
|
|
2680
2680
|
const config = defineRouteConfig({
|
|
2681
|
-
label: "
|
|
2682
|
-
icon:
|
|
2681
|
+
label: "Return Order Details",
|
|
2682
|
+
icon: CheckCircle
|
|
2683
2683
|
});
|
|
2684
2684
|
const i18nTranslations0 = {};
|
|
2685
2685
|
const widgetModule = { widgets: [
|
|
@@ -2695,8 +2695,8 @@ const widgetModule = { widgets: [
|
|
|
2695
2695
|
const routeModule = {
|
|
2696
2696
|
routes: [
|
|
2697
2697
|
{
|
|
2698
|
-
Component:
|
|
2699
|
-
path: "/
|
|
2698
|
+
Component: RefundsPage,
|
|
2699
|
+
path: "/refunds"
|
|
2700
2700
|
},
|
|
2701
2701
|
{
|
|
2702
2702
|
Component: ReturnsPage,
|
|
@@ -2707,57 +2707,57 @@ const routeModule = {
|
|
|
2707
2707
|
path: "/payments"
|
|
2708
2708
|
},
|
|
2709
2709
|
{
|
|
2710
|
-
Component:
|
|
2711
|
-
path: "/
|
|
2710
|
+
Component: SwapsPage,
|
|
2711
|
+
path: "/swaps"
|
|
2712
2712
|
},
|
|
2713
2713
|
{
|
|
2714
|
-
Component:
|
|
2715
|
-
path: "/
|
|
2714
|
+
Component: RefundDetailPage,
|
|
2715
|
+
path: "/refunds/:id"
|
|
2716
2716
|
},
|
|
2717
2717
|
{
|
|
2718
|
-
Component:
|
|
2719
|
-
path: "/
|
|
2718
|
+
Component: SwapDetailPage,
|
|
2719
|
+
path: "/swaps/:id"
|
|
2720
2720
|
},
|
|
2721
2721
|
{
|
|
2722
2722
|
Component: PaymentDetailPage,
|
|
2723
2723
|
path: "/payments/:id"
|
|
2724
2724
|
},
|
|
2725
2725
|
{
|
|
2726
|
-
Component:
|
|
2727
|
-
path: "/
|
|
2726
|
+
Component: ReturnDetailPage,
|
|
2727
|
+
path: "/returns/:id"
|
|
2728
2728
|
}
|
|
2729
2729
|
]
|
|
2730
2730
|
};
|
|
2731
2731
|
const menuItemModule = {
|
|
2732
2732
|
menuItems: [
|
|
2733
|
-
{
|
|
2734
|
-
label: config$4.label,
|
|
2735
|
-
icon: config$4.icon,
|
|
2736
|
-
path: "/refunds",
|
|
2737
|
-
nested: void 0
|
|
2738
|
-
},
|
|
2739
2733
|
{
|
|
2740
2734
|
label: config$5.label,
|
|
2741
2735
|
icon: config$5.icon,
|
|
2742
2736
|
path: "/payments",
|
|
2743
2737
|
nested: void 0
|
|
2744
2738
|
},
|
|
2739
|
+
{
|
|
2740
|
+
label: config$6.label,
|
|
2741
|
+
icon: config$6.icon,
|
|
2742
|
+
path: "/returns",
|
|
2743
|
+
nested: void 0
|
|
2744
|
+
},
|
|
2745
2745
|
{
|
|
2746
2746
|
label: config$7.label,
|
|
2747
2747
|
icon: config$7.icon,
|
|
2748
|
-
path: "/
|
|
2748
|
+
path: "/refunds",
|
|
2749
2749
|
nested: void 0
|
|
2750
2750
|
},
|
|
2751
2751
|
{
|
|
2752
|
-
label: config$
|
|
2753
|
-
icon: config$
|
|
2754
|
-
path: "/
|
|
2752
|
+
label: config$4.label,
|
|
2753
|
+
icon: config$4.icon,
|
|
2754
|
+
path: "/swaps",
|
|
2755
2755
|
nested: void 0
|
|
2756
2756
|
},
|
|
2757
2757
|
{
|
|
2758
2758
|
label: config.label,
|
|
2759
2759
|
icon: config.icon,
|
|
2760
|
-
path: "/
|
|
2760
|
+
path: "/returns/:id",
|
|
2761
2761
|
nested: void 0
|
|
2762
2762
|
},
|
|
2763
2763
|
{
|
|
@@ -2769,13 +2769,13 @@ const menuItemModule = {
|
|
|
2769
2769
|
{
|
|
2770
2770
|
label: config$2.label,
|
|
2771
2771
|
icon: config$2.icon,
|
|
2772
|
-
path: "/
|
|
2772
|
+
path: "/swaps/:id",
|
|
2773
2773
|
nested: void 0
|
|
2774
2774
|
},
|
|
2775
2775
|
{
|
|
2776
2776
|
label: config$3.label,
|
|
2777
2777
|
icon: config$3.icon,
|
|
2778
|
-
path: "/
|
|
2778
|
+
path: "/refunds/:id",
|
|
2779
2779
|
nested: void 0
|
|
2780
2780
|
}
|
|
2781
2781
|
]
|