diff --git a/apps/oeth/tsconfig.app.json b/apps/oeth/tsconfig.app.json index eb2d36377..e4322b551 100644 --- a/apps/oeth/tsconfig.app.json +++ b/apps/oeth/tsconfig.app.json @@ -18,5 +18,5 @@ "src/**/*.spec.jsx", "src/**/*.test.jsx" ], - "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx", "../../libs/defi/oeth/src/components/TopNav.tsx"] + "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] } diff --git a/libs/defi/oeth/src/components/History/HistoryTable.stories.tsx b/libs/defi/oeth/src/components/History/HistoryTable.stories.tsx index dc19da82b..9aae7936d 100644 --- a/libs/defi/oeth/src/components/History/HistoryTable.stories.tsx +++ b/libs/defi/oeth/src/components/History/HistoryTable.stories.tsx @@ -1,32 +1,15 @@ import { useState } from 'react'; -import { faker } from '@faker-js/faker'; import { Container, Stack, Typography } from '@mui/material'; import { within } from '@storybook/testing-library'; +import { rows } from './fixtures'; import { HistoryFilterButton } from './HistoryButton'; import { HistoryTable } from './HistoryTable'; import type { Meta, StoryObj } from '@storybook/react'; import type { ColumnFilter } from '@tanstack/react-table'; -import type { HistoryRow } from './HistoryTable'; - -const rows = faker.helpers.multiple( - () => ({ - date: faker.date.recent({ days: 35 }), - balance: faker.number.float({ - min: 10000, - max: 10000000000, - precision: 10, - }), - change: faker.number.float({ min: -10, max: 25 }), - type: faker.helpers.arrayElement(['swap', 'received', 'sent', 'yield']), - link: faker.internet.url(), - }), - { count: 150 }, -); - const WithFilters = () => { const [filter, setFilter] = useState({ id: 'type', value: [] }); return ( @@ -70,6 +53,7 @@ const WithFilters = () => { ))} + {/* @ts-expect-error type mismatch with fixtures */} ); @@ -80,6 +64,7 @@ const meta: Meta = { title: 'History/History table', args: { isLoading: false, + // @ts-expect-error type mismatch rows, }, render: (args) => ( diff --git a/libs/defi/oeth/src/components/History/HistoryTable.tsx b/libs/defi/oeth/src/components/History/HistoryTable.tsx index 2401bb7dc..95698dd6a 100644 --- a/libs/defi/oeth/src/components/History/HistoryTable.tsx +++ b/libs/defi/oeth/src/components/History/HistoryTable.tsx @@ -1,27 +1,12 @@ -import { useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useRef } from 'react'; -import { - Box, - Pagination, - Stack, - Table, - TableBody, - TableCell, - TableHead, - TableRow, -} from '@mui/material'; -import { LinkIcon, quantityFormat } from '@origin/shared/components'; -import { - createColumnHelper, - flexRender, - getCoreRowModel, - getFilteredRowModel, - getPaginationRowModel, - useReactTable, -} from '@tanstack/react-table'; +import { Box, Stack } from '@mui/material'; +import { DataTable, LinkIcon, quantityFormat } from '@origin/shared/components'; +import { createColumnHelper } from '@tanstack/react-table'; import { useIntl } from 'react-intl'; -import type { ColumnFilter, ColumnFiltersState } from '@tanstack/react-table'; +import type { DataTableRef } from '@origin/shared/components'; +import type { ColumnFilter } from '@tanstack/react-table'; type Filter = 'swap' | 'yield' | 'received' | 'sent'; @@ -31,6 +16,7 @@ export interface HistoryRow { change: number; balance: number; link: string; + [key: string]: unknown; } interface Props { @@ -41,9 +27,10 @@ interface Props { const columnHelper = createColumnHelper(); -export function HistoryTable({ rows, filter }: Props) { +export function HistoryTable({ rows, filter, isLoading }: Props) { const intl = useIntl(); - const [columnFilters, setColumnFilters] = useState([]); + const ref = useRef(null); + const columns = useMemo( () => [ columnHelper.accessor('date', { @@ -93,74 +80,18 @@ export function HistoryTable({ rows, filter }: Props) { [intl], ); - const table = useReactTable({ - data: rows, - columns, - state: { - pagination: { - pageSize: 20, - pageIndex: 0, - }, - columnFilters, - }, - getCoreRowModel: getCoreRowModel(), - getPaginationRowModel: getPaginationRowModel(), - getFilteredRowModel: getFilteredRowModel(), - onColumnFiltersChange: setColumnFilters, - // add when we do server side pagination - // manualPagination: true, - pageCount: rows.length / 3, - // add when we do server side pagination - // onPaginationChange: setPagination - }); - useEffect(() => { - table.getColumn('type')?.setFilterValue(filter); - }, [filter, table]); + ref?.current?.setFilter(filter, 'type'); + }, [filter]); + return ( - - - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => ( - - {flexRender( - header.column.columnDef.header, - header.getContext(), - )} - - ))} - - ))} - - - {table.getRowModel().rows.map((row) => ( - - {row.getVisibleCells().map((cell) => ( - - {flexRender(cell.column.columnDef.cell, cell.getContext())} - - ))} - - ))} - -
- table.setPageIndex(page)} - /> -
+ ); } diff --git a/libs/defi/oeth/src/components/History/fixtures.ts b/libs/defi/oeth/src/components/History/fixtures.ts new file mode 100644 index 000000000..c9310ed0c --- /dev/null +++ b/libs/defi/oeth/src/components/History/fixtures.ts @@ -0,0 +1,1052 @@ +export const rows = [ + { + date: '2023-08-09T09:24:28.392Z', + balance: 2905823500, + change: -8.708203432615846, + type: 'sent', + link: 'https://fixed-killing.net/', + }, + { + date: '2023-08-15T22:12:30.081Z', + balance: 844700630, + change: -9.270400318782777, + type: 'yield', + link: 'https://slim-styling.info', + }, + { + date: '2023-08-20T07:01:48.590Z', + balance: 1657474870, + change: 9.077522575389594, + type: 'sent', + link: 'https://milky-grandchild.name', + }, + { + date: '2023-08-06T22:10:47.654Z', + balance: 7383296180, + change: 8.149598793825135, + type: 'yield', + link: 'https://creative-group.name', + }, + { + date: '2023-08-03T06:54:51.975Z', + balance: 8167162390, + change: 7.759596772957593, + type: 'swap', + link: 'https://magnificent-treat.org/', + }, + { + date: '2023-08-13T05:23:36.673Z', + balance: 5229696650, + change: -4.359190490795299, + type: 'sent', + link: 'https://spotted-anesthesiologist.biz/', + }, + { + date: '2023-08-04T01:13:52.464Z', + balance: 4458535780, + change: -9.770266831619665, + type: 'received', + link: 'https://bare-muskrat.name/', + }, + { + date: '2023-08-19T03:04:49.081Z', + balance: 2513642140, + change: 18.21222705533728, + type: 'sent', + link: 'https://self-reliant-yam.info', + }, + { + date: '2023-07-26T03:56:14.395Z', + balance: 843777780, + change: 18.715593725210056, + type: 'swap', + link: 'https://perfumed-happening.org/', + }, + { + date: '2023-08-09T03:11:46.580Z', + balance: 596396680, + change: 1.9720372662413865, + type: 'received', + link: 'https://naughty-imagination.com', + }, + { + date: '2023-08-18T23:12:50.114Z', + balance: 8750886350, + change: 10.70621510851197, + type: 'received', + link: 'https://open-reprocessing.biz', + }, + { + date: '2023-07-24T15:07:06.628Z', + balance: 8322847100, + change: -9.620051335077733, + type: 'yield', + link: 'https://barren-journalist.biz', + }, + { + date: '2023-07-29T19:06:09.805Z', + balance: 636697010, + change: 10.078663516324013, + type: 'received', + link: 'https://whispered-anguish.net/', + }, + { + date: '2023-08-08T07:49:24.348Z', + balance: 4022903100, + change: -3.815771577646956, + type: 'swap', + link: 'https://firm-inversion.net/', + }, + { + date: '2023-07-30T02:08:30.121Z', + balance: 9292536560, + change: 6.059687343658879, + type: 'yield', + link: 'https://vigilant-recapitulation.com/', + }, + { + date: '2023-08-23T22:11:44.622Z', + balance: 3610512300, + change: 12.880512519041076, + type: 'sent', + link: 'https://perfumed-judgment.net/', + }, + { + date: '2023-08-19T10:28:23.081Z', + balance: 2270149970, + change: 10.585962830809876, + type: 'swap', + link: 'https://lawful-councilor.biz/', + }, + { + date: '2023-08-12T16:24:25.785Z', + balance: 6525393130, + change: -4.815741195343435, + type: 'received', + link: 'https://political-tract.name', + }, + { + date: '2023-08-01T18:48:07.428Z', + balance: 5050409710, + change: 4.072673523332924, + type: 'received', + link: 'https://creamy-job.org', + }, + { + date: '2023-08-16T19:17:43.237Z', + balance: 276207460, + change: -3.763450221158564, + type: 'sent', + link: 'https://inconsequential-dozen.net/', + }, + { + date: '2023-08-08T04:50:22.008Z', + balance: 5836661640, + change: 4.948086115764454, + type: 'swap', + link: 'https://plump-webpage.net/', + }, + { + date: '2023-07-30T02:10:47.594Z', + balance: 9709654270, + change: 7.666684470605105, + type: 'sent', + link: 'https://insidious-weekender.com/', + }, + { + date: '2023-08-10T20:13:20.875Z', + balance: 7836963680, + change: -4.659254213329405, + type: 'sent', + link: 'https://speedy-softdrink.info/', + }, + { + date: '2023-07-31T01:35:29.660Z', + balance: 7638311180, + change: -8.740590022644028, + type: 'yield', + link: 'https://grateful-pathogenesis.com', + }, + { + date: '2023-08-16T20:13:53.362Z', + balance: 8572619970, + change: -0.7305871462449431, + type: 'swap', + link: 'https://weak-grit.net', + }, + { + date: '2023-08-09T20:08:42.465Z', + balance: 1902293040, + change: 12.399773884098977, + type: 'swap', + link: 'https://frank-fencing.net/', + }, + { + date: '2023-08-24T14:20:38.983Z', + balance: 4786790460, + change: 2.432553342077881, + type: 'yield', + link: 'https://classic-regionalism.com', + }, + { + date: '2023-07-27T20:27:16.017Z', + balance: 7745072020, + change: -7.67745430348441, + type: 'swap', + link: 'https://nervous-confectionery.biz', + }, + { + date: '2023-08-07T18:15:52.094Z', + balance: 8886290650, + change: -5.531949570868164, + type: 'received', + link: 'https://jaded-phrase.net/', + }, + { + date: '2023-08-03T02:41:25.923Z', + balance: 9154576050, + change: 13.174208792624995, + type: 'sent', + link: 'https://courageous-walnut.com', + }, + { + date: '2023-08-09T04:06:35.138Z', + balance: 4518435720, + change: 15.643867878243327, + type: 'yield', + link: 'https://cooked-everybody.org/', + }, + { + date: '2023-07-27T04:56:40.838Z', + balance: 3989631390, + change: -1.094570824643597, + type: 'sent', + link: 'https://royal-ecliptic.biz/', + }, + { + date: '2023-08-01T08:14:00.584Z', + balance: 6886920130, + change: -2.7221622632350773, + type: 'yield', + link: 'https://new-banyan.org', + }, + { + date: '2023-08-09T23:54:33.670Z', + balance: 4347283380, + change: -1.0765372531022877, + type: 'sent', + link: 'https://conscious-leading.info', + }, + { + date: '2023-08-07T03:39:55.953Z', + balance: 3343251380, + change: 2.493433946510777, + type: 'yield', + link: 'https://fancy-cauliflower.org', + }, + { + date: '2023-07-27T23:43:31.961Z', + balance: 2466109540, + change: 14.945782331051305, + type: 'received', + link: 'https://minor-hellcat.org', + }, + { + date: '2023-08-04T06:50:24.497Z', + balance: 5950003620, + change: -3.7749596126377583, + type: 'sent', + link: 'https://valid-collaboration.com/', + }, + { + date: '2023-08-12T01:10:23.717Z', + balance: 4664512610, + change: 9.078100132755935, + type: 'swap', + link: 'https://muddy-barge.name', + }, + { + date: '2023-08-02T18:31:08.177Z', + balance: 3267278300, + change: 2.896045239176601, + type: 'sent', + link: 'https://healthy-armchair.name/', + }, + { + date: '2023-08-06T13:39:10.559Z', + balance: 5091366940, + change: 7.557168318890035, + type: 'yield', + link: 'https://lonely-waterwheel.biz/', + }, + { + date: '2023-08-07T11:41:08.714Z', + balance: 1948535790, + change: 20.446028797887266, + type: 'yield', + link: 'https://any-serval.name/', + }, + { + date: '2023-07-25T23:19:14.539Z', + balance: 9502426210, + change: -3.571468291338533, + type: 'received', + link: 'https://apt-chipmunk.net', + }, + { + date: '2023-08-04T16:27:00.392Z', + balance: 3086756500, + change: 11.703390107722953, + type: 'yield', + link: 'https://elegant-rancher.net/', + }, + { + date: '2023-08-02T00:49:04.218Z', + balance: 4359492790, + change: 4.026034857379273, + type: 'yield', + link: 'https://flowery-mascara.com', + }, + { + date: '2023-08-08T22:58:36.968Z', + balance: 6365044610, + change: 0.47157082124613225, + type: 'received', + link: 'https://ordinary-bee.com/', + }, + { + date: '2023-08-20T22:17:27.336Z', + balance: 2443112950, + change: 17.89905706536956, + type: 'yield', + link: 'https://impeccable-heirloom.com/', + }, + { + date: '2023-08-10T13:53:41.471Z', + balance: 4940397110, + change: 15.650188649306074, + type: 'sent', + link: 'https://dimpled-membership.org/', + }, + { + date: '2023-08-24T04:08:40.603Z', + balance: 8529300070, + change: 6.192756824893877, + type: 'yield', + link: 'https://gruesome-driveway.biz', + }, + { + date: '2023-08-14T17:11:01.638Z', + balance: 9836327800, + change: -3.895446005044505, + type: 'received', + link: 'https://feminine-honeydew.org/', + }, + { + date: '2023-08-11T22:45:24.587Z', + balance: 9234169940, + change: -6.109909208025783, + type: 'swap', + link: 'https://glum-value.net/', + }, + { + date: '2023-08-02T03:08:45.464Z', + balance: 50482640, + change: -8.19172924850136, + type: 'yield', + link: 'https://elegant-eurocentrism.biz/', + }, + { + date: '2023-08-03T13:59:43.292Z', + balance: 4904208130, + change: 14.849995655240491, + type: 'received', + link: 'https://little-marketer.name', + }, + { + date: '2023-07-22T21:32:21.914Z', + balance: 2065554380, + change: -8.90812263241969, + type: 'received', + link: 'https://single-humanity.name/', + }, + { + date: '2023-07-25T10:36:38.363Z', + balance: 7074928980, + change: 21.41129512572661, + type: 'received', + link: 'https://reckless-leopard.net/', + }, + { + date: '2023-07-21T18:14:45.427Z', + balance: 3596745580, + change: 0.13369130319915712, + type: 'sent', + link: 'https://ignorant-justification.name/', + }, + { + date: '2023-08-16T13:55:57.957Z', + balance: 4940343570, + change: 21.468565927352756, + type: 'sent', + link: 'https://troubled-adoption.info/', + }, + { + date: '2023-08-15T16:31:26.306Z', + balance: 5368313310, + change: 6.284740898991004, + type: 'yield', + link: 'https://sinful-vibraphone.biz', + }, + { + date: '2023-08-06T02:09:55.394Z', + balance: 9049889290, + change: 17.24372491822578, + type: 'swap', + link: 'https://linear-analytics.info', + }, + { + date: '2023-08-20T19:10:52.671Z', + balance: 280894810, + change: 9.847109070979059, + type: 'yield', + link: 'https://trusty-thrill.net', + }, + { + date: '2023-08-23T21:47:13.672Z', + balance: 3674929620, + change: 13.984326762147248, + type: 'sent', + link: 'https://organic-pencil.name', + }, + { + date: '2023-08-03T16:33:59.828Z', + balance: 7063405200, + change: -5.525222755968571, + type: 'swap', + link: 'https://that-princess.name/', + }, + { + date: '2023-08-15T01:04:00.139Z', + balance: 2022351280, + change: 5.126202659448609, + type: 'received', + link: 'https://trained-particle.org', + }, + { + date: '2023-08-01T02:43:08.459Z', + balance: 1681801840, + change: 16.510418973630294, + type: 'received', + link: 'https://bossy-satire.name/', + }, + { + date: '2023-08-14T03:44:53.794Z', + balance: 2530870840, + change: 15.648809940321371, + type: 'yield', + link: 'https://impassioned-front.info', + }, + { + date: '2023-08-13T21:31:45.104Z', + balance: 9628769890, + change: 21.316541467094794, + type: 'received', + link: 'https://soggy-evil.name/', + }, + { + date: '2023-08-10T07:45:17.519Z', + balance: 7429651370, + change: 7.555527552030981, + type: 'sent', + link: 'https://attentive-evening-wear.net/', + }, + { + date: '2023-08-18T00:52:50.334Z', + balance: 3301215310, + change: 0.747177058365196, + type: 'sent', + link: 'https://faraway-standoff.info', + }, + { + date: '2023-08-08T16:20:07.908Z', + balance: 9262014010, + change: 12.837662829551846, + type: 'swap', + link: 'https://fantastic-lightscreen.net/', + }, + { + date: '2023-07-30T22:22:49.349Z', + balance: 464918640, + change: 20.20089789177291, + type: 'swap', + link: 'https://likable-lipstick.biz/', + }, + { + date: '2023-07-31T22:13:38.198Z', + balance: 882609070, + change: 15.083553224103525, + type: 'swap', + link: 'https://strange-gosling.com', + }, + { + date: '2023-08-02T08:02:06.756Z', + balance: 5712603270, + change: 17.230609678663313, + type: 'received', + link: 'https://trim-alloy.name', + }, + { + date: '2023-08-06T15:05:27.310Z', + balance: 3032095510, + change: 18.399766453076154, + type: 'swap', + link: 'https://ignorant-stand.name', + }, + { + date: '2023-08-07T05:24:08.204Z', + balance: 448097240, + change: -9.545999596593902, + type: 'sent', + link: 'https://sane-post.name', + }, + { + date: '2023-08-12T18:49:18.292Z', + balance: 2490197710, + change: 6.249232146656141, + type: 'swap', + link: 'https://cylindrical-cub.name/', + }, + { + date: '2023-07-24T12:55:34.045Z', + balance: 7097047180, + change: 5.744686705293134, + type: 'swap', + link: 'https://petty-general.net/', + }, + { + date: '2023-08-17T07:09:38.713Z', + balance: 1614758830, + change: 17.577561591751873, + type: 'received', + link: 'https://gargantuan-section.net/', + }, + { + date: '2023-08-17T04:52:56.795Z', + balance: 8390280840, + change: 11.74086031736806, + type: 'received', + link: 'https://blind-commuter.org', + }, + { + date: '2023-08-12T09:29:29.953Z', + balance: 4530061750, + change: 3.450965272495523, + type: 'swap', + link: 'https://icy-beating.biz/', + }, + { + date: '2023-08-09T13:37:40.644Z', + balance: 4313041910, + change: 24.373829145915806, + type: 'received', + link: 'https://legitimate-high-rise.com/', + }, + { + date: '2023-08-04T07:56:57.447Z', + balance: 5033169150, + change: -2.1068390388973057, + type: 'swap', + link: 'https://linear-pinto.name', + }, + { + date: '2023-08-01T16:29:50.524Z', + balance: 9455547480, + change: 8.482989118201658, + type: 'yield', + link: 'https://hideous-fish.biz', + }, + { + date: '2023-08-05T00:18:19.468Z', + balance: 5346149900, + change: 24.13860564585775, + type: 'yield', + link: 'https://distinct-storey.net', + }, + { + date: '2023-08-03T07:04:06.504Z', + balance: 4851172100, + change: -7.146439884090796, + type: 'swap', + link: 'https://subtle-heirloom.net', + }, + { + date: '2023-08-11T20:29:43.613Z', + balance: 708300040, + change: 20.75598706724122, + type: 'sent', + link: 'https://tense-heaven.info', + }, + { + date: '2023-08-19T18:40:50.165Z', + balance: 7125903240, + change: 6.754635359393433, + type: 'yield', + link: 'https://afraid-den.org/', + }, + { + date: '2023-08-24T06:13:35.589Z', + balance: 5253690100, + change: -9.951394514646381, + type: 'sent', + link: 'https://wee-pheromone.net/', + }, + { + date: '2023-07-22T19:53:26.638Z', + balance: 7460417740, + change: 24.949184372089803, + type: 'swap', + link: 'https://sticky-cough.net/', + }, + { + date: '2023-08-13T00:39:20.723Z', + balance: 9492220490, + change: -6.812512658070773, + type: 'yield', + link: 'https://evergreen-preface.biz/', + }, + { + date: '2023-07-25T22:54:54.357Z', + balance: 2037309660, + change: -2.651602728292346, + type: 'swap', + link: 'https://immaculate-antling.biz', + }, + { + date: '2023-08-03T05:13:15.796Z', + balance: 5824103640, + change: -9.384545437060297, + type: 'swap', + link: 'https://near-trinket.com', + }, + { + date: '2023-08-13T14:57:19.569Z', + balance: 4860785660, + change: 11.9818445679266, + type: 'yield', + link: 'https://regal-victim.org/', + }, + { + date: '2023-08-08T23:30:51.065Z', + balance: 4520301540, + change: 13.407504328060895, + type: 'swap', + link: 'https://elegant-vengeance.info', + }, + { + date: '2023-08-21T19:58:17.287Z', + balance: 5847510020, + change: -0.0812852883245796, + type: 'swap', + link: 'https://white-origin.biz', + }, + { + date: '2023-08-22T22:15:10.776Z', + balance: 1239111960, + change: 16.282474347390234, + type: 'sent', + link: 'https://hearty-recapitulation.net/', + }, + { + date: '2023-07-23T21:43:26.441Z', + balance: 6238689250, + change: 16.95008099428378, + type: 'received', + link: 'https://infantile-cadet.name/', + }, + { + date: '2023-08-01T00:22:01.761Z', + balance: 9597797590, + change: 6.057171447901055, + type: 'received', + link: 'https://breakable-collaboration.info/', + }, + { + date: '2023-08-03T13:01:19.326Z', + balance: 2281452150, + change: 16.802954020677134, + type: 'swap', + link: 'https://masculine-shot.info/', + }, + { + date: '2023-08-03T16:44:16.524Z', + balance: 7931747350, + change: 10.092162161599845, + type: 'yield', + link: 'https://trim-cabana.biz/', + }, + { + date: '2023-08-17T02:33:01.425Z', + balance: 359045010, + change: -5.322901763720438, + type: 'yield', + link: 'https://bewitched-ramie.name/', + }, + { + date: '2023-08-19T14:39:58.873Z', + balance: 7289689840, + change: 16.130329166771844, + type: 'yield', + link: 'https://fortunate-chalk.info/', + }, + { + date: '2023-08-04T19:43:47.280Z', + balance: 3016172860, + change: 22.86063428153284, + type: 'yield', + link: 'https://round-lobster.net', + }, + { + date: '2023-08-19T00:53:51.768Z', + balance: 565733160, + change: 2.1270179410930723, + type: 'swap', + link: 'https://speedy-mob.org/', + }, + { + date: '2023-08-13T06:13:27.550Z', + balance: 4186946550, + change: 11.174687197199091, + type: 'yield', + link: 'https://edible-gemsbok.name/', + }, + { + date: '2023-07-30T09:00:41.485Z', + balance: 2978894390, + change: 11.23851340613328, + type: 'sent', + link: 'https://nippy-shoelace.org/', + }, + { + date: '2023-08-13T12:32:25.310Z', + balance: 4660696250, + change: 9.436725714476779, + type: 'swap', + link: 'https://unsung-quicksand.org', + }, + { + date: '2023-07-20T20:01:09.859Z', + balance: 8456941250, + change: 21.990910589229316, + type: 'swap', + link: 'https://informal-pine.name/', + }, + { + date: '2023-08-19T22:49:53.336Z', + balance: 7335924290, + change: 18.93318889895454, + type: 'yield', + link: 'https://hot-shack.net/', + }, + { + date: '2023-08-08T23:53:18.730Z', + balance: 9753887310, + change: 13.69695630390197, + type: 'swap', + link: 'https://grounded-mystery.name', + }, + { + date: '2023-08-07T07:34:02.929Z', + balance: 7338495620, + change: -3.475703609874472, + type: 'swap', + link: 'https://potable-father-in-law.org/', + }, + { + date: '2023-08-22T04:50:00.144Z', + balance: 3203831370, + change: 13.897141627967358, + type: 'received', + link: 'https://zesty-basement.name', + }, + { + date: '2023-07-24T14:00:12.428Z', + balance: 2410268600, + change: 21.874963556183502, + type: 'sent', + link: 'https://shady-cynic.net/', + }, + { + date: '2023-08-10T06:14:49.794Z', + balance: 8941298190, + change: 15.559496455825865, + type: 'swap', + link: 'https://hoarse-outlay.info', + }, + { + date: '2023-07-30T03:00:04.392Z', + balance: 7396618700, + change: 17.19702867907472, + type: 'sent', + link: 'https://married-recruit.org', + }, + { + date: '2023-08-01T21:38:11.271Z', + balance: 7207317650, + change: 11.396486917510629, + type: 'yield', + link: 'https://emotional-dollar.org/', + }, + { + date: '2023-08-21T00:46:58.250Z', + balance: 4918808070, + change: 5.468408960150555, + type: 'received', + link: 'https://frugal-city.name', + }, + { + date: '2023-08-11T23:55:18.759Z', + balance: 5963902130, + change: -1.989949174458161, + type: 'sent', + link: 'https://circular-incompetence.info', + }, + { + date: '2023-08-22T10:37:29.606Z', + balance: 9274577290, + change: 15.22795232012868, + type: 'swap', + link: 'https://vacant-readiness.com/', + }, + { + date: '2023-08-05T14:15:45.042Z', + balance: 5975846770, + change: -7.373732902342454, + type: 'yield', + link: 'https://difficult-poetry.name/', + }, + { + date: '2023-07-29T08:18:00.851Z', + balance: 905243960, + change: 7.9436579591128975, + type: 'received', + link: 'https://big-hearted-whirlwind.name', + }, + { + date: '2023-08-23T04:28:12.227Z', + balance: 9041153650, + change: 19.640102320117876, + type: 'sent', + link: 'https://gracious-surplus.biz', + }, + { + date: '2023-08-07T18:13:30.197Z', + balance: 9357065300, + change: 12.417318258667365, + type: 'swap', + link: 'https://silent-format.org', + }, + { + date: '2023-08-18T19:31:36.035Z', + balance: 3179192780, + change: 6.912120553897694, + type: 'sent', + link: 'https://amusing-story.name/', + }, + { + date: '2023-08-13T23:18:03.730Z', + balance: 3396137230, + change: 17.5823252950795, + type: 'yield', + link: 'https://smoggy-phase.biz', + }, + { + date: '2023-08-10T17:57:08.481Z', + balance: 4773039010, + change: 20.291502751642838, + type: 'received', + link: 'https://each-mapping.com/', + }, + { + date: '2023-08-21T21:08:47.161Z', + balance: 8451375620, + change: 9.090326976729557, + type: 'yield', + link: 'https://square-sandal.biz', + }, + { + date: '2023-07-26T20:28:24.791Z', + balance: 4361149570, + change: 20.422242095228285, + type: 'sent', + link: 'https://upright-mood.info', + }, + { + date: '2023-08-12T08:55:13.060Z', + balance: 3338459500, + change: 6.1444697075057775, + type: 'sent', + link: 'https://unusual-listing.name', + }, + { + date: '2023-08-23T19:25:03.696Z', + balance: 8948474910, + change: -2.5751917844172567, + type: 'swap', + link: 'https://secret-management.biz', + }, + { + date: '2023-08-10T15:27:43.987Z', + balance: 464345920, + change: -9.091949654975906, + type: 'swap', + link: 'https://unsteady-goodnight.com', + }, + { + date: '2023-07-21T19:56:15.578Z', + balance: 5117765500, + change: -7.576209468534216, + type: 'swap', + link: 'https://attentive-jasmine.org/', + }, + { + date: '2023-08-08T23:16:04.207Z', + balance: 8379460980, + change: -7.9690452315844595, + type: 'yield', + link: 'https://stable-green.org', + }, + { + date: '2023-08-15T05:30:21.844Z', + balance: 2840231380, + change: -3.1641928444150835, + type: 'yield', + link: 'https://secret-afterlife.info', + }, + { + date: '2023-08-16T16:51:27.599Z', + balance: 7218613590, + change: 4.1357435716781765, + type: 'swap', + link: 'https://hidden-boss.org', + }, + { + date: '2023-08-19T06:36:36.773Z', + balance: 6563180510, + change: 19.629470657091588, + type: 'sent', + link: 'https://guilty-flax.biz', + }, + { + date: '2023-08-20T11:20:58.049Z', + balance: 1287300100, + change: -6.198906524805352, + type: 'swap', + link: 'https://friendly-carving.info', + }, + { + date: '2023-08-04T22:54:30.290Z', + balance: 6411688780, + change: 2.1907601901330054, + type: 'received', + link: 'https://cooked-disconnection.info/', + }, + { + date: '2023-07-26T08:42:36.843Z', + balance: 4969864360, + change: 16.26245578401722, + type: 'sent', + link: 'https://outlying-crust.org', + }, + { + date: '2023-07-24T11:02:29.409Z', + balance: 8182378120, + change: -5.673653923440725, + type: 'swap', + link: 'https://serious-nonconformist.biz', + }, + { + date: '2023-08-24T08:55:00.074Z', + balance: 1701579960, + change: -3.4414722002111375, + type: 'received', + link: 'https://frigid-developmental.name/', + }, + { + date: '2023-08-06T13:10:58.500Z', + balance: 1042456320, + change: -8.591102588688955, + type: 'sent', + link: 'https://assured-knee.org', + }, + { + date: '2023-07-26T20:07:42.635Z', + balance: 6543119150, + change: 23.335167715558782, + type: 'sent', + link: 'https://distorted-ecology.com/', + }, + { + date: '2023-08-21T08:44:47.462Z', + balance: 3981878840, + change: 14.178313665324822, + type: 'received', + link: 'https://playful-trim.name', + }, + { + date: '2023-08-24T04:55:38.463Z', + balance: 9893684510, + change: 3.724940635729581, + type: 'swap', + link: 'https://lovely-opinion.info/', + }, + { + date: '2023-07-24T12:55:12.534Z', + balance: 7060813180, + change: 10.35112926387228, + type: 'sent', + link: 'https://trusty-operating.biz/', + }, + { + date: '2023-08-20T12:57:36.394Z', + balance: 9667993080, + change: -0.25340800173580647, + type: 'sent', + link: 'https://adolescent-caramel.name', + }, + { + date: '2023-08-23T00:30:11.475Z', + balance: 5431122380, + change: 17.010512063279748, + type: 'swap', + link: 'https://flashy-spectacles.org', + }, + { + date: '2023-08-18T19:55:41.124Z', + balance: 7212541150, + change: 9.085896057076752, + type: 'sent', + link: 'https://grouchy-tomography.name', + }, + { + date: '2023-08-15T10:12:04.918Z', + balance: 2716536270, + change: 20.51837938488461, + type: 'sent', + link: 'https://slow-runway.org/', + }, + { + date: '2023-07-24T17:51:22.521Z', + balance: 2147183330, + change: 20.648573914077133, + type: 'sent', + link: 'https://ultimate-elongation.com/', + }, + { + date: '2023-08-07T17:44:28.560Z', + balance: 8418826940, + change: 13.417102973908186, + type: 'swap', + link: 'https://bright-beanstalk.com/', + }, +]; diff --git a/libs/shared/assets/files/meta.png b/libs/shared/assets/files/meta.png new file mode 100644 index 000000000..9f06b9ef4 Binary files /dev/null and b/libs/shared/assets/files/meta.png differ diff --git a/libs/shared/components/src/DataTable/DataTable.tsx b/libs/shared/components/src/DataTable/DataTable.tsx new file mode 100644 index 000000000..b1ca3308e --- /dev/null +++ b/libs/shared/components/src/DataTable/DataTable.tsx @@ -0,0 +1,124 @@ +import { forwardRef, useImperativeHandle, useState } from 'react'; + +import { + Pagination, + Stack, + Table, + TableBody, + TableCell, + TableHead, + TableRow, +} from '@mui/material'; +import { + flexRender, + getCoreRowModel, + getFilteredRowModel, + getPaginationRowModel, + useReactTable, +} from '@tanstack/react-table'; + +import type { + ColumnDef, + ColumnFilter, + ColumnFiltersState, +} from '@tanstack/react-table'; + +type Data = Record; + +interface Props { + rows: Data[]; + columns: ColumnDef[]; + isLoading: boolean; + pageSize?: number; + pageCount: number; +} + +export const DataTable = forwardRef( + ({ rows, columns, pageSize = 20, pageCount }: Props, ref) => { + const [columnFilters, setColumnFilters] = useState([]); + const table = useReactTable({ + data: rows, + columns, + state: { + pagination: { + pageSize, + pageIndex: 0, + }, + columnFilters, + }, + getCoreRowModel: getCoreRowModel(), + getPaginationRowModel: getPaginationRowModel(), + getFilteredRowModel: getFilteredRowModel(), + onColumnFiltersChange: setColumnFilters, + // add when we do server side pagination + // manualPagination: true, + pageCount, + // add when we do server side pagination + // onPaginationChange: setPagination + }); + + useImperativeHandle( + ref, + (): DataTableRef => { + return { + setFilter: (filter: ColumnFilter, columnName: string) => { + table.getColumn(columnName)?.setFilterValue(filter); + }, + }; + }, + [table], + ); + return ( + + + + {table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => ( + + {flexRender( + header.column.columnDef.header, + header.getContext(), + )} + + ))} + + ))} + + + {table.getRowModel().rows.map((row) => ( + + {row.getVisibleCells().map((cell) => ( + + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + ))} + + ))} + +
+ table.setPageIndex(page)} + /> +
+ ); + }, +); + +DataTable.displayName = 'DataTable'; + +export type DataTableRef = { + setFilter: (filter: ColumnFilter, columnName: string) => void; +}; diff --git a/libs/shared/components/src/DataTable/index.tsx b/libs/shared/components/src/DataTable/index.tsx new file mode 100644 index 000000000..89841a480 --- /dev/null +++ b/libs/shared/components/src/DataTable/index.tsx @@ -0,0 +1 @@ +export * from './DataTable'; diff --git a/libs/shared/components/src/LinkIcon/index.tsx b/libs/shared/components/src/LinkIcon/index.tsx new file mode 100644 index 000000000..1718f57d5 --- /dev/null +++ b/libs/shared/components/src/LinkIcon/index.tsx @@ -0,0 +1 @@ +export * from './LinkIcon'; diff --git a/libs/shared/components/src/index.ts b/libs/shared/components/src/index.ts index 785656bb9..0c0f87547 100644 --- a/libs/shared/components/src/index.ts +++ b/libs/shared/components/src/index.ts @@ -1,3 +1,4 @@ export * from './Cards'; export * from './top-nav'; -export * from './LinkIcon/LinkIcon'; +export * from './LinkIcon'; +export * from './DataTable';