refactor(risk, navigation): update risk management redirects and enhance loading states
Changed default redirects in risk management pages to point to the new risk pools section. Removed unused risk lock log components and streamlined the admin reports page with a loading state for better user experience. Added a new DocFigure component for improved documentation visuals and updated localization files to include new figure descriptions.
This commit is contained in:
97
src/modules/reconcile/reconcile-item-actions.tsx
Normal file
97
src/modules/reconcile/reconcile-item-actions.tsx
Normal file
@@ -0,0 +1,97 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { RotateCcw, Wrench } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { AdminRowActionsMenu } from "@/components/admin/admin-row-actions-menu";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import {
|
||||
canCompleteTransferInCredit,
|
||||
canManuallyProcessTransferOrder,
|
||||
canReverseTransferOrder,
|
||||
transferOrderHasReconcileAction,
|
||||
} from "@/lib/wallet-transfer-actions";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { AdminReconcileItemRow } from "@/types/api/admin-reconcile";
|
||||
|
||||
type ReconcileItemActionsProps = {
|
||||
row: AdminReconcileItemRow;
|
||||
canWriteWallet: boolean;
|
||||
busy: boolean;
|
||||
onCompleteCredit: (transferNo: string) => void;
|
||||
onReverse: (transferNo: string) => void;
|
||||
onManualProcess: (transferNo: string) => void;
|
||||
};
|
||||
|
||||
export function ReconcileItemActions({
|
||||
row,
|
||||
canWriteWallet,
|
||||
busy,
|
||||
onCompleteCredit,
|
||||
onReverse,
|
||||
onManualProcess,
|
||||
}: ReconcileItemActionsProps): React.ReactElement {
|
||||
const { t } = useTranslation(["reconcile", "wallet"]);
|
||||
|
||||
const transferNo = row.side_a_ref ?? "";
|
||||
const actionRow = {
|
||||
direction: row.transfer_direction ?? undefined,
|
||||
status: row.current_transfer_status ?? row.status,
|
||||
fail_reason: row.transfer_fail_reason,
|
||||
external_ref_no: row.external_ref_no,
|
||||
can_reverse: row.can_reverse,
|
||||
can_complete_credit: row.can_complete_credit,
|
||||
can_manually_process: row.can_manually_process,
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{transferNo !== "" && transferOrderHasReconcileAction(actionRow, canWriteWallet) ? (
|
||||
<AdminRowActionsMenu
|
||||
busy={busy}
|
||||
actions={[
|
||||
{
|
||||
key: "complete",
|
||||
label: t("completeCredit", { ns: "wallet" }),
|
||||
hidden: !canCompleteTransferInCredit(actionRow, canWriteWallet),
|
||||
onClick: () => onCompleteCredit(transferNo),
|
||||
},
|
||||
{
|
||||
key: "manual",
|
||||
label: t("markCaseClosed", { ns: "wallet" }),
|
||||
icon: Wrench,
|
||||
hidden: !canManuallyProcessTransferOrder(actionRow, canWriteWallet),
|
||||
onClick: () => onManualProcess(transferNo),
|
||||
},
|
||||
{
|
||||
key: "reverse",
|
||||
label: t("reverse", { ns: "wallet" }),
|
||||
icon: RotateCcw,
|
||||
destructive: true,
|
||||
hidden: !canReverseTransferOrder(actionRow, canWriteWallet),
|
||||
onClick: () => onReverse(transferNo),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
) : null}
|
||||
{transferNo !== "" ? (
|
||||
<Link
|
||||
href={`/admin/wallet/transfer-orders?transfer_no=${encodeURIComponent(transferNo)}`}
|
||||
className={cn(buttonVariants({ variant: "outline", size: "sm" }), "h-8")}
|
||||
>
|
||||
{t("openTransferOrder")}
|
||||
</Link>
|
||||
) : null}
|
||||
{row.side_b_ref ? (
|
||||
<Link
|
||||
href={`/admin/wallet/transactions?txn_no=${encodeURIComponent(row.side_b_ref)}`}
|
||||
className={cn(buttonVariants({ variant: "outline", size: "sm" }), "h-8")}
|
||||
>
|
||||
{t("openWalletTxn")}
|
||||
</Link>
|
||||
) : null}
|
||||
{!transferNo && !row.side_b_ref ? <span>—</span> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user