-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fix sorting, add pagination to all names page
- Loading branch information
Showing
5 changed files
with
152 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
import React, { useMemo } from 'react'; | ||
import React from 'react'; | ||
import { Text } from '@components/ui/text'; | ||
import { | ||
Table, | ||
TableBody, | ||
TableCaption, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from '@components/ui/table'; | ||
import { inscribedNamesAtom } from '@store/bridge'; | ||
import { useAtomValue } from 'jotai'; | ||
import { Table, TableBody, TableHead, TableHeader, TableRow } from '@components/ui/table'; | ||
import { inscribedNamesInfiniteAtom } from '@store/bridge'; | ||
import { useAtom } from 'jotai'; | ||
import { Button } from '@components/ui/button'; | ||
import { BridgedNameRow } from '@components/p/bridge/names/name-row'; | ||
import { useDeepMemo } from '@common/hooks/use-deep-memo'; | ||
|
||
export const BridgeNames: React.FC<{ children?: React.ReactNode }> = () => { | ||
const names = useAtomValue(inscribedNamesAtom); | ||
const [names, dispatch] = useAtom(inscribedNamesInfiniteAtom[0]); | ||
const fetchNextPage = React.useCallback(() => { | ||
dispatch({ type: 'fetchNextPage' }); | ||
}, [dispatch]); | ||
|
||
const nameRows = useMemo(() => { | ||
return names.map(name => { | ||
return <BridgedNameRow name={name} key={name.name} />; | ||
}); | ||
const nameRows = useDeepMemo(() => { | ||
return [ | ||
...names.pages.map(page => page.map(name => <BridgedNameRow name={name} key={name.name} />)), | ||
]; | ||
}, [names]); | ||
|
||
const hasMore = (names.pages.at(-1)?.length ?? 0) === 100; | ||
|
||
return ( | ||
<div className="flex flex-col gap-5 px-[29px]"> | ||
<Text variant="Heading02">BNS on L1</Text> | ||
<Table> | ||
<TableHeader> | ||
<TableRow> | ||
<TableHead className="text-caption01 text-text w-[200px]">Name</TableHead> | ||
<TableHead className="text-right">Time</TableHead> | ||
<TableHead className="text-right">View</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody>{nameRows}</TableBody> | ||
</Table> | ||
<div>{hasMore && <Button onClick={fetchNextPage}>Load More</Button>}</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters