-
Notifications
You must be signed in to change notification settings - Fork 4
chore: ArNS Marketplace UI #880
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
Changes from all commits
034797e
9ed1cc9
b709a7c
17dec7e
a0e4e16
96b9fb6
f4c918c
e809d93
1baa4d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -41,7 +41,7 @@ import { ANTStateError } from '@src/utils/errors'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { queryClient } from '@src/utils/network'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { ColumnDef, createColumnHelper } from '@tanstack/react-table'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { capitalize } from 'lodash'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { CircleCheck, Star } from 'lucide-react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { BookCopy, CircleCheck, Star } from 'lucide-react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useEffect, useState } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { ReactNode } from 'react-markdown'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Link, useNavigate } from 'react-router-dom'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -470,7 +470,7 @@ const DomainsTable = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case 'action': { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex justify-end w-full"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="flex pr-3 w-fit gap-3"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="flex pr-3 w-fit gap-3"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {row.getValue('role') === 'owner' ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Tooltip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message={ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -530,6 +530,25 @@ const DomainsTable = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <></> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {row.getValue('role') === 'owner' && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Tooltip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message="Sell" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| icon={ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled={row.original.version < MIN_ANT_VERSION} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| navigate( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `/my-ants/new-listing/${ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| row.original.processId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }?name=${lowerCaseDomain(row.original.name)}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <BookCopy className="w-[18px] text-grey" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+533
to
+551
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Consider URL-encoding the name parameter in the query string. The navigation constructs a URL with the domain name as a query parameter, but the name is not URL-encoded. If domain names contain special characters (spaces, ampersands, Unicode, etc.), this could result in malformed URLs. Apply this diff to properly encode the name parameter: <Tooltip
message="Sell"
icon={
<button
disabled={row.original.version < MIN_ANT_VERSION}
onClick={() =>
navigate(
- `/my-ants/new-listing/${row.original.processId.toString()}?name=${
- row.original.name
- }`,
+ `/my-ants/new-listing/${row.original.processId}?name=${encodeURIComponent(
+ row.original.name
+ )}`,
)
}
>
<BookCopy className="w-[18px] text-grey" />
</button>
}
/>Note: The 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of encoding URI component, we have a lowerCaseDomain utility for the names
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 281 🏁 Script executed: Length of output: 1848 🏁 Script executed: Length of output: 4825 @atticusofsparta, you're absolutely right—using For the minimal fix respecting your approach, you could apply: navigate(
`/my-ants/new-listing/${row.original.processId}?name=${lowerCaseDomain(
row.original.name
)}`,
)However, I noticed that newer components in this PR (like const params = new URLSearchParams({
name: lowerCaseDomain(row.original.name),
// ... other params
});
navigate(`/my-ants/new-listing/${row.original.processId}?${params.toString()}`);This pattern would be more robust for edge cases while still using |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ManageAssetButtons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id={lowerCaseDomain(row.getValue('name') as string)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assetType="names" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,73 @@ | ||||||||||||||||||||||||||||||||||||||||
| import { fetchActiveListings } from '@blockydevs/arns-marketplace-data'; | ||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||
| ActiveListingTable, | ||||||||||||||||||||||||||||||||||||||||
| Card, | ||||||||||||||||||||||||||||||||||||||||
| Pagination, | ||||||||||||||||||||||||||||||||||||||||
| useCursorPagination, | ||||||||||||||||||||||||||||||||||||||||
| } from '@blockydevs/arns-marketplace-ui'; | ||||||||||||||||||||||||||||||||||||||||
| import { useAntsMetadata } from '@src/hooks/listings/useAntsMetadata'; | ||||||||||||||||||||||||||||||||||||||||
| import { usePrepareListings } from '@src/hooks/listings/usePrepareListings'; | ||||||||||||||||||||||||||||||||||||||||
| import { useGlobalState } from '@src/state'; | ||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||
| BLOCKYDEVS_MARKETPLACE_PROCESS_ID, | ||||||||||||||||||||||||||||||||||||||||
| marketplaceQueryKeys, | ||||||||||||||||||||||||||||||||||||||||
| } from '@src/utils/marketplace'; | ||||||||||||||||||||||||||||||||||||||||
| import { useQuery } from '@tanstack/react-query'; | ||||||||||||||||||||||||||||||||||||||||
| import { useEffect } from 'react'; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| const PAGE_SIZE = 20; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| const ActiveListingsTab = () => { | ||||||||||||||||||||||||||||||||||||||||
| const [{ aoClient }] = useGlobalState(); | ||||||||||||||||||||||||||||||||||||||||
| const pagination = useCursorPagination(PAGE_SIZE); | ||||||||||||||||||||||||||||||||||||||||
| const queryAntsMetadata = useAntsMetadata(); | ||||||||||||||||||||||||||||||||||||||||
| const queryActiveListings = useQuery({ | ||||||||||||||||||||||||||||||||||||||||
| refetchInterval: 15 * 1000, | ||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another question of if we need this refetch interval - its a costly query. Especially since this is a paginated query. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want to show users newly added listings in real time, then this interval is necessary. If it’s not that important for us, we can skip it here. |
||||||||||||||||||||||||||||||||||||||||
| structuralSharing: false, | ||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are using isPending below - i don't know much about this param I'll admit but i think we do want this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||
| queryKey: marketplaceQueryKeys.listings.list('active', { | ||||||||||||||||||||||||||||||||||||||||
| page: pagination.page, | ||||||||||||||||||||||||||||||||||||||||
| pageSize: pagination.pageSize, | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+27
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should probably have cursor in here as well, since the page number and size may be the same with a different cursor. |
||||||||||||||||||||||||||||||||||||||||
| cursor: pagination.cursor, | ||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||
| queryFn: () => { | ||||||||||||||||||||||||||||||||||||||||
| return fetchActiveListings({ | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard the query until aoClient is ready. Without enabled, the query may run with aoClient undefined and fail. const queryActiveListings = useQuery({
refetchInterval: 15 * 1000,
structuralSharing: false,
+ enabled: Boolean(aoClient),
queryKey: marketplaceQueryKeys.listings.list('active', {
page: pagination.page,
pageSize: pagination.pageSize,
}),📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| ao: aoClient, | ||||||||||||||||||||||||||||||||||||||||
| marketplaceProcessId: BLOCKYDEVS_MARKETPLACE_PROCESS_ID, | ||||||||||||||||||||||||||||||||||||||||
| limit: pagination.pageSize, | ||||||||||||||||||||||||||||||||||||||||
| cursor: pagination.cursor, | ||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| const preparedItems = usePrepareListings(queryActiveListings.data); | ||||||||||||||||||||||||||||||||||||||||
| const { totalItems } = queryActiveListings.data ?? {}; | ||||||||||||||||||||||||||||||||||||||||
| const totalPages = pagination.getTotalPages(totalItems); | ||||||||||||||||||||||||||||||||||||||||
| const isPending = | ||||||||||||||||||||||||||||||||||||||||
| queryActiveListings.isPending || queryAntsMetadata.isPending; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||
| if (!queryActiveListings.data) return; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| const { nextCursor, hasMore } = queryActiveListings.data; | ||||||||||||||||||||||||||||||||||||||||
| pagination.storeNextCursor(nextCursor, !!hasMore); | ||||||||||||||||||||||||||||||||||||||||
| }, [queryActiveListings.data, pagination.storeNextCursor]); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||
| <Card className="flex flex-col gap-8"> | ||||||||||||||||||||||||||||||||||||||||
| <ActiveListingTable | ||||||||||||||||||||||||||||||||||||||||
| data={preparedItems} | ||||||||||||||||||||||||||||||||||||||||
| isPending={isPending} | ||||||||||||||||||||||||||||||||||||||||
| error={queryActiveListings.error?.message} | ||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||
| {!isPending && ( | ||||||||||||||||||||||||||||||||||||||||
| <Pagination | ||||||||||||||||||||||||||||||||||||||||
| totalPages={totalPages} | ||||||||||||||||||||||||||||||||||||||||
| activeIndex={pagination.page} | ||||||||||||||||||||||||||||||||||||||||
| onPageChange={pagination.setPage} | ||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||
| </Card> | ||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| export default ActiveListingsTab; | ||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { fetchCompletedListings } from '@blockydevs/arns-marketplace-data'; | ||
| import { | ||
| Card, | ||
| CompletedListingTable, | ||
| Pagination, | ||
| useCursorPagination, | ||
| } from '@blockydevs/arns-marketplace-ui'; | ||
| import { useAntsMetadata } from '@src/hooks/listings/useAntsMetadata'; | ||
| import { usePrepareListings } from '@src/hooks/listings/usePrepareListings'; | ||
| import { useGlobalState } from '@src/state'; | ||
| import { | ||
| BLOCKYDEVS_MARKETPLACE_PROCESS_ID, | ||
| marketplaceQueryKeys, | ||
| } from '@src/utils/marketplace'; | ||
| import { useQuery } from '@tanstack/react-query'; | ||
| import { useEffect } from 'react'; | ||
|
|
||
| const PAGE_SIZE = 20; | ||
|
|
||
| const CompletedListingsTab = () => { | ||
| const [{ aoClient }] = useGlobalState(); | ||
| const pagination = useCursorPagination(PAGE_SIZE); | ||
| const queryAntsMetadata = useAntsMetadata(); | ||
| const queryCompletedListings = useQuery({ | ||
| refetchInterval: 15 * 1000, | ||
| enabled: Boolean(aoClient), | ||
| queryKey: marketplaceQueryKeys.listings.list('completed', { | ||
| page: pagination.page, | ||
| pageSize: pagination.pageSize, | ||
| cursor: pagination.cursor, | ||
| }), | ||
| queryFn: () => { | ||
| return fetchCompletedListings({ | ||
| ao: aoClient, | ||
| marketplaceProcessId: BLOCKYDEVS_MARKETPLACE_PROCESS_ID, | ||
| limit: pagination.pageSize, | ||
| cursor: pagination.cursor, | ||
| }); | ||
| }, | ||
|
Comment on lines
+24
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. refetch question on this one
|
||
| }); | ||
|
|
||
| const preparedItems = usePrepareListings(queryCompletedListings.data); | ||
| const { totalItems } = queryCompletedListings.data ?? {}; | ||
| const totalPages = pagination.getTotalPages(totalItems); | ||
| const isPending = | ||
| queryCompletedListings.isPending || queryAntsMetadata.isPending; | ||
|
|
||
| useEffect(() => { | ||
| if (!queryCompletedListings.data) return; | ||
|
|
||
| const { nextCursor, hasMore } = queryCompletedListings.data; | ||
| pagination.storeNextCursor(nextCursor, !!hasMore); | ||
| }, [queryCompletedListings.data, pagination.storeNextCursor]); | ||
|
|
||
| return ( | ||
| <Card className="flex flex-col gap-8"> | ||
| <CompletedListingTable | ||
| data={preparedItems} | ||
| isPending={isPending} | ||
| error={queryCompletedListings.error?.message} | ||
| /> | ||
| {!isPending && ( | ||
| <Pagination | ||
| totalPages={totalPages} | ||
| activeIndex={pagination.page} | ||
| onPageChange={pagination.setPage} | ||
| /> | ||
| )} | ||
| </Card> | ||
| ); | ||
| }; | ||
|
|
||
| export default CompletedListingsTab; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be why some styling is off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import '@src/index.css';it's moved to main.tsx and should override the package stylesare you able to provide examples with screenshots of things that don’t look the way they should?