Skip to content

Commit dd5c5d3

Browse files
authored
Fix: Partial refund input error (#919)
1 parent 43b7260 commit dd5c5d3

File tree

3 files changed

+39
-14
lines changed

3 files changed

+39
-14
lines changed

frontend/src/components/common/OrdersTable/OrdersTable.module.scss

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,20 @@
148148
align-items: center;
149149
gap: 4px;
150150
font-size: 11px;
151-
color: var(--mantine-color-red-9);
152151
line-height: 1.3;
152+
153+
&[data-refund-status="REFUNDED"],
154+
&[data-refund-status="PARTIALLY_REFUNDED"] {
155+
color: var(--mantine-color-orange-7);
156+
}
157+
158+
&[data-refund-status="REFUND_PENDING"] {
159+
color: var(--mantine-color-yellow-7);
160+
}
161+
162+
&[data-refund-status="REFUND_FAILED"] {
163+
color: var(--mantine-color-red-7);
164+
}
153165
}
154166

155167
// Payment Section

frontend/src/components/common/OrdersTable/index.tsx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {t} from "@lingui/macro";
2-
import {Anchor, Button, Group, Menu, Popover, Text} from '@mantine/core';
2+
import {Anchor, Button, Group, Menu, Popover, Text, Tooltip} from '@mantine/core';
33
import {Event, IdParam, Invoice, MessageType, Order} from "../../../types.ts";
44
import {
55
IconAlertCircle,
@@ -10,7 +10,6 @@ import {
1010
IconClockPause,
1111
IconCopy,
1212
IconCreditCard,
13-
IconCurrencyDollar,
1413
IconDotsVertical,
1514
IconFileInvoice,
1615
IconFileOff,
@@ -317,12 +316,23 @@ export const OrdersTable = ({orders, event}: OrdersTableProps) => {
317316
enableHiding: true,
318317
cell: (info: CellContext<Order, unknown>) => {
319318
const order = info.row.original;
320-
const itemCount = order.order_items?.length || order.attendees?.length || 0;
319+
const totalQuantity = order.order_items?.reduce((sum, item) => sum + item.quantity, 0) || 0;
320+
const itemBreakdown = order.order_items?.map(item =>
321+
`${item.quantity}x ${item.item_name}`
322+
).join('\n') || '';
323+
321324
return (
322-
<div className={classes.itemsBadge}>
323-
<IconTicket size={14}/>
324-
{formatNumber(itemCount)} {t`item(s)`}
325-
</div>
325+
<Tooltip
326+
label={itemBreakdown}
327+
multiline
328+
withArrow
329+
disabled={!itemBreakdown}
330+
>
331+
<div className={classes.itemsBadge}>
332+
<IconTicket size={14}/>
333+
{formatNumber(totalQuantity)} {t`item(s)`}
334+
</div>
335+
</Tooltip>
326336
);
327337
},
328338
},
@@ -341,10 +351,12 @@ export const OrdersTable = ({orders, event}: OrdersTableProps) => {
341351
{t`Tax`}: {formatCurrency(order.total_tax, order.currency)}
342352
{' '}{t`Fees`}: {formatCurrency(order.total_fee, order.currency)}
343353
</Text>
344-
{order.total_refunded > 0 && (
345-
<Text className={classes.refundedAmount}>
346-
<IconCurrencyDollar size={12}/>
347-
{t`Refunded`}: {formatCurrency(order.total_refunded, order.currency)}
354+
{order.refund_status && (
355+
<Text className={classes.refundedAmount} data-refund-status={order.refund_status}>
356+
{order.refund_status === 'REFUNDED' && t`Refunded: ${formatCurrency(order.total_refunded, order.currency)}`}
357+
{order.refund_status === 'PARTIALLY_REFUNDED' && t`Partially refunded: ${formatCurrency(order.total_refunded, order.currency)}`}
358+
{order.refund_status === 'REFUND_PENDING' && t`Refund pending`}
359+
{order.refund_status === 'REFUND_FAILED' && t`Refund failed`}
348360
</Text>
349361
)}
350362
</div>

frontend/src/components/modals/RefundOrderModal/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export const RefundOrderModal = ({onClose, orderId}: RefundOrderModalProps) => {
110110
leftSection={<IconCash size={20}/>}
111111
rightSectionWidth={50}
112112
rightSection={<Text size="sm" c="dimmed">{order.currency}</Text>}
113+
required
113114
styles={{
114115
input: {
115116
fontWeight: 600,
@@ -133,9 +134,9 @@ export const RefundOrderModal = ({onClose, orderId}: RefundOrderModalProps) => {
133134
)}
134135
</Stack>
135136

136-
{isPartialRefund && (
137+
{(isPartialRefund && Number(form.values.amount) > 0) && (
137138
<Alert icon={<IconInfoCircle/>} color="blue" variant="light">
138-
{t`You are issuing a partial refund. The customer will be refunded ${form.values.amount.toFixed(2)} ${order.currency}.`}
139+
{t`You are issuing a partial refund. The customer will be refunded ${Number(form.values.amount).toFixed(2)} ${order.currency}.`}
139140
</Alert>
140141
)}
141142

0 commit comments

Comments
 (0)