Skip to content

Commit

Permalink
fix(dashboard): order list statuses (#7948)
Browse files Browse the repository at this point in the history
* fix: order list statuses

* refactor: remove todo
  • Loading branch information
fPolic authored Jul 4, 2024
1 parent 32998b7 commit 32982e7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { PaymentStatus } from "@medusajs/medusa"
import { useTranslation } from "react-i18next"
import { getOrderPaymentStatus } from "../../../../../lib/order-helpers"
import { StatusCell } from "../../common/status-cell"
Expand All @@ -10,9 +9,6 @@ type PaymentStatusCellProps = {
export const PaymentStatusCell = ({ status }: PaymentStatusCellProps) => {
const { t } = useTranslation()

// TODO: remove this when Order<>Payments are linked
return "-"

const { label, color } = getOrderPaymentStatus(t, status)

return <StatusCell color={color}>{label}</StatusCell>
Expand Down
3 changes: 3 additions & 0 deletions packages/admin-next/dashboard/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,12 @@
"statusTitle": "Payment Status",
"status": {
"notPaid": "Not paid",
"authorized": "Authorized",
"partiallyAuthorized": "Partially authorized",
"awaiting": "Awaiting",
"captured": "Captured",
"partiallyRefunded": "Partially refunded",
"partiallyCaptured": "Partially captured",
"refunded": "Refunded",
"canceled": "Canceled",
"requiresAction": "Requires action"
Expand Down
20 changes: 13 additions & 7 deletions packages/admin-next/dashboard/src/lib/order-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
import { FulfillmentStatus, PaymentStatus } from "@medusajs/medusa"
import { TFunction } from "i18next"

export const getOrderPaymentStatus = (
t: TFunction<"translation">,
status: PaymentStatus
status: string
) => {
const [label, color] = ({
const [label, color] = {
not_paid: [t("orders.payment.status.notPaid"), "red"],
authorized: [t("orders.payment.status.authorized"), "orange"],
partially_authorized: [
t("orders.payment.status.partiallyAuthorized"),
"red",
],
awaiting: [t("orders.payment.status.awaiting"), "orange"],
captured: [t("orders.payment.status.captured"), "green"],
refunded: [t("orders.payment.status.refunded"), "green"],
partially_refunded: [
t("orders.payment.status.partiallyRefunded"),
"orange",
],
partially_captured: [
t("orders.payment.status.partiallyCaptured"),
"orange",
],
canceled: [t("orders.payment.status.canceled"), "red"],
requires_action: [t("orders.payment.status.requiresAction"), "orange"],
}[status] ||
// TODO: remove this when Order<>Payment are linked
"not_paid") as [string, "red" | "orange" | "green"]
}[status]

return { label, color }
}

export const getOrderFulfillmentStatus = (
t: TFunction<"translation">,
status: FulfillmentStatus
status: string
) => {
const [label, color] = {
not_fulfilled: [t("orders.fulfillment.status.notFulfilled"), "red"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const DEFAULT_PROPERTIES = [
"created_at",
"canceled_at",
"email",
// "payment_status", // -> TODO replacement for this
"display_id",
"currency_code",
// --- TOTALS ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const DEFAULT_PROPERTIES = [
"created_at",
"email",
"display_id",
// "payment_status", // -> TODO replacement for this
"payment_status",
"fulfillment_status",
"total",
"currency_code",
]
Expand Down

0 comments on commit 32982e7

Please sign in to comment.