fix(dashboard): fix customer details page crashing when their order is refunded (#14413)

1. Fix the customer details page crashing when a customer's order is fully refunded. The error was originating from the payment collections of the order not being retrieved, since they're being used to calculate the refunded total.
2. Other: fix country not showing as well due to incorrectly trying to retrieving and access the shipping address's country

Closes #14409
This commit is contained in:
Shahed Nasser
2025-12-29 09:38:21 +00:00
committed by GitHub
parent 89a0adc612
commit 4ac7b72d10
4 changed files with 16 additions and 5 deletions
@@ -9,6 +9,7 @@ import {
DateCell,
DateHeader,
} from "../../../components/table/table-cells/common/date-cell"
import { countries } from "../../../lib/data/countries"
import { CountryCell } from "../../../components/table/table-cells/order/country-cell"
import {
CustomerCell,
@@ -101,10 +102,10 @@ export const useOrderTableColumns = (props: UseOrderTableColumnsProps) => {
const isFullyRefunded = row.original.payment_status === "refunded"
const total = !isFullyRefunded
? getValue()
: row.original.payment_collections.reduce(
: row.original.payment_collections?.reduce(
(acc, payCol) => acc + (payCol.refunded_amount ?? 0),
0
)
) || 0
const currencyCode = row.original.currency_code
return (
@@ -121,7 +122,8 @@ export const useOrderTableColumns = (props: UseOrderTableColumnsProps) => {
columnHelper.display({
id: "actions",
cell: ({ row }) => {
const country = row.original.shipping_address?.country
const countryCode = row.original.shipping_address?.country_code
const country = countries.find((c) => c.iso_2 === countryCode)
return <CountryCell country={country} />
},