Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/ninety-trains-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Alphabetically sort the chains in SwapWidget UI
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,25 @@ import type { ThirdwebClient } from "../../../../../client/client.js";
export function useBridgeChains(client: ThirdwebClient) {
return useQuery({
queryKey: ["bridge-chains"],
queryFn: () => {
return chains({ client });
queryFn: async () => {
const data = await chains({ client });
const dataCopy = [...data];
// sort by name, but if name starts with number, put it at the end

return dataCopy.sort((a, b) => {
const aStartsWithNumber = a.name[0]?.match(/^\d/);
const bStartsWithNumber = b.name[0]?.match(/^\d/);

if (aStartsWithNumber && !bStartsWithNumber) {
return 1;
}

if (!aStartsWithNumber && bStartsWithNumber) {
return -1;
}

return a.name.localeCompare(b.name);
});
},
refetchOnMount: false,
refetchOnWindowFocus: false,
Expand Down
Loading