-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(explorer): As a user, I want the Module page to display Portals …
…leveraging it (#851)
- Loading branch information
1 parent
a668ee1
commit 6a6a9aa
Showing
6 changed files
with
82 additions
and
6 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
39 changes: 39 additions & 0 deletions
39
explorer/src/pages/Module/components/ModulePortals/index.tsx
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { t } from "i18next"; | ||
import { useRef } from "react"; | ||
import useSWR from "swr"; | ||
import { Address } from "viem"; | ||
|
||
import { DataTable } from "@/components/DataTable"; | ||
import { columns, portalColumnsOption, skeletonPortals } from "@/constants/columns/portal"; | ||
import { columnsSkeleton } from "@/constants/columns/skeleton"; | ||
import { SWRKeys } from "@/interfaces/swr/enum"; | ||
import { useNetworkContext } from "@/providers/network-provider/context"; | ||
import { APP_ROUTES } from "@/routes/constants"; | ||
import { isNotNullOrUndefined } from "@/utils"; | ||
|
||
export const ModulePortals: React.FC<{ moduleId: Address }> = ({ moduleId }) => { | ||
const { | ||
sdk, | ||
network: { chain }, | ||
} = useNetworkContext(); | ||
|
||
const { data: portals, isLoading } = useSWR( | ||
`${SWRKeys.GET_MODULE_PORTAL_LIST}/${moduleId}/${chain.id}`, | ||
async () => sdk.portal.findBy(undefined, undefined, { modules_contains: [moduleId] }), | ||
{ | ||
shouldRetryOnError: false, | ||
}, | ||
); | ||
|
||
const columnsSkeletonRef = useRef(columnsSkeleton(columns({ chain }), portalColumnsOption)); | ||
const data = isLoading | ||
? { columns: columnsSkeletonRef.current, list: skeletonPortals(5) } | ||
: { columns: columns({ chain }), list: portals?.filter(isNotNullOrUndefined) || [] }; | ||
|
||
return ( | ||
<div className="flex flex-col gap-6 w-full px-5 md:px-10"> | ||
<p className="text-xl not-italic font-semibold text-text-primary dark:text-whiteDefault">{t("portal.title")}</p> | ||
<DataTable columns={data.columns} data={data.list} link={APP_ROUTES.PORTAL_BY_ID} /> | ||
</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