order-management 0.0.105 → 0.0.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +999 -999
- package/.medusa/server/src/admin/index.mjs +1000 -1000
- package/.medusa/server/src/api/store/returns/route.js +4 -19
- package/.medusa/server/src/modules/order-rma-gate/migrations/{Migration20260724100000.js → Migration20260724100001.js} +4 -4
- package/.medusa/server/src/modules/order-rma-gate/migrations/Migration20261027120000.js +36 -0
- package/package.json +1 -1
|
@@ -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 { Text, Container, Heading, Badge, Button, Label, Select, Textarea, Input, Popover, clx, Copy, Skeleton, Tooltip, toast } from "@medusajs/ui";
|
|
5
|
-
import { CashSolid, PencilSquareSolid, Trash, CreditCard, Receipt, ArrowPath, ChevronDownMini, Check, InformationCircle, ExclamationCircle, MagnifierAlert, ChevronRightMini, ArrowLeft, ClockSolid, ShieldCheck, SquareTwoStack
|
|
5
|
+
import { CashSolid, PencilSquareSolid, Trash, CreditCard, Receipt, ArrowPath, ChevronDownMini, Check, InformationCircle, ExclamationCircle, MagnifierAlert, ChevronRightMini, CheckCircle, ArrowLeft, ClockSolid, ShieldCheck, SquareTwoStack } from "@medusajs/icons";
|
|
6
6
|
import { useNavigate, useLocation, useSearchParams, useParams } from "react-router-dom";
|
|
7
7
|
function roundRectPath(ctx, x, y, w, h, r) {
|
|
8
8
|
ctx.beginPath();
|
|
@@ -3486,1030 +3486,1030 @@ const config$3 = defineRouteConfig({
|
|
|
3486
3486
|
label: "Refund details",
|
|
3487
3487
|
icon: Receipt
|
|
3488
3488
|
});
|
|
3489
|
-
const
|
|
3490
|
-
const
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
auth_mfa_factor: /* @__PURE__ */ new Set(["value", "config"])
|
|
3489
|
+
const getStatusBadgeClass$1 = (status) => {
|
|
3490
|
+
const statusLower = status.toLowerCase();
|
|
3491
|
+
if (statusLower === "requested") {
|
|
3492
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
3493
|
+
}
|
|
3494
|
+
if (statusLower === "approved") {
|
|
3495
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
3496
|
+
}
|
|
3497
|
+
if (statusLower === "rejected") {
|
|
3498
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
3499
|
+
}
|
|
3500
|
+
if (statusLower === "received") {
|
|
3501
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
3502
|
+
}
|
|
3503
|
+
if (statusLower === "refunded") {
|
|
3504
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
3505
|
+
}
|
|
3506
|
+
if (statusLower === "completed") {
|
|
3507
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
3508
|
+
}
|
|
3509
|
+
if (statusLower === "cancelled") {
|
|
3510
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
3511
|
+
}
|
|
3512
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
3514
3513
|
};
|
|
3515
|
-
const
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
]);
|
|
3522
|
-
|
|
3523
|
-
const
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3514
|
+
const ReturnDetailPage = () => {
|
|
3515
|
+
const navigate = useNavigate();
|
|
3516
|
+
const { id } = useParams();
|
|
3517
|
+
const [returnOrder, setReturnOrder] = useState(null);
|
|
3518
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
3519
|
+
const [isRejecting, setIsRejecting] = useState(false);
|
|
3520
|
+
const [error, setError] = useState(null);
|
|
3521
|
+
const [updateError, setUpdateError] = useState(null);
|
|
3522
|
+
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
3523
|
+
useEffect(() => {
|
|
3524
|
+
if (!id) {
|
|
3525
|
+
navigate("/returns");
|
|
3526
|
+
return;
|
|
3527
|
+
}
|
|
3528
|
+
const loadReturn = async () => {
|
|
3529
|
+
try {
|
|
3530
|
+
setIsLoading(true);
|
|
3531
|
+
setError(null);
|
|
3532
|
+
const response = await fetch(`/admin/return/${id}`, {
|
|
3533
|
+
credentials: "include"
|
|
3534
|
+
});
|
|
3535
|
+
if (!response.ok) {
|
|
3536
|
+
const message = await response.text();
|
|
3537
|
+
throw new Error(message || "Unable to load return order");
|
|
3538
|
+
}
|
|
3539
|
+
const payload = await response.json();
|
|
3540
|
+
setReturnOrder(payload.return);
|
|
3541
|
+
} catch (loadError) {
|
|
3542
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
|
|
3543
|
+
setError(message);
|
|
3544
|
+
} finally {
|
|
3545
|
+
setIsLoading(false);
|
|
3541
3546
|
}
|
|
3547
|
+
};
|
|
3548
|
+
void loadReturn();
|
|
3549
|
+
}, [id, navigate]);
|
|
3550
|
+
const handleReject = async () => {
|
|
3551
|
+
if (!id) {
|
|
3552
|
+
return;
|
|
3553
|
+
}
|
|
3554
|
+
try {
|
|
3555
|
+
setIsRejecting(true);
|
|
3556
|
+
setUpdateError(null);
|
|
3557
|
+
setUpdateSuccess(false);
|
|
3558
|
+
const response = await fetch(`/admin/return/${id}/reject`, {
|
|
3559
|
+
method: "POST",
|
|
3560
|
+
headers: {
|
|
3561
|
+
"Content-Type": "application/json"
|
|
3562
|
+
},
|
|
3563
|
+
credentials: "include",
|
|
3564
|
+
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
3565
|
+
});
|
|
3566
|
+
if (!response.ok) {
|
|
3567
|
+
const message = await response.text();
|
|
3568
|
+
throw new Error(message || "Unable to reject return");
|
|
3569
|
+
}
|
|
3570
|
+
const payload = await response.json();
|
|
3571
|
+
setReturnOrder(payload.return);
|
|
3572
|
+
setUpdateSuccess(true);
|
|
3573
|
+
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
3574
|
+
const detailResponse = await fetch(`/admin/return/${id}`, {
|
|
3575
|
+
credentials: "include"
|
|
3576
|
+
});
|
|
3577
|
+
if (detailResponse.ok) {
|
|
3578
|
+
const detailPayload = await detailResponse.json();
|
|
3579
|
+
setReturnOrder(detailPayload.return);
|
|
3580
|
+
}
|
|
3581
|
+
} catch (updateErr) {
|
|
3582
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to reject return";
|
|
3583
|
+
setUpdateError(message);
|
|
3584
|
+
} finally {
|
|
3585
|
+
setIsRejecting(false);
|
|
3542
3586
|
}
|
|
3543
|
-
return out;
|
|
3544
|
-
}
|
|
3545
|
-
return value;
|
|
3546
|
-
}
|
|
3547
|
-
function maskSensitiveData(data, tableName) {
|
|
3548
|
-
const ctx = {
|
|
3549
|
-
count: 0,
|
|
3550
|
-
maskAll: tableName ? FULLY_SECRET_TABLES.has(tableName) : false,
|
|
3551
|
-
tableKeys: tableName ? TABLE_SENSITIVE_KEYS[tableName] : void 0
|
|
3552
|
-
};
|
|
3553
|
-
const value = maskValue(data, ctx, 0);
|
|
3554
|
-
return { value, maskedCount: ctx.count };
|
|
3555
|
-
}
|
|
3556
|
-
const AUTO_EXPAND_DEPTH = 1;
|
|
3557
|
-
const LONG_STRING = 200;
|
|
3558
|
-
const JsonViewer = ({ data }) => {
|
|
3559
|
-
const [generation, setGeneration] = useState(0);
|
|
3560
|
-
const [expandAll, setExpandAll] = useState(null);
|
|
3561
|
-
const setAll = (value) => {
|
|
3562
|
-
setExpandAll(value);
|
|
3563
|
-
setGeneration((g) => g + 1);
|
|
3564
3587
|
};
|
|
3565
|
-
|
|
3566
|
-
/* @__PURE__ */
|
|
3567
|
-
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => setAll(true), children: "Expand all" }),
|
|
3568
|
-
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => setAll(false), children: "Collapse all" })
|
|
3569
|
-
] }),
|
|
3570
|
-
/* @__PURE__ */ jsx("div", { className: "max-h-[560px] overflow-auto rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3 font-mono text-xs leading-5", children: /* @__PURE__ */ jsx(JsonNode, { value: data, depth: 0, forceExpand: expandAll }, generation) })
|
|
3571
|
-
] });
|
|
3572
|
-
};
|
|
3573
|
-
const JsonNode = ({ name, value, depth, forceExpand }) => {
|
|
3574
|
-
const isContainer = value !== null && typeof value === "object";
|
|
3575
|
-
const [open, setOpen] = useState(forceExpand ?? depth < AUTO_EXPAND_DEPTH);
|
|
3576
|
-
const label = name !== void 0 ? /* @__PURE__ */ jsxs("span", { className: "text-ui-fg-subtle", children: [
|
|
3577
|
-
name,
|
|
3578
|
-
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: ": " })
|
|
3579
|
-
] }) : null;
|
|
3580
|
-
if (!isContainer) {
|
|
3581
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-start", style: { paddingLeft: depth ? 16 : 0 }, children: [
|
|
3582
|
-
/* @__PURE__ */ jsx("span", { className: "w-4 shrink-0" }),
|
|
3583
|
-
/* @__PURE__ */ jsxs("span", { className: "min-w-0 break-words [overflow-wrap:anywhere]", children: [
|
|
3584
|
-
label,
|
|
3585
|
-
/* @__PURE__ */ jsx(Primitive, { value })
|
|
3586
|
-
] })
|
|
3587
|
-
] });
|
|
3588
|
+
if (isLoading) {
|
|
3589
|
+
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..." }) }) }) });
|
|
3588
3590
|
}
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
"button",
|
|
3595
|
-
{
|
|
3596
|
-
type: "button",
|
|
3597
|
-
onClick: () => setOpen((o) => !o),
|
|
3598
|
-
className: "flex items-start text-left hover:bg-ui-bg-base-hover",
|
|
3599
|
-
"aria-expanded": open,
|
|
3600
|
-
children: [
|
|
3601
|
-
/* @__PURE__ */ jsx("span", { className: "flex w-4 shrink-0 items-center pt-0.5 text-ui-fg-muted", children: entries.length ? open ? /* @__PURE__ */ jsx(ChevronDownMini, {}) : /* @__PURE__ */ jsx(ChevronRightMini, {}) : null }),
|
|
3602
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
3603
|
-
label,
|
|
3604
|
-
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: openBracket }),
|
|
3605
|
-
!open || entries.length === 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3606
|
-
entries.length ? /* @__PURE__ */ jsx("span", { className: "px-1 italic text-ui-fg-muted", children: summary }) : null,
|
|
3607
|
-
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: closeBracket })
|
|
3608
|
-
] }) : null
|
|
3609
|
-
] })
|
|
3610
|
-
]
|
|
3611
|
-
}
|
|
3612
|
-
),
|
|
3613
|
-
open && entries.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3614
|
-
entries.map(([key, child]) => /* @__PURE__ */ jsx(JsonNode, { name: key, value: child, depth: depth + 1, forceExpand }, key)),
|
|
3615
|
-
/* @__PURE__ */ jsx("div", { style: { paddingLeft: 16 }, className: "text-ui-fg-muted", children: closeBracket })
|
|
3616
|
-
] }) : null
|
|
3617
|
-
] });
|
|
3618
|
-
};
|
|
3619
|
-
const Primitive = ({ value }) => {
|
|
3620
|
-
const [showFull, setShowFull] = useState(false);
|
|
3621
|
-
if (value === MASKED_VALUE) {
|
|
3622
|
-
return /* @__PURE__ */ jsx("span", { className: "rounded bg-ui-tag-orange-bg px-1 text-ui-tag-orange-text", title: "Hidden for security", children: MASKED_VALUE });
|
|
3591
|
+
if (error || !returnOrder) {
|
|
3592
|
+
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: [
|
|
3593
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
|
|
3594
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
|
|
3595
|
+
] }) }) });
|
|
3623
3596
|
}
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
}
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
}
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
}
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
}
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
{
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
CREATED
|
|
3819
|
-
],
|
|
3820
|
-
product_collection: [{ key: "title", label: "Title" }, { key: "handle", label: "Handle" }, CREATED],
|
|
3821
|
-
payment: [
|
|
3822
|
-
{ key: "amount", label: "Amount", kind: "money" },
|
|
3823
|
-
{ key: "currency_code", label: "Currency" },
|
|
3824
|
-
{ key: "provider_id", label: "Provider" },
|
|
3825
|
-
{ key: "captured_at", label: "Captured", kind: "date" },
|
|
3826
|
-
{ key: "canceled_at", label: "Canceled", kind: "date" },
|
|
3827
|
-
{ key: "payment_collection_id", label: "Payment collection ID", kind: "id" },
|
|
3828
|
-
CREATED
|
|
3829
|
-
],
|
|
3830
|
-
payment_session: [
|
|
3831
|
-
{ key: "amount", label: "Amount", kind: "money" },
|
|
3832
|
-
{ key: "currency_code", label: "Currency" },
|
|
3833
|
-
{ key: "provider_id", label: "Provider" },
|
|
3834
|
-
{ key: "status", label: "Status", kind: "status" },
|
|
3835
|
-
{ key: "payment_collection_id", label: "Payment collection ID", kind: "id" },
|
|
3836
|
-
CREATED
|
|
3837
|
-
],
|
|
3838
|
-
payment_collection: [
|
|
3839
|
-
{ key: "amount", label: "Amount", kind: "money" },
|
|
3840
|
-
{ key: "currency_code", label: "Currency" },
|
|
3841
|
-
{ key: "status", label: "Status", kind: "status" },
|
|
3842
|
-
CREATED
|
|
3843
|
-
],
|
|
3844
|
-
refund: [
|
|
3845
|
-
{ key: "amount", label: "Amount", kind: "money" },
|
|
3846
|
-
{ key: "payment_id", label: "Payment ID", kind: "id" },
|
|
3847
|
-
{ key: "refund_reason_id", label: "Refund reason ID", kind: "id" },
|
|
3848
|
-
{ key: "note", label: "Note" },
|
|
3849
|
-
{ key: "created_by", label: "Created by" },
|
|
3850
|
-
CREATED
|
|
3851
|
-
],
|
|
3852
|
-
return: [
|
|
3853
|
-
{ key: "display_id", label: "Return number" },
|
|
3854
|
-
{ key: "status", label: "Status", kind: "status" },
|
|
3855
|
-
{ key: "order_id", label: "Order ID", kind: "id" },
|
|
3856
|
-
{ key: "refund_amount", label: "Refund amount", kind: "money" },
|
|
3857
|
-
{ key: "received_at", label: "Received", kind: "date" },
|
|
3858
|
-
CREATED
|
|
3859
|
-
],
|
|
3860
|
-
payment_detail: [
|
|
3861
|
-
{ key: "type", label: "Method type" },
|
|
3862
|
-
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
3863
|
-
{ key: "is_default", label: "Default method", kind: "boolean" },
|
|
3864
|
-
CREATED
|
|
3865
|
-
],
|
|
3866
|
-
user: [NAME, { key: "email", label: "Email" }, CREATED],
|
|
3867
|
-
invite: [
|
|
3868
|
-
{ key: "email", label: "Email" },
|
|
3869
|
-
{ key: "accepted", label: "Accepted", kind: "boolean" },
|
|
3870
|
-
{ key: "expires_at", label: "Expires", kind: "date" },
|
|
3871
|
-
CREATED
|
|
3872
|
-
],
|
|
3873
|
-
api_key: [
|
|
3874
|
-
{ key: "title", label: "Title" },
|
|
3875
|
-
{ key: "type", label: "Type" },
|
|
3876
|
-
{ key: "redacted", label: "Key (redacted)" },
|
|
3877
|
-
{ key: "revoked_at", label: "Revoked", kind: "date" },
|
|
3878
|
-
CREATED
|
|
3879
|
-
],
|
|
3880
|
-
promotion: [
|
|
3881
|
-
{ key: "code", label: "Promotion code" },
|
|
3882
|
-
{ key: "type", label: "Type" },
|
|
3883
|
-
{ key: "status", label: "Status", kind: "status" },
|
|
3884
|
-
{ key: "is_automatic", label: "Automatic", kind: "boolean" },
|
|
3885
|
-
CREATED
|
|
3886
|
-
],
|
|
3887
|
-
fulfillment: [
|
|
3888
|
-
{ key: "provider_id", label: "Provider" },
|
|
3889
|
-
{ key: "location_id", label: "Location ID", kind: "id" },
|
|
3890
|
-
{ key: "shipped_at", label: "Shipped", kind: "date" },
|
|
3891
|
-
{ key: "delivered_at", label: "Delivered", kind: "date" },
|
|
3892
|
-
{ key: "canceled_at", label: "Canceled", kind: "date" },
|
|
3893
|
-
CREATED
|
|
3894
|
-
],
|
|
3895
|
-
inventory_item: [
|
|
3896
|
-
{ key: "sku", label: "SKU" },
|
|
3897
|
-
{ key: "title", label: "Title" },
|
|
3898
|
-
{ key: "requires_shipping", label: "Requires shipping", kind: "boolean" },
|
|
3899
|
-
CREATED
|
|
3900
|
-
],
|
|
3901
|
-
inventory_level: [
|
|
3902
|
-
{ key: "inventory_item_id", label: "Inventory item ID", kind: "id" },
|
|
3903
|
-
{ key: "location_id", label: "Location ID", kind: "id" },
|
|
3904
|
-
{ key: "stocked_quantity", label: "Stocked", kind: "number" },
|
|
3905
|
-
{ key: "reserved_quantity", label: "Reserved", kind: "number" },
|
|
3906
|
-
CREATED
|
|
3907
|
-
],
|
|
3908
|
-
review: [
|
|
3909
|
-
{ key: "title", label: "Title" },
|
|
3910
|
-
{ key: "rating", label: "Rating", kind: "number" },
|
|
3911
|
-
{ key: "status", label: "Status", kind: "status" },
|
|
3912
|
-
{ key: "product_id", label: "Product ID", kind: "id" },
|
|
3913
|
-
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
3914
|
-
CREATED
|
|
3915
|
-
]
|
|
3916
|
-
};
|
|
3917
|
-
const GENERIC_FIELDS = [
|
|
3918
|
-
{ key: "display_id", label: "Number" },
|
|
3919
|
-
{ key: "title", label: "Title" },
|
|
3920
|
-
{ key: "name", label: "Name" },
|
|
3921
|
-
NAME,
|
|
3922
|
-
{ key: "email", label: "Email" },
|
|
3923
|
-
{ key: "phone", label: "Phone" },
|
|
3924
|
-
{ key: "handle", label: "Handle" },
|
|
3925
|
-
{ key: "sku", label: "SKU" },
|
|
3926
|
-
{ key: "code", label: "Code" },
|
|
3927
|
-
{ key: "status", label: "Status", kind: "status" },
|
|
3928
|
-
{ key: "type", label: "Type" },
|
|
3929
|
-
{ key: "amount", label: "Amount", kind: "money" },
|
|
3930
|
-
{ key: "quantity", label: "Quantity", kind: "number" },
|
|
3931
|
-
{ key: "currency_code", label: "Currency" },
|
|
3932
|
-
{ key: "order_id", label: "Order ID", kind: "id" },
|
|
3933
|
-
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
3934
|
-
{ key: "product_id", label: "Product ID", kind: "id" },
|
|
3935
|
-
{ key: "payment_id", label: "Payment ID", kind: "id" },
|
|
3936
|
-
{ key: "provider_id", label: "Provider" },
|
|
3937
|
-
CREATED,
|
|
3938
|
-
{ key: "updated_at", label: "Last updated", kind: "date" }
|
|
3597
|
+
const statusHistory = returnOrder.metadata?.status_history || [];
|
|
3598
|
+
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: [
|
|
3599
|
+
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
3600
|
+
/* @__PURE__ */ jsxs(
|
|
3601
|
+
Button,
|
|
3602
|
+
{
|
|
3603
|
+
variant: "transparent",
|
|
3604
|
+
size: "small",
|
|
3605
|
+
onClick: () => navigate("/returns"),
|
|
3606
|
+
className: "w-fit",
|
|
3607
|
+
children: [
|
|
3608
|
+
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
3609
|
+
"Back to list"
|
|
3610
|
+
]
|
|
3611
|
+
}
|
|
3612
|
+
),
|
|
3613
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
3614
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
3615
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Return Order Details" }),
|
|
3616
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
|
|
3617
|
+
] }),
|
|
3618
|
+
/* @__PURE__ */ jsx(
|
|
3619
|
+
Badge,
|
|
3620
|
+
{
|
|
3621
|
+
size: "small",
|
|
3622
|
+
className: `uppercase ${getStatusBadgeClass$1(returnOrder.status)}`,
|
|
3623
|
+
children: returnOrder.status.replace(/_/g, " ")
|
|
3624
|
+
}
|
|
3625
|
+
)
|
|
3626
|
+
] })
|
|
3627
|
+
] }),
|
|
3628
|
+
returnOrder.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
3629
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
3630
|
+
Button,
|
|
3631
|
+
{
|
|
3632
|
+
variant: "danger",
|
|
3633
|
+
onClick: handleReject,
|
|
3634
|
+
disabled: isRejecting,
|
|
3635
|
+
isLoading: isRejecting,
|
|
3636
|
+
children: "Reject (Cancel) Return"
|
|
3637
|
+
}
|
|
3638
|
+
) }),
|
|
3639
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: 'Cancel this return request. Use "Mark as received" when items are received.' })
|
|
3640
|
+
] }),
|
|
3641
|
+
returnOrder.refund ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: /* @__PURE__ */ jsx(RefundCalculationBlock, { refund: returnOrder.refund }) }) : null,
|
|
3642
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
3643
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
3644
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
3645
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3646
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
3647
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
3648
|
+
] }),
|
|
3649
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
3650
|
+
Button,
|
|
3651
|
+
{
|
|
3652
|
+
variant: "secondary",
|
|
3653
|
+
onClick: () => {
|
|
3654
|
+
window.open(
|
|
3655
|
+
`/app/orders/${returnOrder.order_id}`,
|
|
3656
|
+
"_blank"
|
|
3657
|
+
);
|
|
3658
|
+
},
|
|
3659
|
+
children: "View order"
|
|
3660
|
+
}
|
|
3661
|
+
) })
|
|
3662
|
+
] })
|
|
3663
|
+
] }),
|
|
3664
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
3665
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
3666
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
|
|
3667
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
3668
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3669
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
3670
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
3671
|
+
] }),
|
|
3672
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3673
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
3674
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
|
|
3675
|
+
] }),
|
|
3676
|
+
returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
3677
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
3678
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
|
|
3679
|
+
] }),
|
|
3680
|
+
returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
3681
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
3682
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
|
|
3683
|
+
] }),
|
|
3684
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3685
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
3686
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
|
|
3687
|
+
] }),
|
|
3688
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3689
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
3690
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
|
|
3691
|
+
] })
|
|
3692
|
+
] })
|
|
3693
|
+
] }),
|
|
3694
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
3695
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Status History" }),
|
|
3696
|
+
statusHistory.length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-2", children: statusHistory.map((entry, index) => /* @__PURE__ */ jsx(
|
|
3697
|
+
"div",
|
|
3698
|
+
{
|
|
3699
|
+
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
3700
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
3701
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(
|
|
3702
|
+
Badge,
|
|
3703
|
+
{
|
|
3704
|
+
size: "2xsmall",
|
|
3705
|
+
className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
|
|
3706
|
+
children: entry.status.replace(/_/g, " ")
|
|
3707
|
+
}
|
|
3708
|
+
) }),
|
|
3709
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
3710
|
+
new Date(entry.timestamp).toLocaleString(),
|
|
3711
|
+
entry.admin_id && ` by ${entry.admin_id}`,
|
|
3712
|
+
entry.reason && ` - ${entry.reason}`
|
|
3713
|
+
] })
|
|
3714
|
+
] })
|
|
3715
|
+
},
|
|
3716
|
+
index
|
|
3717
|
+
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
3718
|
+
] })
|
|
3719
|
+
] }),
|
|
3720
|
+
returnOrder.order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
3721
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
3722
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
3723
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3724
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
3725
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.id })
|
|
3726
|
+
] }),
|
|
3727
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3728
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
3729
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.status || "—" })
|
|
3730
|
+
] }),
|
|
3731
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3732
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
3733
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.customer?.email || returnOrder.order.email || "—" })
|
|
3734
|
+
] }),
|
|
3735
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3736
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Payment method" }),
|
|
3737
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.order_payment?.label || "—" })
|
|
3738
|
+
] }),
|
|
3739
|
+
returnOrder.order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
3740
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
3741
|
+
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
3742
|
+
returnOrder.order.currency_code || "$",
|
|
3743
|
+
(Number(returnOrder.order.total) / 100).toFixed(2)
|
|
3744
|
+
] })
|
|
3745
|
+
] })
|
|
3746
|
+
] })
|
|
3747
|
+
] }),
|
|
3748
|
+
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: [
|
|
3749
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
3750
|
+
/* @__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: [
|
|
3751
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
3752
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
|
|
3753
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
3754
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
3755
|
+
] }) }),
|
|
3756
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
3757
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
3758
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
3759
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
3760
|
+
] }, item.id || index)) })
|
|
3761
|
+
] }) })
|
|
3762
|
+
] }),
|
|
3763
|
+
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 }) }),
|
|
3764
|
+
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" }) })
|
|
3765
|
+
] }) });
|
|
3766
|
+
};
|
|
3767
|
+
const config$2 = defineRouteConfig({
|
|
3768
|
+
label: "Return Order Details",
|
|
3769
|
+
icon: CheckCircle
|
|
3770
|
+
});
|
|
3771
|
+
const MASKED_VALUE = "••••••••••••";
|
|
3772
|
+
const SENSITIVE_KEY_PATTERNS = [
|
|
3773
|
+
/password|passwd|passphrase/i,
|
|
3774
|
+
/secret/i,
|
|
3775
|
+
/token/i,
|
|
3776
|
+
/api_?key$/i,
|
|
3777
|
+
/private_?key/i,
|
|
3778
|
+
/access_?key/i,
|
|
3779
|
+
/(^|_)hash(ed)?($|_)/i,
|
|
3780
|
+
/(^|_)salt$/i,
|
|
3781
|
+
/^cvv$|^cvc$|security_code/i,
|
|
3782
|
+
/card_?number/i,
|
|
3783
|
+
/account_?number/i,
|
|
3784
|
+
/credential/i,
|
|
3785
|
+
/authorization/i,
|
|
3786
|
+
/recovery_?code/i,
|
|
3787
|
+
/(^|_)otp($|_)/i,
|
|
3788
|
+
/verification_?code/i,
|
|
3789
|
+
/^code_hash$/i,
|
|
3790
|
+
/webhook_?signature/i
|
|
3939
3791
|
];
|
|
3940
|
-
const
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3792
|
+
const TABLE_SENSITIVE_KEYS = {
|
|
3793
|
+
otp_verification: /* @__PURE__ */ new Set(["code", "value"]),
|
|
3794
|
+
auth_verification: /* @__PURE__ */ new Set(["code", "value"]),
|
|
3795
|
+
auth_mfa_factor: /* @__PURE__ */ new Set(["value", "config"])
|
|
3796
|
+
};
|
|
3797
|
+
const SAFE_KEYS = /* @__PURE__ */ new Set([
|
|
3798
|
+
"token_type",
|
|
3799
|
+
"redacted",
|
|
3800
|
+
"api_key_id",
|
|
3801
|
+
"token_id",
|
|
3802
|
+
"notification_token_id"
|
|
3803
|
+
]);
|
|
3804
|
+
function isSensitiveKey(key) {
|
|
3805
|
+
const normalized = key.trim().toLowerCase();
|
|
3806
|
+
if (SAFE_KEYS.has(normalized)) return false;
|
|
3807
|
+
return SENSITIVE_KEY_PATTERNS.some((pattern) => pattern.test(normalized));
|
|
3948
3808
|
}
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
const
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
const n = amountOf(raw);
|
|
3965
|
-
return n === null ? null : { value: formatNumber(n), kind };
|
|
3809
|
+
const FULLY_SECRET_TABLES = /* @__PURE__ */ new Set(["auth_mfa_recovery_code", "auth_password_reset_token"]);
|
|
3810
|
+
const ALWAYS_VISIBLE_KEYS = /* @__PURE__ */ new Set(["id", "created_at", "updated_at", "deleted_at", "expires_at", "used_at"]);
|
|
3811
|
+
function maskValue(value, ctx, depth) {
|
|
3812
|
+
if (Array.isArray(value)) return value.map((item) => maskValue(item, ctx, depth + 1));
|
|
3813
|
+
if (value !== null && typeof value === "object") {
|
|
3814
|
+
const out = {};
|
|
3815
|
+
for (const [key, inner] of Object.entries(value)) {
|
|
3816
|
+
const topLevel = depth === 0;
|
|
3817
|
+
const secret = inner !== null && inner !== void 0 && inner !== "" && (isSensitiveKey(key) || topLevel && ctx.tableKeys?.has(key.toLowerCase()) === true || topLevel && ctx.maskAll && !ALWAYS_VISIBLE_KEYS.has(key) && !key.endsWith("_id"));
|
|
3818
|
+
if (secret) {
|
|
3819
|
+
ctx.count += 1;
|
|
3820
|
+
out[key] = MASKED_VALUE;
|
|
3821
|
+
} else {
|
|
3822
|
+
out[key] = maskValue(inner, ctx, depth + 1);
|
|
3823
|
+
}
|
|
3966
3824
|
}
|
|
3967
|
-
|
|
3968
|
-
return { value: String(raw).replace(/_/g, " "), kind };
|
|
3969
|
-
default:
|
|
3970
|
-
if (typeof raw === "object") return null;
|
|
3971
|
-
if (typeof raw === "string" && raw.length > 160) return { value: `${raw.slice(0, 157)}…`, kind };
|
|
3972
|
-
return { value: String(raw), kind };
|
|
3973
|
-
}
|
|
3974
|
-
}
|
|
3975
|
-
function summarizeOldData(tableName, oldData) {
|
|
3976
|
-
if (!oldData) return [];
|
|
3977
|
-
const { value: row } = maskSensitiveData(oldData, tableName);
|
|
3978
|
-
const specific = ENTITY_FIELDS[tableName];
|
|
3979
|
-
const specs = specific ?? GENERIC_FIELDS;
|
|
3980
|
-
const fields = [];
|
|
3981
|
-
const seenLabels = /* @__PURE__ */ new Set();
|
|
3982
|
-
for (const spec of specs) {
|
|
3983
|
-
const raw = spec.derive ? spec.derive(row) : row[spec.key];
|
|
3984
|
-
const formatted = formatValue(raw, spec.kind ?? "text", row);
|
|
3985
|
-
if (!formatted || seenLabels.has(spec.label)) continue;
|
|
3986
|
-
seenLabels.add(spec.label);
|
|
3987
|
-
const value = spec.key === "currency_code" ? formatted.value.toUpperCase() : formatted.value;
|
|
3988
|
-
fields.push({ key: spec.key, label: spec.label, value, kind: formatted.kind });
|
|
3989
|
-
if (!specific && fields.length >= MAX_GENERIC_FIELDS) break;
|
|
3990
|
-
}
|
|
3991
|
-
return fields;
|
|
3992
|
-
}
|
|
3993
|
-
function readLastListSearch() {
|
|
3994
|
-
try {
|
|
3995
|
-
return window.sessionStorage.getItem(LAST_LIST_URL_KEY) ?? "";
|
|
3996
|
-
} catch {
|
|
3997
|
-
return "";
|
|
3825
|
+
return out;
|
|
3998
3826
|
}
|
|
3827
|
+
return value;
|
|
3999
3828
|
}
|
|
4000
|
-
|
|
4001
|
-
const
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
const [reloadToken, setReloadToken] = useState(0);
|
|
4006
|
-
const cameFromList = location.state?.fromList === true;
|
|
4007
|
-
const goBack = () => {
|
|
4008
|
-
if (cameFromList) navigate(-1);
|
|
4009
|
-
else navigate(`/deleted-records-audit${readLastListSearch()}`);
|
|
3829
|
+
function maskSensitiveData(data, tableName) {
|
|
3830
|
+
const ctx = {
|
|
3831
|
+
count: 0,
|
|
3832
|
+
maskAll: tableName ? FULLY_SECRET_TABLES.has(tableName) : false,
|
|
3833
|
+
tableKeys: tableName ? TABLE_SENSITIVE_KEYS[tableName] : void 0
|
|
4010
3834
|
};
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
return () => controller.abort();
|
|
4023
|
-
}, [id, reloadToken]);
|
|
4024
|
-
return /* @__PURE__ */ jsx("div", { className: "w-full p-3 md:p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-4 md:p-6", children: [
|
|
4025
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Button, { variant: "transparent", size: "small", onClick: goBack, className: "-ml-2", children: [
|
|
4026
|
-
/* @__PURE__ */ jsx(ArrowLeft, {}),
|
|
4027
|
-
"Back to Deleted Records"
|
|
4028
|
-
] }) }),
|
|
4029
|
-
state.status === "loading" ? /* @__PURE__ */ jsx(DetailSkeleton, {}) : state.status === "error" ? /* @__PURE__ */ jsx(
|
|
4030
|
-
DetailError,
|
|
4031
|
-
{
|
|
4032
|
-
notFound: state.notFound,
|
|
4033
|
-
message: state.message,
|
|
4034
|
-
onRetry: () => setReloadToken((t) => t + 1),
|
|
4035
|
-
onBack: goBack
|
|
4036
|
-
}
|
|
4037
|
-
) : /* @__PURE__ */ jsx(DetailContent, { audit: state.audit })
|
|
4038
|
-
] }) });
|
|
4039
|
-
};
|
|
4040
|
-
const DetailContent = ({ audit }) => {
|
|
4041
|
-
const navigate = useNavigate();
|
|
4042
|
-
const entity = getEntityInfo(audit.table_name);
|
|
4043
|
-
const source = describeSource(audit.source);
|
|
4044
|
-
const summary = useMemo(() => summarizeOldData(audit.table_name, audit.old_data), [audit]);
|
|
4045
|
-
const masked = useMemo(() => maskSensitiveData(audit.old_data, audit.table_name), [audit]);
|
|
4046
|
-
const guidance = getNextSteps(entity.category.id);
|
|
4047
|
-
const related = getRelatedLinks(audit.table_name, audit.old_data);
|
|
4048
|
-
const [showRaw, setShowRaw] = useState(false);
|
|
4049
|
-
const copyJson = async () => {
|
|
4050
|
-
try {
|
|
4051
|
-
await navigator.clipboard.writeText(JSON.stringify(masked.value, null, 2));
|
|
4052
|
-
toast.success("Record data copied", {
|
|
4053
|
-
description: masked.maskedCount ? "Sensitive values were left hidden." : void 0
|
|
4054
|
-
});
|
|
4055
|
-
} catch {
|
|
4056
|
-
toast.error("Couldn’t copy to clipboard");
|
|
4057
|
-
}
|
|
3835
|
+
const value = maskValue(data, ctx, 0);
|
|
3836
|
+
return { value, maskedCount: ctx.count };
|
|
3837
|
+
}
|
|
3838
|
+
const AUTO_EXPAND_DEPTH = 1;
|
|
3839
|
+
const LONG_STRING = 200;
|
|
3840
|
+
const JsonViewer = ({ data }) => {
|
|
3841
|
+
const [generation, setGeneration] = useState(0);
|
|
3842
|
+
const [expandAll, setExpandAll] = useState(null);
|
|
3843
|
+
const setAll = (value) => {
|
|
3844
|
+
setExpandAll(value);
|
|
3845
|
+
setGeneration((g) => g + 1);
|
|
4058
3846
|
};
|
|
4059
|
-
return /* @__PURE__ */ jsxs(
|
|
4060
|
-
/* @__PURE__ */ jsxs("
|
|
4061
|
-
/* @__PURE__ */
|
|
4062
|
-
|
|
4063
|
-
/* @__PURE__ */ jsx(Trash, {}),
|
|
4064
|
-
"Deleted"
|
|
4065
|
-
] }),
|
|
4066
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: entity.category.label })
|
|
4067
|
-
] }),
|
|
4068
|
-
/* @__PURE__ */ jsxs(Heading, { level: "h1", children: [
|
|
4069
|
-
"Deleted ",
|
|
4070
|
-
entity.label
|
|
4071
|
-
] }),
|
|
4072
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
4073
|
-
/* @__PURE__ */ jsx(CopyableId, { value: audit.record_id, emptyLabel: "This record type has no ID column", className: "text-sm" }),
|
|
4074
|
-
/* @__PURE__ */ jsxs(Text, { size: "xsmall", className: "text-ui-fg-muted", children: [
|
|
4075
|
-
"Database table: ",
|
|
4076
|
-
/* @__PURE__ */ jsx("span", { className: "font-mono", children: audit.table_name })
|
|
4077
|
-
] })
|
|
4078
|
-
] })
|
|
3847
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3848
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
3849
|
+
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => setAll(true), children: "Expand all" }),
|
|
3850
|
+
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => setAll(false), children: "Collapse all" })
|
|
4079
3851
|
] }),
|
|
4080
|
-
/* @__PURE__ */
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
3852
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-[560px] overflow-auto rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3 font-mono text-xs leading-5", children: /* @__PURE__ */ jsx(JsonNode, { value: data, depth: 0, forceExpand: expandAll }, generation) })
|
|
3853
|
+
] });
|
|
3854
|
+
};
|
|
3855
|
+
const JsonNode = ({ name, value, depth, forceExpand }) => {
|
|
3856
|
+
const isContainer = value !== null && typeof value === "object";
|
|
3857
|
+
const [open, setOpen] = useState(forceExpand ?? depth < AUTO_EXPAND_DEPTH);
|
|
3858
|
+
const label = name !== void 0 ? /* @__PURE__ */ jsxs("span", { className: "text-ui-fg-subtle", children: [
|
|
3859
|
+
name,
|
|
3860
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: ": " })
|
|
3861
|
+
] }) : null;
|
|
3862
|
+
if (!isContainer) {
|
|
3863
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-start", style: { paddingLeft: depth ? 16 : 0 }, children: [
|
|
3864
|
+
/* @__PURE__ */ jsx("span", { className: "w-4 shrink-0" }),
|
|
3865
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 break-words [overflow-wrap:anywhere]", children: [
|
|
3866
|
+
label,
|
|
3867
|
+
/* @__PURE__ */ jsx(Primitive, { value })
|
|
4085
3868
|
] })
|
|
4086
|
-
] })
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
] }) }),
|
|
4095
|
-
/* @__PURE__ */ jsx(Field, { label: "Deleted by", children: audit.deleted_by ? /* @__PURE__ */ jsx("span", { className: "break-all text-sm text-ui-fg-base", children: audit.deleted_by }) : /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-muted", children: "Not recorded" }) }),
|
|
4096
|
-
/* @__PURE__ */ jsx(Field, { label: "Source", children: source.kind === "unknown" ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-muted", children: "Unknown" }) : /* @__PURE__ */ jsx(Badge, { size: "small", color: sourceBadgeColor(source.kind), children: source.label }) }),
|
|
4097
|
-
/* @__PURE__ */ jsx(Field, { label: "Action", children: /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Permanently deleted" }) })
|
|
4098
|
-
] }) }),
|
|
4099
|
-
/* @__PURE__ */ jsx(
|
|
4100
|
-
Section,
|
|
3869
|
+
] });
|
|
3870
|
+
}
|
|
3871
|
+
const entries = Array.isArray(value) ? value.map((v, i) => [String(i), v]) : Object.entries(value);
|
|
3872
|
+
const [openBracket, closeBracket] = Array.isArray(value) ? ["[", "]"] : ["{", "}"];
|
|
3873
|
+
const summary = Array.isArray(value) ? `${entries.length} items` : `${entries.length} keys`;
|
|
3874
|
+
return /* @__PURE__ */ jsxs("div", { style: { paddingLeft: depth ? 16 : 0 }, children: [
|
|
3875
|
+
/* @__PURE__ */ jsxs(
|
|
3876
|
+
"button",
|
|
4101
3877
|
{
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
3878
|
+
type: "button",
|
|
3879
|
+
onClick: () => setOpen((o) => !o),
|
|
3880
|
+
className: "flex items-start text-left hover:bg-ui-bg-base-hover",
|
|
3881
|
+
"aria-expanded": open,
|
|
3882
|
+
children: [
|
|
3883
|
+
/* @__PURE__ */ jsx("span", { className: "flex w-4 shrink-0 items-center pt-0.5 text-ui-fg-muted", children: entries.length ? open ? /* @__PURE__ */ jsx(ChevronDownMini, {}) : /* @__PURE__ */ jsx(ChevronRightMini, {}) : null }),
|
|
3884
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
3885
|
+
label,
|
|
3886
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: openBracket }),
|
|
3887
|
+
!open || entries.length === 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3888
|
+
entries.length ? /* @__PURE__ */ jsx("span", { className: "px-1 italic text-ui-fg-muted", children: summary }) : null,
|
|
3889
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: closeBracket })
|
|
3890
|
+
] }) : null
|
|
3891
|
+
] })
|
|
3892
|
+
]
|
|
4105
3893
|
}
|
|
4106
3894
|
),
|
|
4107
|
-
/* @__PURE__ */
|
|
4108
|
-
|
|
3895
|
+
open && entries.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3896
|
+
entries.map(([key, child]) => /* @__PURE__ */ jsx(JsonNode, { name: key, value: child, depth: depth + 1, forceExpand }, key)),
|
|
3897
|
+
/* @__PURE__ */ jsx("div", { style: { paddingLeft: 16 }, className: "text-ui-fg-muted", children: closeBracket })
|
|
3898
|
+
] }) : null
|
|
3899
|
+
] });
|
|
3900
|
+
};
|
|
3901
|
+
const Primitive = ({ value }) => {
|
|
3902
|
+
const [showFull, setShowFull] = useState(false);
|
|
3903
|
+
if (value === MASKED_VALUE) {
|
|
3904
|
+
return /* @__PURE__ */ jsx("span", { className: "rounded bg-ui-tag-orange-bg px-1 text-ui-tag-orange-text", title: "Hidden for security", children: MASKED_VALUE });
|
|
3905
|
+
}
|
|
3906
|
+
if (value === null || value === void 0) return /* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "null" });
|
|
3907
|
+
if (typeof value === "boolean") return /* @__PURE__ */ jsx("span", { className: "text-ui-tag-purple-text", children: String(value) });
|
|
3908
|
+
if (typeof value === "number") return /* @__PURE__ */ jsx("span", { className: "text-ui-tag-blue-text", children: value });
|
|
3909
|
+
const text = String(value);
|
|
3910
|
+
const truncated = !showFull && text.length > LONG_STRING;
|
|
3911
|
+
return /* @__PURE__ */ jsxs("span", { className: clx("text-ui-tag-green-text"), children: [
|
|
3912
|
+
'"',
|
|
3913
|
+
truncated ? `${text.slice(0, LONG_STRING)}…` : text,
|
|
3914
|
+
'"',
|
|
3915
|
+
text.length > LONG_STRING ? /* @__PURE__ */ jsx(
|
|
3916
|
+
"button",
|
|
4109
3917
|
{
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
"Copy JSON"
|
|
4115
|
-
] }) : null,
|
|
4116
|
-
children: audit.old_data ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
4117
|
-
masked.maskedCount > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4118
|
-
/* @__PURE__ */ jsx(ShieldCheck, { className: "shrink-0 text-ui-fg-muted" }),
|
|
4119
|
-
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
4120
|
-
masked.maskedCount,
|
|
4121
|
-
" sensitive ",
|
|
4122
|
-
masked.maskedCount === 1 ? "value is" : "values are",
|
|
4123
|
-
" hidden for security (passwords, tokens, card or account numbers)."
|
|
4124
|
-
] })
|
|
4125
|
-
] }) : null,
|
|
4126
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Button, { variant: "secondary", size: "small", onClick: () => setShowRaw((s2) => !s2), "aria-expanded": showRaw, children: [
|
|
4127
|
-
showRaw ? /* @__PURE__ */ jsx(ChevronDownMini, {}) : /* @__PURE__ */ jsx(ChevronRightMini, {}),
|
|
4128
|
-
showRaw ? "Hide full record" : "View full record"
|
|
4129
|
-
] }) }),
|
|
4130
|
-
showRaw ? /* @__PURE__ */ jsx(JsonViewer, { data: masked.value }) : null
|
|
4131
|
-
] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No data was captured for this deletion." })
|
|
3918
|
+
type: "button",
|
|
3919
|
+
onClick: () => setShowFull((s2) => !s2),
|
|
3920
|
+
className: "ml-1 font-sans text-ui-fg-interactive hover:underline",
|
|
3921
|
+
children: showFull ? "show less" : `show all (${text.length} chars)`
|
|
4132
3922
|
}
|
|
4133
|
-
)
|
|
4134
|
-
/* @__PURE__ */ jsx(Section, { title: "What you can do now", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
4135
|
-
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-base", children: [
|
|
4136
|
-
"This record was permanently deleted. ",
|
|
4137
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium", children: "Automatic restoration is not available" }),
|
|
4138
|
-
" ",
|
|
4139
|
-
"from this screen."
|
|
4140
|
-
] }),
|
|
4141
|
-
/* @__PURE__ */ jsxs("ol", { className: "flex list-decimal flex-col gap-3 pl-5 text-sm text-ui-fg-subtle marker:text-ui-fg-muted", children: [
|
|
4142
|
-
/* @__PURE__ */ jsxs("li", { children: [
|
|
4143
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "Check whether this was expected." }),
|
|
4144
|
-
" ",
|
|
4145
|
-
audit.deleted_by || source.kind !== "unknown" ? "Confirm with the person or system shown above." : `Who deleted it wasn’t recorded—check with your team or integrations active around ${formatExactDateTime(audit.occurred_at)}.`,
|
|
4146
|
-
" ",
|
|
4147
|
-
guidance.headline
|
|
4148
|
-
] }),
|
|
4149
|
-
/* @__PURE__ */ jsxs("li", { children: [
|
|
4150
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "If it needs to come back:" }),
|
|
4151
|
-
" ",
|
|
4152
|
-
guidance.recreate
|
|
4153
|
-
] }),
|
|
4154
|
-
/* @__PURE__ */ jsxs("li", { children: [
|
|
4155
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "Need the details?" }),
|
|
4156
|
-
" Use “View full record” above to see or copy everything that was stored. Sensitive values stay hidden."
|
|
4157
|
-
] })
|
|
4158
|
-
] }),
|
|
4159
|
-
guidance.adminSection || related.length ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
4160
|
-
guidance.adminSection ? /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", onClick: () => navigate(guidance.adminSection.path), children: guidance.adminSection.label }) : null,
|
|
4161
|
-
related.map((link) => /* @__PURE__ */ jsxs(
|
|
4162
|
-
Button,
|
|
4163
|
-
{
|
|
4164
|
-
variant: "transparent",
|
|
4165
|
-
size: "small",
|
|
4166
|
-
onClick: () => navigate(link.path),
|
|
4167
|
-
title: `Opens ${link.label.toLowerCase()} ${link.id} if it still exists`,
|
|
4168
|
-
children: [
|
|
4169
|
-
"Open related ",
|
|
4170
|
-
link.label.toLowerCase(),
|
|
4171
|
-
/* @__PURE__ */ jsx(ChevronRightMini, {})
|
|
4172
|
-
]
|
|
4173
|
-
},
|
|
4174
|
-
link.path
|
|
4175
|
-
))
|
|
4176
|
-
] }) : null,
|
|
4177
|
-
related.length ? /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-muted", children: "Related records open only if they haven’t been deleted too." }) : null
|
|
4178
|
-
] }) })
|
|
3923
|
+
) : null
|
|
4179
3924
|
] });
|
|
4180
3925
|
};
|
|
4181
|
-
const
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
}
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
}
|
|
4242
|
-
|
|
4243
|
-
|
|
3926
|
+
const GUIDANCE = {
|
|
3927
|
+
orders: {
|
|
3928
|
+
headline: "Order data affects customers, payments and reports.",
|
|
3929
|
+
recreate: "Orders can’t be recreated identically from the admin. If this deletion was not intended, ask a developer to restore it from a database backup using the snapshot on this page.",
|
|
3930
|
+
adminSection: { label: "Go to Orders", path: "/orders" }
|
|
3931
|
+
},
|
|
3932
|
+
carts: {
|
|
3933
|
+
headline: "Carts are usually cleaned up automatically.",
|
|
3934
|
+
recreate: "No action is normally needed. Customers can simply add items to a new cart."
|
|
3935
|
+
},
|
|
3936
|
+
customers: {
|
|
3937
|
+
headline: "Customer data may be needed for orders, support and compliance.",
|
|
3938
|
+
recreate: "If it was deleted by mistake, recreate it from Customers using the values shown above. A recreated customer gets a new ID and must reset their password.",
|
|
3939
|
+
adminSection: { label: "Go to Customers", path: "/customers" }
|
|
3940
|
+
},
|
|
3941
|
+
catalog: {
|
|
3942
|
+
headline: "Catalog changes affect what customers can see and buy.",
|
|
3943
|
+
recreate: "If it was deleted by mistake, recreate it from Products using the values shown above. It will get a new ID.",
|
|
3944
|
+
adminSection: { label: "Go to Products", path: "/products" }
|
|
3945
|
+
},
|
|
3946
|
+
pricing: {
|
|
3947
|
+
headline: "Pricing and promotions affect what customers pay.",
|
|
3948
|
+
recreate: "If it was deleted by mistake, recreate it from Promotions or Price Lists using the values shown above.",
|
|
3949
|
+
adminSection: { label: "Go to Promotions", path: "/promotions" }
|
|
3950
|
+
},
|
|
3951
|
+
payments: {
|
|
3952
|
+
headline: "Payment records are financial data.",
|
|
3953
|
+
recreate: "Do not recreate payment records by hand—this can make balances inconsistent. If this deletion was not expected, escalate to a developer or your finance team."
|
|
3954
|
+
},
|
|
3955
|
+
fulfillment: {
|
|
3956
|
+
headline: "Shipping and fulfillment settings affect checkout and delivery.",
|
|
3957
|
+
recreate: "If it was deleted by mistake, recreate it from Settings → Locations & Shipping using the values shown above.",
|
|
3958
|
+
adminSection: { label: "Go to Settings", path: "/settings" }
|
|
3959
|
+
},
|
|
3960
|
+
inventory: {
|
|
3961
|
+
headline: "Inventory changes can affect stock levels and availability.",
|
|
3962
|
+
recreate: "If it was deleted by mistake, recreate it from Inventory using the values shown above and re-check stock quantities.",
|
|
3963
|
+
adminSection: { label: "Go to Inventory", path: "/inventory" }
|
|
3964
|
+
},
|
|
3965
|
+
wallet: {
|
|
3966
|
+
headline: "Wallet and credit records are financial data.",
|
|
3967
|
+
recreate: "Do not recreate balances by hand. If this deletion was not expected, escalate to a developer or your finance team so balances can be verified."
|
|
3968
|
+
},
|
|
3969
|
+
access: {
|
|
3970
|
+
headline: "Access records control who can sign in.",
|
|
3971
|
+
recreate: "Secrets such as passwords and keys can’t be restored. Re-invite the user or create a new API key if access is still needed.",
|
|
3972
|
+
adminSection: { label: "Go to Settings", path: "/settings" }
|
|
3973
|
+
},
|
|
3974
|
+
store: {
|
|
3975
|
+
headline: "Store settings affect regions, currencies and taxes.",
|
|
3976
|
+
recreate: "If it was deleted by mistake, recreate it from Settings using the values shown above.",
|
|
3977
|
+
adminSection: { label: "Go to Settings", path: "/settings" }
|
|
3978
|
+
},
|
|
3979
|
+
engagement: {
|
|
3980
|
+
headline: "Customer-generated content.",
|
|
3981
|
+
recreate: "These usually can’t be recreated on the customer’s behalf. Keep the snapshot on this page if you need a record of it."
|
|
3982
|
+
},
|
|
3983
|
+
notifications: {
|
|
3984
|
+
headline: "Notification records are usually cleaned up automatically.",
|
|
3985
|
+
recreate: "No action is normally needed."
|
|
3986
|
+
},
|
|
3987
|
+
system: {
|
|
3988
|
+
headline: "Internal system data, usually removed automatically by the platform.",
|
|
3989
|
+
recreate: "No action is normally needed. If you suspect a problem, share this page with a developer."
|
|
3990
|
+
}
|
|
3991
|
+
};
|
|
3992
|
+
function getNextSteps(category) {
|
|
3993
|
+
return GUIDANCE[category];
|
|
3994
|
+
}
|
|
3995
|
+
const RELATED_LINKS = [
|
|
3996
|
+
{ key: "order_id", label: "Order", path: (id) => `/orders/${id}`, selfTables: ["order"] },
|
|
3997
|
+
{ key: "customer_id", label: "Customer", path: (id) => `/customers/${id}`, selfTables: ["customer"] },
|
|
3998
|
+
{ key: "product_id", label: "Product", path: (id) => `/products/${id}`, selfTables: ["product"] }
|
|
3999
|
+
];
|
|
4000
|
+
function getRelatedLinks(tableName, oldData) {
|
|
4001
|
+
if (!oldData) return [];
|
|
4002
|
+
return RELATED_LINKS.flatMap((link) => {
|
|
4003
|
+
const id = oldData[link.key];
|
|
4004
|
+
if (link.selfTables.includes(tableName) || typeof id !== "string" || !id.trim()) return [];
|
|
4005
|
+
return [{ label: link.label, id, path: link.path(id) }];
|
|
4006
|
+
});
|
|
4007
|
+
}
|
|
4008
|
+
const fullName = (row) => {
|
|
4009
|
+
const parts = [row.first_name, row.last_name].filter(
|
|
4010
|
+
(part) => typeof part === "string" && part.trim() !== ""
|
|
4011
|
+
);
|
|
4012
|
+
return parts.length ? parts.join(" ") : void 0;
|
|
4013
|
+
};
|
|
4014
|
+
const addressLine = (row) => {
|
|
4015
|
+
const parts = [row.address_1, row.address_2, row.city, row.province, row.postal_code, row.country_code].filter((part) => typeof part === "string" && part.trim() !== "").map((part) => part.trim());
|
|
4016
|
+
return parts.length ? parts.join(", ") : void 0;
|
|
4017
|
+
};
|
|
4018
|
+
const NAME = { key: "name", label: "Name", derive: fullName };
|
|
4019
|
+
const ADDRESS = { key: "address", label: "Address", derive: addressLine };
|
|
4020
|
+
const CREATED = { key: "created_at", label: "Created", kind: "date" };
|
|
4021
|
+
const ENTITY_FIELDS = {
|
|
4022
|
+
order: [
|
|
4023
|
+
{ key: "display_id", label: "Order number" },
|
|
4024
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
4025
|
+
{ key: "email", label: "Customer email" },
|
|
4026
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
4027
|
+
{ key: "currency_code", label: "Currency" },
|
|
4028
|
+
{ key: "region_id", label: "Region ID", kind: "id" },
|
|
4029
|
+
{ key: "sales_channel_id", label: "Sales channel ID", kind: "id" },
|
|
4030
|
+
{ key: "canceled_at", label: "Canceled", kind: "date" },
|
|
4031
|
+
CREATED
|
|
4032
|
+
],
|
|
4033
|
+
order_line_item: [
|
|
4034
|
+
{ key: "title", label: "Item" },
|
|
4035
|
+
{ key: "variant_title", label: "Variant" },
|
|
4036
|
+
{ key: "variant_sku", label: "SKU" },
|
|
4037
|
+
{ key: "unit_price", label: "Unit price", kind: "money" },
|
|
4038
|
+
{ key: "product_id", label: "Product ID", kind: "id" },
|
|
4039
|
+
{ key: "variant_id", label: "Variant ID", kind: "id" },
|
|
4040
|
+
CREATED
|
|
4041
|
+
],
|
|
4042
|
+
cart_line_item: [
|
|
4043
|
+
{ key: "title", label: "Item" },
|
|
4044
|
+
{ key: "variant_sku", label: "SKU" },
|
|
4045
|
+
{ key: "quantity", label: "Quantity", kind: "number" },
|
|
4046
|
+
{ key: "unit_price", label: "Unit price", kind: "money" },
|
|
4047
|
+
{ key: "cart_id", label: "Cart ID", kind: "id" },
|
|
4048
|
+
{ key: "variant_id", label: "Variant ID", kind: "id" },
|
|
4049
|
+
CREATED
|
|
4050
|
+
],
|
|
4051
|
+
cart: [
|
|
4052
|
+
{ key: "email", label: "Email" },
|
|
4053
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
4054
|
+
{ key: "currency_code", label: "Currency" },
|
|
4055
|
+
{ key: "region_id", label: "Region ID", kind: "id" },
|
|
4056
|
+
{ key: "completed_at", label: "Completed", kind: "date" },
|
|
4057
|
+
CREATED
|
|
4058
|
+
],
|
|
4059
|
+
customer: [
|
|
4060
|
+
NAME,
|
|
4061
|
+
{ key: "email", label: "Email" },
|
|
4062
|
+
{ key: "phone", label: "Phone" },
|
|
4063
|
+
{ key: "company_name", label: "Company" },
|
|
4064
|
+
{ key: "has_account", label: "Registered account", kind: "boolean" },
|
|
4065
|
+
CREATED
|
|
4066
|
+
],
|
|
4067
|
+
customer_address: [
|
|
4068
|
+
{ key: "address_name", label: "Label" },
|
|
4069
|
+
NAME,
|
|
4070
|
+
ADDRESS,
|
|
4071
|
+
{ key: "phone", label: "Phone" },
|
|
4072
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
4073
|
+
{ key: "is_default_shipping", label: "Default shipping", kind: "boolean" },
|
|
4074
|
+
CREATED
|
|
4075
|
+
],
|
|
4076
|
+
order_address: [NAME, ADDRESS, { key: "phone", label: "Phone" }, CREATED],
|
|
4077
|
+
cart_address: [NAME, ADDRESS, { key: "phone", label: "Phone" }, CREATED],
|
|
4078
|
+
product: [
|
|
4079
|
+
{ key: "title", label: "Title" },
|
|
4080
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
4081
|
+
{ key: "handle", label: "Handle" },
|
|
4082
|
+
{ key: "subtitle", label: "Subtitle" },
|
|
4083
|
+
{ key: "collection_id", label: "Collection ID", kind: "id" },
|
|
4084
|
+
{ key: "is_giftcard", label: "Gift card", kind: "boolean" },
|
|
4085
|
+
CREATED
|
|
4086
|
+
],
|
|
4087
|
+
product_variant: [
|
|
4088
|
+
{ key: "title", label: "Title" },
|
|
4089
|
+
{ key: "sku", label: "SKU" },
|
|
4090
|
+
{ key: "barcode", label: "Barcode" },
|
|
4091
|
+
{ key: "product_id", label: "Product ID", kind: "id" },
|
|
4092
|
+
{ key: "manage_inventory", label: "Manages inventory", kind: "boolean" },
|
|
4093
|
+
CREATED
|
|
4094
|
+
],
|
|
4095
|
+
product_category: [
|
|
4096
|
+
{ key: "name", label: "Name" },
|
|
4097
|
+
{ key: "handle", label: "Handle" },
|
|
4098
|
+
{ key: "is_active", label: "Active", kind: "boolean" },
|
|
4099
|
+
{ key: "parent_category_id", label: "Parent category ID", kind: "id" },
|
|
4100
|
+
CREATED
|
|
4101
|
+
],
|
|
4102
|
+
product_collection: [{ key: "title", label: "Title" }, { key: "handle", label: "Handle" }, CREATED],
|
|
4103
|
+
payment: [
|
|
4104
|
+
{ key: "amount", label: "Amount", kind: "money" },
|
|
4105
|
+
{ key: "currency_code", label: "Currency" },
|
|
4106
|
+
{ key: "provider_id", label: "Provider" },
|
|
4107
|
+
{ key: "captured_at", label: "Captured", kind: "date" },
|
|
4108
|
+
{ key: "canceled_at", label: "Canceled", kind: "date" },
|
|
4109
|
+
{ key: "payment_collection_id", label: "Payment collection ID", kind: "id" },
|
|
4110
|
+
CREATED
|
|
4111
|
+
],
|
|
4112
|
+
payment_session: [
|
|
4113
|
+
{ key: "amount", label: "Amount", kind: "money" },
|
|
4114
|
+
{ key: "currency_code", label: "Currency" },
|
|
4115
|
+
{ key: "provider_id", label: "Provider" },
|
|
4116
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
4117
|
+
{ key: "payment_collection_id", label: "Payment collection ID", kind: "id" },
|
|
4118
|
+
CREATED
|
|
4119
|
+
],
|
|
4120
|
+
payment_collection: [
|
|
4121
|
+
{ key: "amount", label: "Amount", kind: "money" },
|
|
4122
|
+
{ key: "currency_code", label: "Currency" },
|
|
4123
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
4124
|
+
CREATED
|
|
4125
|
+
],
|
|
4126
|
+
refund: [
|
|
4127
|
+
{ key: "amount", label: "Amount", kind: "money" },
|
|
4128
|
+
{ key: "payment_id", label: "Payment ID", kind: "id" },
|
|
4129
|
+
{ key: "refund_reason_id", label: "Refund reason ID", kind: "id" },
|
|
4130
|
+
{ key: "note", label: "Note" },
|
|
4131
|
+
{ key: "created_by", label: "Created by" },
|
|
4132
|
+
CREATED
|
|
4133
|
+
],
|
|
4134
|
+
return: [
|
|
4135
|
+
{ key: "display_id", label: "Return number" },
|
|
4136
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
4137
|
+
{ key: "order_id", label: "Order ID", kind: "id" },
|
|
4138
|
+
{ key: "refund_amount", label: "Refund amount", kind: "money" },
|
|
4139
|
+
{ key: "received_at", label: "Received", kind: "date" },
|
|
4140
|
+
CREATED
|
|
4141
|
+
],
|
|
4142
|
+
payment_detail: [
|
|
4143
|
+
{ key: "type", label: "Method type" },
|
|
4144
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
4145
|
+
{ key: "is_default", label: "Default method", kind: "boolean" },
|
|
4146
|
+
CREATED
|
|
4147
|
+
],
|
|
4148
|
+
user: [NAME, { key: "email", label: "Email" }, CREATED],
|
|
4149
|
+
invite: [
|
|
4150
|
+
{ key: "email", label: "Email" },
|
|
4151
|
+
{ key: "accepted", label: "Accepted", kind: "boolean" },
|
|
4152
|
+
{ key: "expires_at", label: "Expires", kind: "date" },
|
|
4153
|
+
CREATED
|
|
4154
|
+
],
|
|
4155
|
+
api_key: [
|
|
4156
|
+
{ key: "title", label: "Title" },
|
|
4157
|
+
{ key: "type", label: "Type" },
|
|
4158
|
+
{ key: "redacted", label: "Key (redacted)" },
|
|
4159
|
+
{ key: "revoked_at", label: "Revoked", kind: "date" },
|
|
4160
|
+
CREATED
|
|
4161
|
+
],
|
|
4162
|
+
promotion: [
|
|
4163
|
+
{ key: "code", label: "Promotion code" },
|
|
4164
|
+
{ key: "type", label: "Type" },
|
|
4165
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
4166
|
+
{ key: "is_automatic", label: "Automatic", kind: "boolean" },
|
|
4167
|
+
CREATED
|
|
4168
|
+
],
|
|
4169
|
+
fulfillment: [
|
|
4170
|
+
{ key: "provider_id", label: "Provider" },
|
|
4171
|
+
{ key: "location_id", label: "Location ID", kind: "id" },
|
|
4172
|
+
{ key: "shipped_at", label: "Shipped", kind: "date" },
|
|
4173
|
+
{ key: "delivered_at", label: "Delivered", kind: "date" },
|
|
4174
|
+
{ key: "canceled_at", label: "Canceled", kind: "date" },
|
|
4175
|
+
CREATED
|
|
4176
|
+
],
|
|
4177
|
+
inventory_item: [
|
|
4178
|
+
{ key: "sku", label: "SKU" },
|
|
4179
|
+
{ key: "title", label: "Title" },
|
|
4180
|
+
{ key: "requires_shipping", label: "Requires shipping", kind: "boolean" },
|
|
4181
|
+
CREATED
|
|
4182
|
+
],
|
|
4183
|
+
inventory_level: [
|
|
4184
|
+
{ key: "inventory_item_id", label: "Inventory item ID", kind: "id" },
|
|
4185
|
+
{ key: "location_id", label: "Location ID", kind: "id" },
|
|
4186
|
+
{ key: "stocked_quantity", label: "Stocked", kind: "number" },
|
|
4187
|
+
{ key: "reserved_quantity", label: "Reserved", kind: "number" },
|
|
4188
|
+
CREATED
|
|
4189
|
+
],
|
|
4190
|
+
review: [
|
|
4191
|
+
{ key: "title", label: "Title" },
|
|
4192
|
+
{ key: "rating", label: "Rating", kind: "number" },
|
|
4193
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
4194
|
+
{ key: "product_id", label: "Product ID", kind: "id" },
|
|
4195
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
4196
|
+
CREATED
|
|
4197
|
+
]
|
|
4198
|
+
};
|
|
4199
|
+
const GENERIC_FIELDS = [
|
|
4200
|
+
{ key: "display_id", label: "Number" },
|
|
4201
|
+
{ key: "title", label: "Title" },
|
|
4202
|
+
{ key: "name", label: "Name" },
|
|
4203
|
+
NAME,
|
|
4204
|
+
{ key: "email", label: "Email" },
|
|
4205
|
+
{ key: "phone", label: "Phone" },
|
|
4206
|
+
{ key: "handle", label: "Handle" },
|
|
4207
|
+
{ key: "sku", label: "SKU" },
|
|
4208
|
+
{ key: "code", label: "Code" },
|
|
4209
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
4210
|
+
{ key: "type", label: "Type" },
|
|
4211
|
+
{ key: "amount", label: "Amount", kind: "money" },
|
|
4212
|
+
{ key: "quantity", label: "Quantity", kind: "number" },
|
|
4213
|
+
{ key: "currency_code", label: "Currency" },
|
|
4214
|
+
{ key: "order_id", label: "Order ID", kind: "id" },
|
|
4215
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
4216
|
+
{ key: "product_id", label: "Product ID", kind: "id" },
|
|
4217
|
+
{ key: "payment_id", label: "Payment ID", kind: "id" },
|
|
4218
|
+
{ key: "provider_id", label: "Provider" },
|
|
4219
|
+
CREATED,
|
|
4220
|
+
{ key: "updated_at", label: "Last updated", kind: "date" }
|
|
4221
|
+
];
|
|
4222
|
+
const MAX_GENERIC_FIELDS = 8;
|
|
4223
|
+
function amountOf(value) {
|
|
4224
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
4225
|
+
if (typeof value === "string" && value.trim() !== "" && Number.isFinite(Number(value))) return Number(value);
|
|
4226
|
+
if (value !== null && typeof value === "object" && "value" in value) {
|
|
4227
|
+
return amountOf(value.value);
|
|
4244
4228
|
}
|
|
4245
|
-
|
|
4246
|
-
|
|
4229
|
+
return null;
|
|
4230
|
+
}
|
|
4231
|
+
function formatValue(raw, kind, row) {
|
|
4232
|
+
if (raw === null || raw === void 0 || raw === "") return null;
|
|
4233
|
+
if (raw === MASKED_VALUE) return { value: MASKED_VALUE, kind: "masked" };
|
|
4234
|
+
switch (kind) {
|
|
4235
|
+
case "money": {
|
|
4236
|
+
const amount = amountOf(raw);
|
|
4237
|
+
if (amount === null) return null;
|
|
4238
|
+
const currency = typeof row.currency_code === "string" ? row.currency_code : null;
|
|
4239
|
+
return { value: formatMoney(amount, currency), kind };
|
|
4240
|
+
}
|
|
4241
|
+
case "date":
|
|
4242
|
+
return typeof raw === "string" || raw instanceof Date ? { value: formatDate(raw), kind } : null;
|
|
4243
|
+
case "boolean":
|
|
4244
|
+
return { value: raw === true || raw === "true" ? "Yes" : "No", kind };
|
|
4245
|
+
case "number": {
|
|
4246
|
+
const n = amountOf(raw);
|
|
4247
|
+
return n === null ? null : { value: formatNumber(n), kind };
|
|
4248
|
+
}
|
|
4249
|
+
case "status":
|
|
4250
|
+
return { value: String(raw).replace(/_/g, " "), kind };
|
|
4251
|
+
default:
|
|
4252
|
+
if (typeof raw === "object") return null;
|
|
4253
|
+
if (typeof raw === "string" && raw.length > 160) return { value: `${raw.slice(0, 157)}…`, kind };
|
|
4254
|
+
return { value: String(raw), kind };
|
|
4247
4255
|
}
|
|
4248
|
-
|
|
4249
|
-
|
|
4256
|
+
}
|
|
4257
|
+
function summarizeOldData(tableName, oldData) {
|
|
4258
|
+
if (!oldData) return [];
|
|
4259
|
+
const { value: row } = maskSensitiveData(oldData, tableName);
|
|
4260
|
+
const specific = ENTITY_FIELDS[tableName];
|
|
4261
|
+
const specs = specific ?? GENERIC_FIELDS;
|
|
4262
|
+
const fields = [];
|
|
4263
|
+
const seenLabels = /* @__PURE__ */ new Set();
|
|
4264
|
+
for (const spec of specs) {
|
|
4265
|
+
const raw = spec.derive ? spec.derive(row) : row[spec.key];
|
|
4266
|
+
const formatted = formatValue(raw, spec.kind ?? "text", row);
|
|
4267
|
+
if (!formatted || seenLabels.has(spec.label)) continue;
|
|
4268
|
+
seenLabels.add(spec.label);
|
|
4269
|
+
const value = spec.key === "currency_code" ? formatted.value.toUpperCase() : formatted.value;
|
|
4270
|
+
fields.push({ key: spec.key, label: spec.label, value, kind: formatted.kind });
|
|
4271
|
+
if (!specific && fields.length >= MAX_GENERIC_FIELDS) break;
|
|
4250
4272
|
}
|
|
4251
|
-
|
|
4252
|
-
|
|
4273
|
+
return fields;
|
|
4274
|
+
}
|
|
4275
|
+
function readLastListSearch() {
|
|
4276
|
+
try {
|
|
4277
|
+
return window.sessionStorage.getItem(LAST_LIST_URL_KEY) ?? "";
|
|
4278
|
+
} catch {
|
|
4279
|
+
return "";
|
|
4253
4280
|
}
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
const ReturnDetailPage = () => {
|
|
4281
|
+
}
|
|
4282
|
+
const DeletedRecordDetailPage = () => {
|
|
4257
4283
|
const navigate = useNavigate();
|
|
4258
|
-
const
|
|
4259
|
-
const
|
|
4260
|
-
const [
|
|
4261
|
-
const [
|
|
4262
|
-
const
|
|
4263
|
-
const
|
|
4264
|
-
|
|
4284
|
+
const location = useLocation();
|
|
4285
|
+
const { id = "" } = useParams();
|
|
4286
|
+
const [state, setState] = useState({ status: "loading" });
|
|
4287
|
+
const [reloadToken, setReloadToken] = useState(0);
|
|
4288
|
+
const cameFromList = location.state?.fromList === true;
|
|
4289
|
+
const goBack = () => {
|
|
4290
|
+
if (cameFromList) navigate(-1);
|
|
4291
|
+
else navigate(`/deleted-records-audit${readLastListSearch()}`);
|
|
4292
|
+
};
|
|
4265
4293
|
useEffect(() => {
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
const response = await fetch(`/admin/return/${id}`, {
|
|
4275
|
-
credentials: "include"
|
|
4276
|
-
});
|
|
4277
|
-
if (!response.ok) {
|
|
4278
|
-
const message = await response.text();
|
|
4279
|
-
throw new Error(message || "Unable to load return order");
|
|
4280
|
-
}
|
|
4281
|
-
const payload = await response.json();
|
|
4282
|
-
setReturnOrder(payload.return);
|
|
4283
|
-
} catch (loadError) {
|
|
4284
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
|
|
4285
|
-
setError(message);
|
|
4286
|
-
} finally {
|
|
4287
|
-
setIsLoading(false);
|
|
4288
|
-
}
|
|
4289
|
-
};
|
|
4290
|
-
void loadReturn();
|
|
4291
|
-
}, [id, navigate]);
|
|
4292
|
-
const handleReject = async () => {
|
|
4293
|
-
if (!id) {
|
|
4294
|
-
return;
|
|
4295
|
-
}
|
|
4296
|
-
try {
|
|
4297
|
-
setIsRejecting(true);
|
|
4298
|
-
setUpdateError(null);
|
|
4299
|
-
setUpdateSuccess(false);
|
|
4300
|
-
const response = await fetch(`/admin/return/${id}/reject`, {
|
|
4301
|
-
method: "POST",
|
|
4302
|
-
headers: {
|
|
4303
|
-
"Content-Type": "application/json"
|
|
4304
|
-
},
|
|
4305
|
-
credentials: "include",
|
|
4306
|
-
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
4294
|
+
const controller = new AbortController();
|
|
4295
|
+
setState({ status: "loading" });
|
|
4296
|
+
fetchAuditDetail(id, controller.signal).then((audit) => setState({ status: "ready", audit })).catch((e) => {
|
|
4297
|
+
if (controller.signal.aborted) return;
|
|
4298
|
+
setState({
|
|
4299
|
+
status: "error",
|
|
4300
|
+
message: e instanceof Error ? e.message : "Unknown error",
|
|
4301
|
+
notFound: e instanceof AuditApiError && e.status === 404
|
|
4307
4302
|
});
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4303
|
+
});
|
|
4304
|
+
return () => controller.abort();
|
|
4305
|
+
}, [id, reloadToken]);
|
|
4306
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-3 md:p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-4 md:p-6", children: [
|
|
4307
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Button, { variant: "transparent", size: "small", onClick: goBack, className: "-ml-2", children: [
|
|
4308
|
+
/* @__PURE__ */ jsx(ArrowLeft, {}),
|
|
4309
|
+
"Back to Deleted Records"
|
|
4310
|
+
] }) }),
|
|
4311
|
+
state.status === "loading" ? /* @__PURE__ */ jsx(DetailSkeleton, {}) : state.status === "error" ? /* @__PURE__ */ jsx(
|
|
4312
|
+
DetailError,
|
|
4313
|
+
{
|
|
4314
|
+
notFound: state.notFound,
|
|
4315
|
+
message: state.message,
|
|
4316
|
+
onRetry: () => setReloadToken((t) => t + 1),
|
|
4317
|
+
onBack: goBack
|
|
4311
4318
|
}
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4319
|
+
) : /* @__PURE__ */ jsx(DetailContent, { audit: state.audit })
|
|
4320
|
+
] }) });
|
|
4321
|
+
};
|
|
4322
|
+
const DetailContent = ({ audit }) => {
|
|
4323
|
+
const navigate = useNavigate();
|
|
4324
|
+
const entity = getEntityInfo(audit.table_name);
|
|
4325
|
+
const source = describeSource(audit.source);
|
|
4326
|
+
const summary = useMemo(() => summarizeOldData(audit.table_name, audit.old_data), [audit]);
|
|
4327
|
+
const masked = useMemo(() => maskSensitiveData(audit.old_data, audit.table_name), [audit]);
|
|
4328
|
+
const guidance = getNextSteps(entity.category.id);
|
|
4329
|
+
const related = getRelatedLinks(audit.table_name, audit.old_data);
|
|
4330
|
+
const [showRaw, setShowRaw] = useState(false);
|
|
4331
|
+
const copyJson = async () => {
|
|
4332
|
+
try {
|
|
4333
|
+
await navigator.clipboard.writeText(JSON.stringify(masked.value, null, 2));
|
|
4334
|
+
toast.success("Record data copied", {
|
|
4335
|
+
description: masked.maskedCount ? "Sensitive values were left hidden." : void 0
|
|
4318
4336
|
});
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
setReturnOrder(detailPayload.return);
|
|
4322
|
-
}
|
|
4323
|
-
} catch (updateErr) {
|
|
4324
|
-
const message = updateErr instanceof Error ? updateErr.message : "Unable to reject return";
|
|
4325
|
-
setUpdateError(message);
|
|
4326
|
-
} finally {
|
|
4327
|
-
setIsRejecting(false);
|
|
4337
|
+
} catch {
|
|
4338
|
+
toast.error("Couldn’t copy to clipboard");
|
|
4328
4339
|
}
|
|
4329
4340
|
};
|
|
4330
|
-
|
|
4331
|
-
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..." }) }) }) });
|
|
4332
|
-
}
|
|
4333
|
-
if (error || !returnOrder) {
|
|
4334
|
-
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: [
|
|
4335
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
|
|
4336
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
|
|
4337
|
-
] }) }) });
|
|
4338
|
-
}
|
|
4339
|
-
const statusHistory = returnOrder.metadata?.status_history || [];
|
|
4340
|
-
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: [
|
|
4341
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4341
4342
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
4342
|
-
/* @__PURE__ */ jsxs(
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
className: "w-fit",
|
|
4349
|
-
children: [
|
|
4350
|
-
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
4351
|
-
"Back to list"
|
|
4352
|
-
]
|
|
4353
|
-
}
|
|
4354
|
-
),
|
|
4355
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
4356
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
4357
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Return Order Details" }),
|
|
4358
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
|
|
4359
|
-
] }),
|
|
4360
|
-
/* @__PURE__ */ jsx(
|
|
4361
|
-
Badge,
|
|
4362
|
-
{
|
|
4363
|
-
size: "small",
|
|
4364
|
-
className: `uppercase ${getStatusBadgeClass$1(returnOrder.status)}`,
|
|
4365
|
-
children: returnOrder.status.replace(/_/g, " ")
|
|
4366
|
-
}
|
|
4367
|
-
)
|
|
4368
|
-
] })
|
|
4369
|
-
] }),
|
|
4370
|
-
returnOrder.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
4371
|
-
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
4372
|
-
Button,
|
|
4373
|
-
{
|
|
4374
|
-
variant: "danger",
|
|
4375
|
-
onClick: handleReject,
|
|
4376
|
-
disabled: isRejecting,
|
|
4377
|
-
isLoading: isRejecting,
|
|
4378
|
-
children: "Reject (Cancel) Return"
|
|
4379
|
-
}
|
|
4380
|
-
) }),
|
|
4381
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: 'Cancel this return request. Use "Mark as received" when items are received.' })
|
|
4382
|
-
] }),
|
|
4383
|
-
returnOrder.refund ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: /* @__PURE__ */ jsx(RefundCalculationBlock, { refund: returnOrder.refund }) }) : null,
|
|
4384
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
4385
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
4386
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
4387
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
4388
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
4389
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
4390
|
-
] }),
|
|
4391
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
4392
|
-
Button,
|
|
4393
|
-
{
|
|
4394
|
-
variant: "secondary",
|
|
4395
|
-
onClick: () => {
|
|
4396
|
-
window.open(
|
|
4397
|
-
`/app/orders/${returnOrder.order_id}`,
|
|
4398
|
-
"_blank"
|
|
4399
|
-
);
|
|
4400
|
-
},
|
|
4401
|
-
children: "View order"
|
|
4402
|
-
}
|
|
4403
|
-
) })
|
|
4404
|
-
] })
|
|
4405
|
-
] }),
|
|
4406
|
-
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
4407
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
4408
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
|
|
4409
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
4410
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
4411
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
4412
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
4413
|
-
] }),
|
|
4414
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
4415
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
4416
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
|
|
4417
|
-
] }),
|
|
4418
|
-
returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
4419
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
4420
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
|
|
4421
|
-
] }),
|
|
4422
|
-
returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
4423
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
4424
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
|
|
4425
|
-
] }),
|
|
4426
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
4427
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
4428
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
|
|
4429
|
-
] }),
|
|
4430
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
4431
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
4432
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
|
|
4433
|
-
] })
|
|
4434
|
-
] })
|
|
4343
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
4344
|
+
/* @__PURE__ */ jsxs(Badge, { size: "small", color: "red", children: [
|
|
4345
|
+
/* @__PURE__ */ jsx(Trash, {}),
|
|
4346
|
+
"Deleted"
|
|
4347
|
+
] }),
|
|
4348
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: entity.category.label })
|
|
4435
4349
|
] }),
|
|
4436
|
-
/* @__PURE__ */ jsxs(
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
size: "2xsmall",
|
|
4447
|
-
className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
|
|
4448
|
-
children: entry.status.replace(/_/g, " ")
|
|
4449
|
-
}
|
|
4450
|
-
) }),
|
|
4451
|
-
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
4452
|
-
new Date(entry.timestamp).toLocaleString(),
|
|
4453
|
-
entry.admin_id && ` by ${entry.admin_id}`,
|
|
4454
|
-
entry.reason && ` - ${entry.reason}`
|
|
4455
|
-
] })
|
|
4456
|
-
] })
|
|
4457
|
-
},
|
|
4458
|
-
index
|
|
4459
|
-
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
4350
|
+
/* @__PURE__ */ jsxs(Heading, { level: "h1", children: [
|
|
4351
|
+
"Deleted ",
|
|
4352
|
+
entity.label
|
|
4353
|
+
] }),
|
|
4354
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
4355
|
+
/* @__PURE__ */ jsx(CopyableId, { value: audit.record_id, emptyLabel: "This record type has no ID column", className: "text-sm" }),
|
|
4356
|
+
/* @__PURE__ */ jsxs(Text, { size: "xsmall", className: "text-ui-fg-muted", children: [
|
|
4357
|
+
"Database table: ",
|
|
4358
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono", children: audit.table_name })
|
|
4359
|
+
] })
|
|
4460
4360
|
] })
|
|
4461
4361
|
] }),
|
|
4462
|
-
|
|
4463
|
-
/* @__PURE__ */ jsx(
|
|
4464
|
-
/* @__PURE__ */ jsxs("
|
|
4465
|
-
/* @__PURE__ */
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4362
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 rounded-lg border border-ui-tag-orange-border bg-ui-tag-orange-bg px-4 py-3", children: [
|
|
4363
|
+
/* @__PURE__ */ jsx(InformationCircle, { className: "mt-0.5 shrink-0 text-ui-tag-orange-icon" }),
|
|
4364
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-tag-orange-text", children: [
|
|
4365
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: "This is a historical snapshot" }),
|
|
4366
|
+
" captured immediately before deletion. The record no longer exists in the database, so changes elsewhere in the admin are not reflected here."
|
|
4367
|
+
] })
|
|
4368
|
+
] }),
|
|
4369
|
+
/* @__PURE__ */ jsx(Section, { title: "Deletion information", children: /* @__PURE__ */ jsxs("dl", { className: "grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2", children: [
|
|
4370
|
+
/* @__PURE__ */ jsx(Field, { label: "Deleted", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
4371
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: formatExactDateTime(audit.occurred_at) }),
|
|
4372
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-xs text-ui-fg-muted", children: [
|
|
4373
|
+
/* @__PURE__ */ jsx(ClockSolid, { className: "size-3" }),
|
|
4374
|
+
formatRelativeTime(audit.occurred_at)
|
|
4375
|
+
] })
|
|
4376
|
+
] }) }),
|
|
4377
|
+
/* @__PURE__ */ jsx(Field, { label: "Deleted by", children: audit.deleted_by ? /* @__PURE__ */ jsx("span", { className: "break-all text-sm text-ui-fg-base", children: audit.deleted_by }) : /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-muted", children: "Not recorded" }) }),
|
|
4378
|
+
/* @__PURE__ */ jsx(Field, { label: "Source", children: source.kind === "unknown" ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-muted", children: "Unknown" }) : /* @__PURE__ */ jsx(Badge, { size: "small", color: sourceBadgeColor(source.kind), children: source.label }) }),
|
|
4379
|
+
/* @__PURE__ */ jsx(Field, { label: "Action", children: /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Permanently deleted" }) })
|
|
4380
|
+
] }) }),
|
|
4381
|
+
/* @__PURE__ */ jsx(
|
|
4382
|
+
Section,
|
|
4383
|
+
{
|
|
4384
|
+
title: "Record summary",
|
|
4385
|
+
description: `Key details of this ${entity.label.toLowerCase()} at the moment it was deleted.`,
|
|
4386
|
+
children: summary.length ? /* @__PURE__ */ jsx("dl", { className: "grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2", children: summary.map((field) => /* @__PURE__ */ jsx(Field, { label: field.label, children: field.kind === "id" ? /* @__PURE__ */ jsx(CopyableId, { value: field.value }) : field.kind === "status" ? /* @__PURE__ */ jsx(Badge, { size: "2xsmall", color: "grey", className: "capitalize", children: field.value }) : field.kind === "masked" ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-muted", children: "Hidden for security" }) : /* @__PURE__ */ jsx("span", { className: "break-words text-sm text-ui-fg-base", children: field.value }) }, field.label)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No key details could be extracted for this record type. See the original record data below." })
|
|
4387
|
+
}
|
|
4388
|
+
),
|
|
4389
|
+
/* @__PURE__ */ jsx(
|
|
4390
|
+
Section,
|
|
4391
|
+
{
|
|
4392
|
+
title: "Original record data",
|
|
4393
|
+
description: "The complete data captured before deletion.",
|
|
4394
|
+
actions: showRaw && audit.old_data ? /* @__PURE__ */ jsxs(Button, { variant: "secondary", size: "small", onClick: copyJson, children: [
|
|
4395
|
+
/* @__PURE__ */ jsx(SquareTwoStack, {}),
|
|
4396
|
+
"Copy JSON"
|
|
4397
|
+
] }) : null,
|
|
4398
|
+
children: audit.old_data ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
4399
|
+
masked.maskedCount > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4400
|
+
/* @__PURE__ */ jsx(ShieldCheck, { className: "shrink-0 text-ui-fg-muted" }),
|
|
4401
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
4402
|
+
masked.maskedCount,
|
|
4403
|
+
" sensitive ",
|
|
4404
|
+
masked.maskedCount === 1 ? "value is" : "values are",
|
|
4405
|
+
" hidden for security (passwords, tokens, card or account numbers)."
|
|
4406
|
+
] })
|
|
4407
|
+
] }) : null,
|
|
4408
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Button, { variant: "secondary", size: "small", onClick: () => setShowRaw((s2) => !s2), "aria-expanded": showRaw, children: [
|
|
4409
|
+
showRaw ? /* @__PURE__ */ jsx(ChevronDownMini, {}) : /* @__PURE__ */ jsx(ChevronRightMini, {}),
|
|
4410
|
+
showRaw ? "Hide full record" : "View full record"
|
|
4411
|
+
] }) }),
|
|
4412
|
+
showRaw ? /* @__PURE__ */ jsx(JsonViewer, { data: masked.value }) : null
|
|
4413
|
+
] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No data was captured for this deletion." })
|
|
4414
|
+
}
|
|
4415
|
+
),
|
|
4416
|
+
/* @__PURE__ */ jsx(Section, { title: "What you can do now", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
4417
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-base", children: [
|
|
4418
|
+
"This record was permanently deleted. ",
|
|
4419
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: "Automatic restoration is not available" }),
|
|
4420
|
+
" ",
|
|
4421
|
+
"from this screen."
|
|
4422
|
+
] }),
|
|
4423
|
+
/* @__PURE__ */ jsxs("ol", { className: "flex list-decimal flex-col gap-3 pl-5 text-sm text-ui-fg-subtle marker:text-ui-fg-muted", children: [
|
|
4424
|
+
/* @__PURE__ */ jsxs("li", { children: [
|
|
4425
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "Check whether this was expected." }),
|
|
4426
|
+
" ",
|
|
4427
|
+
audit.deleted_by || source.kind !== "unknown" ? "Confirm with the person or system shown above." : `Who deleted it wasn’t recorded—check with your team or integrations active around ${formatExactDateTime(audit.occurred_at)}.`,
|
|
4428
|
+
" ",
|
|
4429
|
+
guidance.headline
|
|
4476
4430
|
] }),
|
|
4477
|
-
/* @__PURE__ */ jsxs("
|
|
4478
|
-
/* @__PURE__ */ jsx(
|
|
4479
|
-
|
|
4431
|
+
/* @__PURE__ */ jsxs("li", { children: [
|
|
4432
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "If it needs to come back:" }),
|
|
4433
|
+
" ",
|
|
4434
|
+
guidance.recreate
|
|
4480
4435
|
] }),
|
|
4481
|
-
|
|
4482
|
-
/* @__PURE__ */ jsx(
|
|
4483
|
-
|
|
4484
|
-
returnOrder.order.currency_code || "$",
|
|
4485
|
-
(Number(returnOrder.order.total) / 100).toFixed(2)
|
|
4486
|
-
] })
|
|
4436
|
+
/* @__PURE__ */ jsxs("li", { children: [
|
|
4437
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "Need the details?" }),
|
|
4438
|
+
" Use “View full record” above to see or copy everything that was stored. Sensitive values stay hidden."
|
|
4487
4439
|
] })
|
|
4488
|
-
] })
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4440
|
+
] }),
|
|
4441
|
+
guidance.adminSection || related.length ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
4442
|
+
guidance.adminSection ? /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", onClick: () => navigate(guidance.adminSection.path), children: guidance.adminSection.label }) : null,
|
|
4443
|
+
related.map((link) => /* @__PURE__ */ jsxs(
|
|
4444
|
+
Button,
|
|
4445
|
+
{
|
|
4446
|
+
variant: "transparent",
|
|
4447
|
+
size: "small",
|
|
4448
|
+
onClick: () => navigate(link.path),
|
|
4449
|
+
title: `Opens ${link.label.toLowerCase()} ${link.id} if it still exists`,
|
|
4450
|
+
children: [
|
|
4451
|
+
"Open related ",
|
|
4452
|
+
link.label.toLowerCase(),
|
|
4453
|
+
/* @__PURE__ */ jsx(ChevronRightMini, {})
|
|
4454
|
+
]
|
|
4455
|
+
},
|
|
4456
|
+
link.path
|
|
4457
|
+
))
|
|
4458
|
+
] }) : null,
|
|
4459
|
+
related.length ? /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-muted", children: "Related records open only if they haven’t been deleted too." }) : null
|
|
4460
|
+
] }) })
|
|
4461
|
+
] });
|
|
4508
4462
|
};
|
|
4509
|
-
const
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4463
|
+
const Section = ({
|
|
4464
|
+
title,
|
|
4465
|
+
description,
|
|
4466
|
+
actions,
|
|
4467
|
+
children
|
|
4468
|
+
}) => /* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-4 rounded-lg border border-ui-border-base p-5", children: [
|
|
4469
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start justify-between gap-2", children: [
|
|
4470
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
4471
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: title }),
|
|
4472
|
+
description ? /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: description }) : null
|
|
4473
|
+
] }),
|
|
4474
|
+
actions
|
|
4475
|
+
] }),
|
|
4476
|
+
children
|
|
4477
|
+
] });
|
|
4478
|
+
const Field = ({ label, children }) => /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [
|
|
4479
|
+
/* @__PURE__ */ jsx("dt", { className: "text-xs font-medium uppercase tracking-wide text-ui-fg-muted", children: label }),
|
|
4480
|
+
/* @__PURE__ */ jsx("dd", { className: "min-w-0", children })
|
|
4481
|
+
] });
|
|
4482
|
+
const DetailSkeleton = () => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", "aria-busy": "true", children: [
|
|
4483
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
4484
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-24 rounded-full" }),
|
|
4485
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-64" }),
|
|
4486
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-48" })
|
|
4487
|
+
] }),
|
|
4488
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-14 w-full" }),
|
|
4489
|
+
Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 rounded-lg border border-ui-border-base p-5", children: [
|
|
4490
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-40" }),
|
|
4491
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: Array.from({ length: 4 }).map((__, j) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
4492
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-20" }),
|
|
4493
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-36" })
|
|
4494
|
+
] }, j)) })
|
|
4495
|
+
] }, i))
|
|
4496
|
+
] });
|
|
4497
|
+
const DetailError = ({
|
|
4498
|
+
notFound,
|
|
4499
|
+
message,
|
|
4500
|
+
onRetry,
|
|
4501
|
+
onBack
|
|
4502
|
+
}) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2 rounded-lg border border-ui-border-base px-6 py-12 text-center", children: [
|
|
4503
|
+
/* @__PURE__ */ jsx(ExclamationCircle, { className: clx(notFound ? "text-ui-fg-muted" : "text-ui-fg-error") }),
|
|
4504
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", children: notFound ? "Audit entry not found" : "Unable to load this deleted record" }),
|
|
4505
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "max-w-md text-ui-fg-subtle", children: notFound ? "This audit entry doesn’t exist. The link may be incorrect." : "We couldn’t retrieve the audit entry right now. Check your connection and try again." }),
|
|
4506
|
+
!notFound ? /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "max-w-md font-mono text-ui-fg-muted", children: message }) : null,
|
|
4507
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex gap-2", children: [
|
|
4508
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", onClick: onBack, children: "Back to Deleted Records" }),
|
|
4509
|
+
!notFound ? /* @__PURE__ */ jsx(Button, { variant: "primary", size: "small", onClick: onRetry, children: "Try again" }) : null
|
|
4510
|
+
] })
|
|
4511
|
+
] });
|
|
4512
|
+
const config$1 = defineRouteConfig({});
|
|
4513
4513
|
const getStatusBadgeClass = (status) => {
|
|
4514
4514
|
const statusLower = status.toLowerCase();
|
|
4515
4515
|
if (statusLower === "requested") {
|
|
@@ -4839,13 +4839,13 @@ const routeModule = {
|
|
|
4839
4839
|
handle: { label: config$3.label, translationNs: config$3.translationNs }
|
|
4840
4840
|
},
|
|
4841
4841
|
{
|
|
4842
|
-
Component:
|
|
4843
|
-
path: "/
|
|
4842
|
+
Component: ReturnDetailPage,
|
|
4843
|
+
path: "/returns/:id",
|
|
4844
4844
|
handle: { label: config$2.label, translationNs: config$2.translationNs }
|
|
4845
4845
|
},
|
|
4846
4846
|
{
|
|
4847
|
-
Component:
|
|
4848
|
-
path: "/
|
|
4847
|
+
Component: DeletedRecordDetailPage,
|
|
4848
|
+
path: "/deleted-records-audit/:id",
|
|
4849
4849
|
handle: { label: config$1.label, translationNs: config$1.translationNs }
|
|
4850
4850
|
},
|
|
4851
4851
|
{
|
|
@@ -4874,17 +4874,17 @@ const menuItemModule = {
|
|
|
4874
4874
|
translationNs: void 0
|
|
4875
4875
|
},
|
|
4876
4876
|
{
|
|
4877
|
-
label: config$
|
|
4878
|
-
icon: config$
|
|
4879
|
-
path: "/
|
|
4877
|
+
label: config$7.label,
|
|
4878
|
+
icon: config$7.icon,
|
|
4879
|
+
path: "/returns",
|
|
4880
4880
|
nested: void 0,
|
|
4881
4881
|
rank: void 0,
|
|
4882
4882
|
translationNs: void 0
|
|
4883
4883
|
},
|
|
4884
4884
|
{
|
|
4885
|
-
label: config$
|
|
4886
|
-
icon: config$
|
|
4887
|
-
path: "/
|
|
4885
|
+
label: config$8.label,
|
|
4886
|
+
icon: config$8.icon,
|
|
4887
|
+
path: "/refunds",
|
|
4888
4888
|
nested: void 0,
|
|
4889
4889
|
rank: void 0,
|
|
4890
4890
|
translationNs: void 0
|
|
@@ -4906,17 +4906,17 @@ const menuItemModule = {
|
|
|
4906
4906
|
translationNs: void 0
|
|
4907
4907
|
},
|
|
4908
4908
|
{
|
|
4909
|
-
label: config$
|
|
4910
|
-
icon: config$
|
|
4911
|
-
path: "/
|
|
4909
|
+
label: config$2.label,
|
|
4910
|
+
icon: config$2.icon,
|
|
4911
|
+
path: "/returns/:id",
|
|
4912
4912
|
nested: void 0,
|
|
4913
4913
|
rank: void 0,
|
|
4914
4914
|
translationNs: void 0
|
|
4915
4915
|
},
|
|
4916
4916
|
{
|
|
4917
|
-
label: config$
|
|
4918
|
-
icon: config$
|
|
4919
|
-
path: "/
|
|
4917
|
+
label: config$3.label,
|
|
4918
|
+
icon: config$3.icon,
|
|
4919
|
+
path: "/refunds/:id",
|
|
4920
4920
|
nested: void 0,
|
|
4921
4921
|
rank: void 0,
|
|
4922
4922
|
translationNs: void 0
|