Skip to content

Commit

Permalink
fix: fixed sorting bug and updated created col to updated
Browse files Browse the repository at this point in the history
  • Loading branch information
invisiblemask committed Nov 21, 2024
1 parent dffa261 commit 78c534e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/components/dashboard/hiiq-table/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useState } from 'react'
export type HIIQHoldersProps = {
address: string
tokens: string
created: number
updated: number
}

export const columns: ColumnDef<HIIQHoldersProps>[] = [
Expand Down Expand Up @@ -66,7 +66,7 @@ export const columns: ColumnDef<HIIQHoldersProps>[] = [
<Button
variant="ghost"
className="p-0"
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
onClick={() => column.toggleSorting()}
>
HiIQ Balance
<RiArrowDownSFill className="ml-2 h-4 w-4" />
Expand All @@ -80,15 +80,18 @@ export const columns: ColumnDef<HIIQHoldersProps>[] = [
</div>
)
},
sortingFn: (rowA, rowB) => {
return Number(rowA.original.tokens) - Number(rowB.original.tokens)
},
},
{
accessorKey: 'created',
header: 'Date Staked',
accessorKey: 'updated',
header: 'Date Updated',
cell: ({ row }) => {
return (
<div className="flex flex-row items-center gap-1 font-medium">
<span>
{new Date(row.getValue('created')).toLocaleDateString('en-GB', {
{new Date(row.getValue('updated')).toLocaleDateString('en-GB', {
day: 'numeric',
month: 'short',
year: 'numeric',
Expand Down
1 change: 0 additions & 1 deletion src/components/dashboard/hiiq-table/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export function DataTable<TData, TValue>({
getPaginationRowModel: getPaginationRowModel(),
onSortingChange: setSorting,
getSortedRowModel: getSortedRowModel(),

state: {
sorting,
},
Expand Down
4 changes: 2 additions & 2 deletions src/services/holders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type GetHIIQHoldersRankResponse = {
hiIQHoldersRank: {
address: string
tokens: string
created: number
updated: number
}[]
}

Expand Down Expand Up @@ -43,7 +43,7 @@ export const IQHoldersApi = createApi({
{
address: string
tokens: string
created: number
updated: number
}[],
{ limit: number; offset: number }
>({
Expand Down
1 change: 1 addition & 0 deletions src/services/holders/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const HIIQ_HOLDERS_RANK = gql`
address
tokens
created
updated
}
}
Expand Down

0 comments on commit 78c534e

Please sign in to comment.