Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refunds #4837

Merged
merged 11 commits into from
Jan 23, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { Order, OrderCustomer, Organization, Product } from '@polar-sh/api'
import { RowSelectionState } from '@tanstack/react-table'
import { useRouter } from 'next/navigation'
import { FormattedDateTime } from 'polarkit/components/ui/atoms'
import { FormattedDateTime, Pill } from 'polarkit/components/ui/atoms'
import Avatar from 'polarkit/components/ui/atoms/avatar'
import {
DataTable,
Expand All @@ -22,6 +22,24 @@ import {
import { formatCurrencyAndAmount } from 'polarkit/lib/money'
import React, { useEffect, useState } from 'react'

const AmountColumn = ({ order }: { order: Order }) => {
return (
<div className="flex flex-row gap-x-2">
<span>{formatCurrencyAndAmount(order.amount, order.currency)}</span>
{order.status == 'refunded' && (
<Pill color="blue" className="flex flex-row">
<span>Refunded</span>
</Pill>
)}
{order.status == 'partially_refunded' && (
<Pill color="purple" className="flex flex-row">
<span>Partial Refund</span>
</Pill>
)}
</div>
)
}

interface ClientPageProps {
organization: Organization
pagination: DataTablePaginationState
Expand Down Expand Up @@ -132,14 +150,12 @@ const ClientPage: React.FC<ClientPageProps> = ({
},
},
{
accessorKey: 'created_at',
accessorKey: 'amount',
enableSorting: true,
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Date" />
),
cell: (props) => (
<FormattedDateTime datetime={props.getValue() as string} />
<DataTableColumnHeader column={column} title="Amount" />
),
cell: ({ row: { original: order } }) => <AmountColumn order={order} />,
},
{
accessorKey: 'product',
Expand All @@ -162,13 +178,13 @@ const ClientPage: React.FC<ClientPageProps> = ({
},
},
{
accessorKey: 'amount',
accessorKey: 'created_at',
enableSorting: true,
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Amount" />
<DataTableColumnHeader column={column} title="Date" />
),
cell: ({ row: { original: order } }) => (
<>{formatCurrencyAndAmount(order.amount, order.currency)}</>
cell: (props) => (
<FormattedDateTime datetime={props.getValue() as string} />
),
},
]
Expand Down
Loading
Loading