Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions web/sdk/react/views/tokens/transactions/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,26 @@ import dayjs from 'dayjs';
interface getColumnsOptions {
dateFormat: string;
}
const TxnEventSourceMap = {
const TxnEventSourceMap: Record<string, string> = {
'system.starter': 'Starter tokens',
'system.buy': 'Recharge',
'system.awarded': 'Complimentary tokens',
'system.revert': 'Refund'
'system.revert': 'Refund',
'system.overdraft': 'Overdraft'
};

const eventFilterOptions = Object.entries(TxnEventSourceMap).map(
([value, label]) => ({ value, label })
);

export const getColumns = ({
dateFormat
}: getColumnsOptions): DataTableColumnDef<BillingTransaction, unknown>[] => [
{
header: 'Date',
accessorKey: 'createdAt',
enableColumnFilter: true,
filterType: 'date',
cell: ({ getValue }) => {
const value = getValue() as TimeStamp;
const date = isNullTimestamp(value)
Expand Down Expand Up @@ -59,6 +66,9 @@ export const getColumns = ({
{
header: 'Event',
accessorKey: 'source',
enableColumnFilter: true,
filterType: 'multiselect',
filterOptions: eventFilterOptions,
classNames: {
cell: tokenStyles.txnTableEventColumn
},
Expand Down
14 changes: 14 additions & 0 deletions web/sdk/react/views/tokens/transactions/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {
Button,
EmptyState,
Text,
Flex,
DataTable,
DataTableSort
} from '@raystack/apsara';
import { ExclamationTriangleIcon } from '@radix-ui/react-icons';
import { FilterIcon } from '@raystack/apsara/icons';
import type { BillingTransaction } from '~/src';
import { getColumns } from './columns';
import { useFrontier } from '~/react/contexts/FrontierContext';
Expand Down Expand Up @@ -40,6 +42,18 @@ export function TransactionsTable({
<Text size="small" weight="medium">
Token transactions
</Text>
<DataTable.Filters
trigger={
<Button
variant="outline"
color="neutral"
size="small"
leadingIcon={<FilterIcon />}
>
Filter
</Button>
}
/>
<DataTable.Content
emptyState={noDataChildren}
classNames={{ header: tokenStyles.txnTableHeader }}
Expand Down
Loading