diff --git a/packages/admin/dashboard/src/components/common/display-id/display-id.tsx b/packages/admin/dashboard/src/components/common/display-id/display-id.tsx new file mode 100644 index 0000000000..844dc04890 --- /dev/null +++ b/packages/admin/dashboard/src/components/common/display-id/display-id.tsx @@ -0,0 +1,30 @@ +import { useTranslation } from "react-i18next" +import { useState } from "react" +import copy from "copy-to-clipboard" + +import { clx, toast, Tooltip } from "@medusajs/ui" + +type DisplayIdProps = { + id: string + className?: string +} + +function DisplayId({ id, className }: DisplayIdProps) { + const { t } = useTranslation() + const [open, setOpen] = useState(false) + + const onClick = () => { + copy(id) + toast.success(t("actions.idCopiedToClipboard")) + } + + return ( + + + #{id.slice(-7)} + + + ) +} + +export default DisplayId diff --git a/packages/admin/dashboard/src/components/common/display-id/index.ts b/packages/admin/dashboard/src/components/common/display-id/index.ts new file mode 100644 index 0000000000..c423966ff1 --- /dev/null +++ b/packages/admin/dashboard/src/components/common/display-id/index.ts @@ -0,0 +1 @@ +export * from "./display-id" diff --git a/packages/admin/dashboard/src/i18n/translations/en.json b/packages/admin/dashboard/src/i18n/translations/en.json index 6b4a0a3e13..610615299a 100644 --- a/packages/admin/dashboard/src/i18n/translations/en.json +++ b/packages/admin/dashboard/src/i18n/translations/en.json @@ -98,6 +98,8 @@ "actions": { "save": "Save", "saveAsDraft": "Save as draft", + "copy": "Copy", + "copied": "Copied", "duplicate": "Duplicate", "publish": "Publish", "create": "Create", @@ -117,6 +119,7 @@ "showMore": "Show more", "continue": "Continue", "continueWithEmail": "Continue with Email", + "idCopiedToClipboard": "ID copied to clipboard", "addReason": "Add Reason", "addNote": "Add Note", "reset": "Reset", @@ -902,9 +905,10 @@ }, "payment": { "title": "Payments", - "isReadyToBeCaptured": "Payment {{id}} is ready to be captured.", + "isReadyToBeCaptured": "Payment <0/> is ready to be captured.", "totalPaidByCustomer": "Total paid by customer", "capture": "Capture payment", + "capture_short": "Capture", "refund": "Refund", "markAsPaid": "Mark as paid", "statusLabel": "Payment status", diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/components/copy-payment-link/copy-payment-link.tsx b/packages/admin/dashboard/src/routes/orders/order-detail/components/copy-payment-link/copy-payment-link.tsx index 91726c5be7..c4c1391a73 100644 --- a/packages/admin/dashboard/src/routes/orders/order-detail/components/copy-payment-link/copy-payment-link.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-detail/components/copy-payment-link/copy-payment-link.tsx @@ -41,12 +41,12 @@ const CopyPaymentLink = React.forwardRef( React.useEffect(() => { if (done) { - setText("Copied") + setText(t("actions.copied")) return } setTimeout(() => { - setText("Copy") + setText(t("actions.copy")) }, 500) }, [done]) diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-payment-section/order-payment-section.tsx b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-payment-section/order-payment-section.tsx index 4c778c20c6..fec3be7c3d 100644 --- a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-payment-section/order-payment-section.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-payment-section/order-payment-section.tsx @@ -12,7 +12,7 @@ import { usePrompt, } from "@medusajs/ui" import { format } from "date-fns" -import { useTranslation } from "react-i18next" +import { Trans, useTranslation } from "react-i18next" import { ActionMenu } from "../../../../../components/common/action-menu" import { useCapturePayment } from "../../../../../hooks/api" import { formatCurrency } from "../../../../../lib/format-currency" @@ -22,6 +22,7 @@ import { } from "../../../../../lib/money-amount-helpers" import { getOrderPaymentStatus } from "../../../../../lib/order-helpers" import { getTotalCaptured, getTotalPending } from "../../../../../lib/payment" +import DisplayId from "../../../../../components/common/display-id/display-id" type OrderPaymentSectionProps = { order: HttpTypes.AdminOrder @@ -176,21 +177,20 @@ const Payment = ({ payment.captured_at ? ["Captured", "green"] : ["Pending", "orange"] ) as [string, "green" | "orange"] - const cleanId = payment.id.replace("pay_", "") const showCapture = payment.captured_at === null && payment.canceled_at === null return (
-
-
+
+
- {cleanId} + {format( @@ -199,7 +199,7 @@ const Payment = ({ )}
-
+
{payment.provider_id} @@ -232,16 +232,27 @@ const Payment = ({ {showCapture && (
- + - {t("orders.payment.isReadyToBeCaptured", { - id: cleanId, - })} + ]} + />
-
)}