From 24d9cf592d8d1b410e998d3fb659575d5bf5bd6c Mon Sep 17 00:00:00 2001 From: poomthiti Date: Wed, 10 May 2023 11:37:57 +0700 Subject: [PATCH 1/6] feat: add tab url path for account details and public project details page --- CHANGELOG.md | 2 + src/lib/pages/account-details/index.tsx | 77 ++++++++++++++----- src/lib/pages/public-project/slug.tsx | 74 ++++++++++++------ .../[tab].tsx} | 0 .../account/[accountAddress]/index.tsx} | 0 src/pages/[network]/public-project/[slug].tsx | 3 - .../[network]/public-project/[slug]/[tab].tsx | 3 + .../[network]/public-project/[slug]/index.tsx | 3 + src/pages/account/[accountAddress]/[tab].tsx | 3 + src/pages/account/[accountAddress]/index.tsx | 3 + src/pages/public-project/[slug].tsx | 3 - src/pages/public-project/[slug]/[tab].tsx | 3 + src/pages/public-project/[slug]/index.tsx | 3 + 13 files changed, 127 insertions(+), 50 deletions(-) rename src/pages/[network]/account/{[accountAddress].tsx => [accountAddress]/[tab].tsx} (100%) rename src/pages/{account/[accountAddress].tsx => [network]/account/[accountAddress]/index.tsx} (100%) delete mode 100644 src/pages/[network]/public-project/[slug].tsx create mode 100644 src/pages/[network]/public-project/[slug]/[tab].tsx create mode 100644 src/pages/[network]/public-project/[slug]/index.tsx create mode 100644 src/pages/account/[accountAddress]/[tab].tsx create mode 100644 src/pages/account/[accountAddress]/index.tsx delete mode 100644 src/pages/public-project/[slug].tsx create mode 100644 src/pages/public-project/[slug]/[tab].tsx create mode 100644 src/pages/public-project/[slug]/index.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 820ac7839..66731aea5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features +- [#322](https://github.com/alleslabs/celatone-frontend/pull/322) Tab url path for account details and public project details pages + ### Improvements - [#298](https://github.com/alleslabs/celatone-frontend/pull/298) Show deposit/voting period from gov params and add minimum required alert diff --git a/src/lib/pages/account-details/index.tsx b/src/lib/pages/account-details/index.tsx index 21c0747bd..bdcbed1c4 100644 --- a/src/lib/pages/account-details/index.tsx +++ b/src/lib/pages/account-details/index.tsx @@ -10,13 +10,14 @@ import { Image, } from "@chakra-ui/react"; import { useRouter } from "next/router"; -import { useEffect, useState } from "react"; +import { useCallback, useEffect } from "react"; -import { useValidateAddress } from "lib/app-provider"; +import { useInternalNavigate, useValidateAddress } from "lib/app-provider"; import { BackButton } from "lib/components/button"; import { CopyLink } from "lib/components/CopyLink"; import { CustomTab } from "lib/components/CustomTab"; import { CustomIcon } from "lib/components/icon"; +import { Loading } from "lib/components/Loading"; import PageContainer from "lib/components/PageContainer"; import { InvalidState } from "lib/components/state"; import { useAccountDetailsTableCounts } from "lib/model/account"; @@ -27,7 +28,7 @@ import { usePublicProjectBySlug, } from "lib/services/publicProjectService"; import type { HumanAddr } from "lib/types"; -import { formatPrice, getFirstQueryParam, scrollToTop } from "lib/utils"; +import { formatPrice, getFirstQueryParam } from "lib/utils"; import { AssetsSection } from "./components/asset"; import { DelegationsSection } from "./components/delegations"; @@ -40,15 +41,17 @@ import { } from "./components/tables"; import { useAccountTotalValue } from "./data"; +const tableHeaderId = "accountDetailsTab"; + enum TabIndex { - Overview, - Assets, - Delegations, - Txs, - Codes, - Contracts, - Admins, - Proposals, + Overview = "overview", + Assets = "assets", + Delegations = "delegations", + Txs = "txs", + Codes = "codes", + Contracts = "contracts", + Admins = "admins", + Proposals = "proposals", } interface AccountDetailsBodyProps { @@ -58,8 +61,9 @@ interface AccountDetailsBodyProps { const InvalidAccount = () => ; const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { - const [tabIndex, setTabIndex] = useState(TabIndex.Overview); - const tableHeaderId = "accountDetailsTab"; + const navigate = useInternalNavigate(); + const router = useRouter(); + const tab = getFirstQueryParam(router.query.tab) as TabIndex; const { data: publicInfo } = usePublicProjectByAccountAddress(accountAddress); const { data: publicInfoBySlug } = usePublicProjectBySlug(publicInfo?.slug); const { data: accountId } = useAccountId(accountAddress); @@ -76,14 +80,41 @@ const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { const { totalAccountValue, isLoading } = useAccountTotalValue(accountAddress); - const handleTabChange = (tab: TabIndex) => { - AmpTrackUseTab(TabIndex[tab]); - setTabIndex(tab); - scrollToTop(); - }; + const handleTabChange = useCallback( + (nextTab: TabIndex) => { + if (nextTab === tab) return; + AmpTrackUseTab(nextTab); + navigate({ + pathname: "/account/[accountAddress]/[tab]", + query: { + accountAddress, + tab: nextTab, + }, + options: { + shallow: true, + }, + }); + }, + [accountAddress, tab, navigate] + ); const displayName = publicInfo?.name ?? "Account Details"; + useEffect(() => { + if (router.isReady && (!tab || !Object.values(TabIndex).includes(tab))) { + navigate({ + pathname: "/account/[accountAddress]/[tab]", + query: { + accountAddress, + tab: TabIndex.Overview, + }, + options: { + shallow: true, + }, + }); + } + }, [router.isReady, tab, accountAddress, navigate]); + return ( <> @@ -135,7 +166,7 @@ const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { )} - + { const accountAddressParam = getFirstQueryParam( router.query.accountAddress ) as HumanAddr; + const tab = getFirstQueryParam(router.query.tab) as TabIndex; useEffect(() => { - if (router.isReady) AmpTrack(AmpEvent.TO_ACCOUNT_DETAIL); - }, [router.isReady]); + if (router.isReady) + AmpTrack(AmpEvent.TO_ACCOUNT_DETAIL, { ...(tab && { tab }) }); + }, [router.isReady, tab]); + + if (!router.isReady) return ; return ( diff --git a/src/lib/pages/public-project/slug.tsx b/src/lib/pages/public-project/slug.tsx index 6c967f85d..f24adf499 100644 --- a/src/lib/pages/public-project/slug.tsx +++ b/src/lib/pages/public-project/slug.tsx @@ -1,12 +1,13 @@ import { Tabs, TabList, TabPanels, TabPanel } from "@chakra-ui/react"; import { useRouter } from "next/router"; -import { useEffect, useState } from "react"; +import { useEffect } from "react"; +import { useInternalNavigate } from "lib/app-provider"; import { CustomTab } from "lib/components/CustomTab"; import { Loading } from "lib/components/Loading"; import PageContainer from "lib/components/PageContainer"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; -import { scrollToTop } from "lib/utils"; +import { getFirstQueryParam } from "lib/utils"; import { DetailHeader } from "./components/DetailHeader"; import { PublicProjectAccountTable } from "./components/table/account/PublicProjectAccountTable"; @@ -15,15 +16,16 @@ import { PublicProjectContractTable } from "./components/table/contract/PublicPr import { usePublicData } from "./data"; enum TabIndex { - Overview, - Codes, - Contracts, - Accounts, + Overview = "overview", + Codes = "codes", + Contracts = "contracts", + Accounts = "accounts", } -export const ProjectDetail = () => { +const ProjectDetail = () => { const router = useRouter(); - const [tabIndex, setTabIndex] = useState(TabIndex.Overview); + const navigate = useInternalNavigate(); + const tab = getFirstQueryParam(router.query.tab) as TabIndex; const { publicCodes, publicContracts, @@ -33,20 +35,44 @@ export const ProjectDetail = () => { isLoading, } = usePublicData(); - useEffect(() => { - if (router.isReady) AmpTrack(AmpEvent.TO_PROJECT_DETAIL); - }, [router.isReady]); - - const handleOnViewMore = (tab: TabIndex) => { - setTabIndex(tab); - scrollToTop(); + const handleTabChange = (nextTab: TabIndex) => () => { + if (nextTab === tab) return; + navigate({ + pathname: "/public-project/[slug]/[tab]", + query: { + slug, + tab: nextTab, + }, + options: { + shallow: true, + }, + }); }; + useEffect(() => { + if (router.isReady) { + if (!tab || !Object.values(TabIndex).includes(tab)) { + navigate({ + pathname: "/public-project/[slug]/[tab]", + query: { + slug, + tab: TabIndex.Overview, + }, + options: { + shallow: true, + }, + }); + } + AmpTrack(AmpEvent.TO_PROJECT_DETAIL, { ...(tab && { tab }) }); + } + }, [router.isReady, tab, slug, navigate]); + if (isLoading) return ; + return ( - + { publicContracts.length + publicAccounts.length } - onClick={() => setTabIndex(TabIndex.Overview)} + onClick={handleTabChange(TabIndex.Overview)} > Overview setTabIndex(TabIndex.Codes)} + onClick={handleTabChange(TabIndex.Codes)} > Codes setTabIndex(TabIndex.Contracts)} + onClick={handleTabChange(TabIndex.Contracts)} > Contracts setTabIndex(TabIndex.Accounts)} + onClick={handleTabChange(TabIndex.Accounts)} > Accounts @@ -85,15 +111,15 @@ export const ProjectDetail = () => { handleOnViewMore(TabIndex.Codes)} + onViewMore={handleTabChange(TabIndex.Codes)} /> handleOnViewMore(TabIndex.Contracts)} + onViewMore={handleTabChange(TabIndex.Contracts)} /> handleOnViewMore(TabIndex.Accounts)} + onViewMore={handleTabChange(TabIndex.Accounts)} /> @@ -110,3 +136,5 @@ export const ProjectDetail = () => { ); }; + +export default ProjectDetail; diff --git a/src/pages/[network]/account/[accountAddress].tsx b/src/pages/[network]/account/[accountAddress]/[tab].tsx similarity index 100% rename from src/pages/[network]/account/[accountAddress].tsx rename to src/pages/[network]/account/[accountAddress]/[tab].tsx diff --git a/src/pages/account/[accountAddress].tsx b/src/pages/[network]/account/[accountAddress]/index.tsx similarity index 100% rename from src/pages/account/[accountAddress].tsx rename to src/pages/[network]/account/[accountAddress]/index.tsx diff --git a/src/pages/[network]/public-project/[slug].tsx b/src/pages/[network]/public-project/[slug].tsx deleted file mode 100644 index 21ef00b5f..000000000 --- a/src/pages/[network]/public-project/[slug].tsx +++ /dev/null @@ -1,3 +0,0 @@ -import { ProjectDetail } from "lib/pages/public-project/slug"; - -export default ProjectDetail; diff --git a/src/pages/[network]/public-project/[slug]/[tab].tsx b/src/pages/[network]/public-project/[slug]/[tab].tsx new file mode 100644 index 000000000..cb35ef6f5 --- /dev/null +++ b/src/pages/[network]/public-project/[slug]/[tab].tsx @@ -0,0 +1,3 @@ +import ProjectDetail from "lib/pages/public-project/slug"; + +export default ProjectDetail; diff --git a/src/pages/[network]/public-project/[slug]/index.tsx b/src/pages/[network]/public-project/[slug]/index.tsx new file mode 100644 index 000000000..cb35ef6f5 --- /dev/null +++ b/src/pages/[network]/public-project/[slug]/index.tsx @@ -0,0 +1,3 @@ +import ProjectDetail from "lib/pages/public-project/slug"; + +export default ProjectDetail; diff --git a/src/pages/account/[accountAddress]/[tab].tsx b/src/pages/account/[accountAddress]/[tab].tsx new file mode 100644 index 000000000..8549192f3 --- /dev/null +++ b/src/pages/account/[accountAddress]/[tab].tsx @@ -0,0 +1,3 @@ +import AccountDetails from "lib/pages/account-details"; + +export default AccountDetails; diff --git a/src/pages/account/[accountAddress]/index.tsx b/src/pages/account/[accountAddress]/index.tsx new file mode 100644 index 000000000..8549192f3 --- /dev/null +++ b/src/pages/account/[accountAddress]/index.tsx @@ -0,0 +1,3 @@ +import AccountDetails from "lib/pages/account-details"; + +export default AccountDetails; diff --git a/src/pages/public-project/[slug].tsx b/src/pages/public-project/[slug].tsx deleted file mode 100644 index 21ef00b5f..000000000 --- a/src/pages/public-project/[slug].tsx +++ /dev/null @@ -1,3 +0,0 @@ -import { ProjectDetail } from "lib/pages/public-project/slug"; - -export default ProjectDetail; diff --git a/src/pages/public-project/[slug]/[tab].tsx b/src/pages/public-project/[slug]/[tab].tsx new file mode 100644 index 000000000..cb35ef6f5 --- /dev/null +++ b/src/pages/public-project/[slug]/[tab].tsx @@ -0,0 +1,3 @@ +import ProjectDetail from "lib/pages/public-project/slug"; + +export default ProjectDetail; diff --git a/src/pages/public-project/[slug]/index.tsx b/src/pages/public-project/[slug]/index.tsx new file mode 100644 index 000000000..cb35ef6f5 --- /dev/null +++ b/src/pages/public-project/[slug]/index.tsx @@ -0,0 +1,3 @@ +import ProjectDetail from "lib/pages/public-project/slug"; + +export default ProjectDetail; From 4db4e71892890bbb91a51e2a4c00fcf974085ad1 Mon Sep 17 00:00:00 2001 From: poomthiti Date: Wed, 24 May 2023 17:40:52 +0700 Subject: [PATCH 2/6] fix: change route to plural forms --- src/lib/pages/account-details/index.tsx | 4 ++-- src/lib/pages/public-project/slug.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/pages/account-details/index.tsx b/src/lib/pages/account-details/index.tsx index bdcbed1c4..6602ea918 100644 --- a/src/lib/pages/account-details/index.tsx +++ b/src/lib/pages/account-details/index.tsx @@ -85,7 +85,7 @@ const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { if (nextTab === tab) return; AmpTrackUseTab(nextTab); navigate({ - pathname: "/account/[accountAddress]/[tab]", + pathname: "/accounts/[accountAddress]/[tab]", query: { accountAddress, tab: nextTab, @@ -103,7 +103,7 @@ const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { useEffect(() => { if (router.isReady && (!tab || !Object.values(TabIndex).includes(tab))) { navigate({ - pathname: "/account/[accountAddress]/[tab]", + pathname: "/accounts/[accountAddress]/[tab]", query: { accountAddress, tab: TabIndex.Overview, diff --git a/src/lib/pages/public-project/slug.tsx b/src/lib/pages/public-project/slug.tsx index f24adf499..1c784c906 100644 --- a/src/lib/pages/public-project/slug.tsx +++ b/src/lib/pages/public-project/slug.tsx @@ -38,7 +38,7 @@ const ProjectDetail = () => { const handleTabChange = (nextTab: TabIndex) => () => { if (nextTab === tab) return; navigate({ - pathname: "/public-project/[slug]/[tab]", + pathname: "/public-projects/[slug]/[tab]", query: { slug, tab: nextTab, @@ -53,7 +53,7 @@ const ProjectDetail = () => { if (router.isReady) { if (!tab || !Object.values(TabIndex).includes(tab)) { navigate({ - pathname: "/public-project/[slug]/[tab]", + pathname: "/public-projects/[slug]/[tab]", query: { slug, tab: TabIndex.Overview, From f882053599b130d905276be013ed4b93880747e4 Mon Sep 17 00:00:00 2001 From: poomthiti Date: Wed, 24 May 2023 18:18:24 +0700 Subject: [PATCH 3/6] fix: revert\\ --- src/lib/components/StopPropagationBox.tsx | 8 +++ src/lib/components/Tooltip.tsx | 14 ++++ src/lib/styles/theme/components/spinner.ts | 16 +++++ src/lib/styles/theme/components/tag.ts | 69 +++++++++++++++++++ .../[network]/accounts/[accountAddress].tsx | 3 + src/pages/[network]/blocks/[height].tsx | 3 + src/pages/[network]/blocks/index.tsx | 3 + src/pages/[network]/codes/[codeId].tsx | 3 + src/pages/[network]/codes/index.tsx | 3 + src/pages/[network]/contract-lists/[slug].tsx | 3 + src/pages/[network]/contract-lists/index.tsx | 3 + .../[network]/contracts/[contractAddress].tsx | 3 + src/pages/[network]/my-codes.tsx | 3 + src/pages/[network]/projects/[slug].tsx | 3 + src/pages/[network]/projects/[slug]/[tab].tsx | 3 + src/pages/[network]/projects/[slug]/index.tsx | 3 + src/pages/[network]/projects/index.tsx | 3 + src/pages/[network]/proposals/index.tsx | 3 + src/pages/[network]/proposals/whitelist.tsx | 3 + src/pages/[network]/txs/[txHash].tsx | 3 + src/pages/[network]/txs/index.tsx | 3 + src/pages/accounts/[accountAddress].tsx | 3 + src/pages/blocks/[height].tsx | 3 + src/pages/blocks/index.tsx | 3 + src/pages/codes/[codeId].tsx | 3 + src/pages/codes/index.tsx | 3 + src/pages/contract-lists/[slug].tsx | 3 + src/pages/contract-lists/index.tsx | 3 + src/pages/contracts/[contractAddress].tsx | 3 + src/pages/my-codes.tsx | 3 + src/pages/projects/[slug].tsx | 3 + src/pages/projects/[slug]/[tab].tsx | 3 + src/pages/projects/[slug]/index.tsx | 3 + src/pages/projects/index.tsx | 3 + src/pages/proposals/whitelist.tsx | 3 + src/pages/txs/[txHash].tsx | 3 + src/pages/txs/index.tsx | 3 + 37 files changed, 206 insertions(+) create mode 100644 src/lib/components/StopPropagationBox.tsx create mode 100644 src/lib/components/Tooltip.tsx create mode 100644 src/lib/styles/theme/components/spinner.ts create mode 100644 src/lib/styles/theme/components/tag.ts create mode 100644 src/pages/[network]/accounts/[accountAddress].tsx create mode 100644 src/pages/[network]/blocks/[height].tsx create mode 100644 src/pages/[network]/blocks/index.tsx create mode 100644 src/pages/[network]/codes/[codeId].tsx create mode 100644 src/pages/[network]/codes/index.tsx create mode 100644 src/pages/[network]/contract-lists/[slug].tsx create mode 100644 src/pages/[network]/contract-lists/index.tsx create mode 100644 src/pages/[network]/contracts/[contractAddress].tsx create mode 100644 src/pages/[network]/my-codes.tsx create mode 100644 src/pages/[network]/projects/[slug].tsx create mode 100644 src/pages/[network]/projects/[slug]/[tab].tsx create mode 100644 src/pages/[network]/projects/[slug]/index.tsx create mode 100644 src/pages/[network]/projects/index.tsx create mode 100644 src/pages/[network]/proposals/index.tsx create mode 100644 src/pages/[network]/proposals/whitelist.tsx create mode 100644 src/pages/[network]/txs/[txHash].tsx create mode 100644 src/pages/[network]/txs/index.tsx create mode 100644 src/pages/accounts/[accountAddress].tsx create mode 100644 src/pages/blocks/[height].tsx create mode 100644 src/pages/blocks/index.tsx create mode 100644 src/pages/codes/[codeId].tsx create mode 100644 src/pages/codes/index.tsx create mode 100644 src/pages/contract-lists/[slug].tsx create mode 100644 src/pages/contract-lists/index.tsx create mode 100644 src/pages/contracts/[contractAddress].tsx create mode 100644 src/pages/my-codes.tsx create mode 100644 src/pages/projects/[slug].tsx create mode 100644 src/pages/projects/[slug]/[tab].tsx create mode 100644 src/pages/projects/[slug]/index.tsx create mode 100644 src/pages/projects/index.tsx create mode 100644 src/pages/proposals/whitelist.tsx create mode 100644 src/pages/txs/[txHash].tsx create mode 100644 src/pages/txs/index.tsx diff --git a/src/lib/components/StopPropagationBox.tsx b/src/lib/components/StopPropagationBox.tsx new file mode 100644 index 000000000..738900ccd --- /dev/null +++ b/src/lib/components/StopPropagationBox.tsx @@ -0,0 +1,8 @@ +import { Box } from "@chakra-ui/react"; +import type { ReactNode } from "react"; + +export const StopPropagationBox = ({ children }: { children: ReactNode }) => ( + e.stopPropagation()} cursor="initial"> + {children} + +); diff --git a/src/lib/components/Tooltip.tsx b/src/lib/components/Tooltip.tsx new file mode 100644 index 000000000..f96c1395c --- /dev/null +++ b/src/lib/components/Tooltip.tsx @@ -0,0 +1,14 @@ +import type { TooltipProps } from "@chakra-ui/react"; +import { Tooltip as ChakraTooltip } from "@chakra-ui/react"; + +export const Tooltip = ({ + placement = "top", + ...tooltipProps +}: TooltipProps) => ( + +); diff --git a/src/lib/styles/theme/components/spinner.ts b/src/lib/styles/theme/components/spinner.ts new file mode 100644 index 000000000..ee36b3772 --- /dev/null +++ b/src/lib/styles/theme/components/spinner.ts @@ -0,0 +1,16 @@ +import type { ComponentStyleConfig } from "@chakra-ui/react"; + +export const Spinner: ComponentStyleConfig = { + baseStyle: { + color: "gray.600", + speed: "0.65s", + }, + variants: { + primary: { + color: "primary.light", + }, + light: { + color: "text.main", + }, + }, +}; diff --git a/src/lib/styles/theme/components/tag.ts b/src/lib/styles/theme/components/tag.ts new file mode 100644 index 000000000..b376e313a --- /dev/null +++ b/src/lib/styles/theme/components/tag.ts @@ -0,0 +1,69 @@ +import { tagAnatomy } from "@chakra-ui/anatomy"; +import { createMultiStyleConfigHelpers } from "@chakra-ui/react"; + +const { definePartsStyle, defineMultiStyleConfig } = + createMultiStyleConfigHelpers(tagAnatomy.keys); + +const accentDark = definePartsStyle({ + container: { + bg: "accent.dark", + color: "gray.900", + }, +}); + +const accentDarker = definePartsStyle({ + container: { + bg: "accent.darker", + color: "text.main", + }, +}); + +const primaryLight = definePartsStyle({ + container: { + bg: "primary.light", + color: "gray.900", + }, +}); + +const gray = definePartsStyle({ + container: { + bg: "gray.700", + color: "text.main", + }, +}); + +export const Tag = defineMultiStyleConfig({ + baseStyle: { + container: { + px: 2, + py: 0, + borderRadius: "full", + lineHeight: "100%", + textAlign: "center", + }, + }, + sizes: { + sm: { + container: { + maxH: "20px", + fontSize: "12px", + }, + }, + md: { + container: { + maxH: "24px", + fontSize: "12px", + }, + }, + }, + variants: { + "primary-light": primaryLight, + "accent-dark": accentDark, + "accent-darker": accentDarker, + gray, + }, + defaultProps: { + size: "md", + variant: "accent-darker", + }, +}); diff --git a/src/pages/[network]/accounts/[accountAddress].tsx b/src/pages/[network]/accounts/[accountAddress].tsx new file mode 100644 index 000000000..8549192f3 --- /dev/null +++ b/src/pages/[network]/accounts/[accountAddress].tsx @@ -0,0 +1,3 @@ +import AccountDetails from "lib/pages/account-details"; + +export default AccountDetails; diff --git a/src/pages/[network]/blocks/[height].tsx b/src/pages/[network]/blocks/[height].tsx new file mode 100644 index 000000000..8c5b053ec --- /dev/null +++ b/src/pages/[network]/blocks/[height].tsx @@ -0,0 +1,3 @@ +import BlockDetail from "lib/pages/block-details"; + +export default BlockDetail; diff --git a/src/pages/[network]/blocks/index.tsx b/src/pages/[network]/blocks/index.tsx new file mode 100644 index 000000000..6112f18ed --- /dev/null +++ b/src/pages/[network]/blocks/index.tsx @@ -0,0 +1,3 @@ +import BlocksPage from "lib/pages/blocks"; + +export default BlocksPage; diff --git a/src/pages/[network]/codes/[codeId].tsx b/src/pages/[network]/codes/[codeId].tsx new file mode 100644 index 000000000..5442c3a10 --- /dev/null +++ b/src/pages/[network]/codes/[codeId].tsx @@ -0,0 +1,3 @@ +import CodeDetails from "lib/pages/code-details"; + +export default CodeDetails; diff --git a/src/pages/[network]/codes/index.tsx b/src/pages/[network]/codes/index.tsx new file mode 100644 index 000000000..8d7e851c0 --- /dev/null +++ b/src/pages/[network]/codes/index.tsx @@ -0,0 +1,3 @@ +import RecentCodes from "lib/pages/recent-codes"; + +export default RecentCodes; diff --git a/src/pages/[network]/contract-lists/[slug].tsx b/src/pages/[network]/contract-lists/[slug].tsx new file mode 100644 index 000000000..cf30d4062 --- /dev/null +++ b/src/pages/[network]/contract-lists/[slug].tsx @@ -0,0 +1,3 @@ +import ContractsByList from "lib/pages/contract-list/slug"; + +export default ContractsByList; diff --git a/src/pages/[network]/contract-lists/index.tsx b/src/pages/[network]/contract-lists/index.tsx new file mode 100644 index 000000000..719d24905 --- /dev/null +++ b/src/pages/[network]/contract-lists/index.tsx @@ -0,0 +1,3 @@ +import AllContractListsPage from "lib/pages/contract-list"; + +export default AllContractListsPage; diff --git a/src/pages/[network]/contracts/[contractAddress].tsx b/src/pages/[network]/contracts/[contractAddress].tsx new file mode 100644 index 000000000..5776fddfd --- /dev/null +++ b/src/pages/[network]/contracts/[contractAddress].tsx @@ -0,0 +1,3 @@ +import ContractDetails from "lib/pages/contract-details"; + +export default ContractDetails; diff --git a/src/pages/[network]/my-codes.tsx b/src/pages/[network]/my-codes.tsx new file mode 100644 index 000000000..4a19ab5f8 --- /dev/null +++ b/src/pages/[network]/my-codes.tsx @@ -0,0 +1,3 @@ +import Codes from "lib/pages/codes"; + +export default Codes; diff --git a/src/pages/[network]/projects/[slug].tsx b/src/pages/[network]/projects/[slug].tsx new file mode 100644 index 000000000..cb35ef6f5 --- /dev/null +++ b/src/pages/[network]/projects/[slug].tsx @@ -0,0 +1,3 @@ +import ProjectDetail from "lib/pages/public-project/slug"; + +export default ProjectDetail; diff --git a/src/pages/[network]/projects/[slug]/[tab].tsx b/src/pages/[network]/projects/[slug]/[tab].tsx new file mode 100644 index 000000000..cb35ef6f5 --- /dev/null +++ b/src/pages/[network]/projects/[slug]/[tab].tsx @@ -0,0 +1,3 @@ +import ProjectDetail from "lib/pages/public-project/slug"; + +export default ProjectDetail; diff --git a/src/pages/[network]/projects/[slug]/index.tsx b/src/pages/[network]/projects/[slug]/index.tsx new file mode 100644 index 000000000..cb35ef6f5 --- /dev/null +++ b/src/pages/[network]/projects/[slug]/index.tsx @@ -0,0 +1,3 @@ +import ProjectDetail from "lib/pages/public-project/slug"; + +export default ProjectDetail; diff --git a/src/pages/[network]/projects/index.tsx b/src/pages/[network]/projects/index.tsx new file mode 100644 index 000000000..8308e5555 --- /dev/null +++ b/src/pages/[network]/projects/index.tsx @@ -0,0 +1,3 @@ +import { AllPublicProjectsPage } from "lib/pages/public-project"; + +export default AllPublicProjectsPage; diff --git a/src/pages/[network]/proposals/index.tsx b/src/pages/[network]/proposals/index.tsx new file mode 100644 index 000000000..6eaf2d6c4 --- /dev/null +++ b/src/pages/[network]/proposals/index.tsx @@ -0,0 +1,3 @@ +import Proposals from "lib/pages/proposals"; + +export default Proposals; diff --git a/src/pages/[network]/proposals/whitelist.tsx b/src/pages/[network]/proposals/whitelist.tsx new file mode 100644 index 000000000..cd4b54f1f --- /dev/null +++ b/src/pages/[network]/proposals/whitelist.tsx @@ -0,0 +1,3 @@ +import Whitelist from "lib/pages/proposal/whitelist"; + +export default Whitelist; diff --git a/src/pages/[network]/txs/[txHash].tsx b/src/pages/[network]/txs/[txHash].tsx new file mode 100644 index 000000000..fd2aa4abb --- /dev/null +++ b/src/pages/[network]/txs/[txHash].tsx @@ -0,0 +1,3 @@ +import TxDetails from "lib/pages/tx-details"; + +export default TxDetails; diff --git a/src/pages/[network]/txs/index.tsx b/src/pages/[network]/txs/index.tsx new file mode 100644 index 000000000..3d9d35789 --- /dev/null +++ b/src/pages/[network]/txs/index.tsx @@ -0,0 +1,3 @@ +import Txs from "lib/pages/txs"; + +export default Txs; diff --git a/src/pages/accounts/[accountAddress].tsx b/src/pages/accounts/[accountAddress].tsx new file mode 100644 index 000000000..8549192f3 --- /dev/null +++ b/src/pages/accounts/[accountAddress].tsx @@ -0,0 +1,3 @@ +import AccountDetails from "lib/pages/account-details"; + +export default AccountDetails; diff --git a/src/pages/blocks/[height].tsx b/src/pages/blocks/[height].tsx new file mode 100644 index 000000000..8c5b053ec --- /dev/null +++ b/src/pages/blocks/[height].tsx @@ -0,0 +1,3 @@ +import BlockDetail from "lib/pages/block-details"; + +export default BlockDetail; diff --git a/src/pages/blocks/index.tsx b/src/pages/blocks/index.tsx new file mode 100644 index 000000000..6112f18ed --- /dev/null +++ b/src/pages/blocks/index.tsx @@ -0,0 +1,3 @@ +import BlocksPage from "lib/pages/blocks"; + +export default BlocksPage; diff --git a/src/pages/codes/[codeId].tsx b/src/pages/codes/[codeId].tsx new file mode 100644 index 000000000..5442c3a10 --- /dev/null +++ b/src/pages/codes/[codeId].tsx @@ -0,0 +1,3 @@ +import CodeDetails from "lib/pages/code-details"; + +export default CodeDetails; diff --git a/src/pages/codes/index.tsx b/src/pages/codes/index.tsx new file mode 100644 index 000000000..8d7e851c0 --- /dev/null +++ b/src/pages/codes/index.tsx @@ -0,0 +1,3 @@ +import RecentCodes from "lib/pages/recent-codes"; + +export default RecentCodes; diff --git a/src/pages/contract-lists/[slug].tsx b/src/pages/contract-lists/[slug].tsx new file mode 100644 index 000000000..cf30d4062 --- /dev/null +++ b/src/pages/contract-lists/[slug].tsx @@ -0,0 +1,3 @@ +import ContractsByList from "lib/pages/contract-list/slug"; + +export default ContractsByList; diff --git a/src/pages/contract-lists/index.tsx b/src/pages/contract-lists/index.tsx new file mode 100644 index 000000000..719d24905 --- /dev/null +++ b/src/pages/contract-lists/index.tsx @@ -0,0 +1,3 @@ +import AllContractListsPage from "lib/pages/contract-list"; + +export default AllContractListsPage; diff --git a/src/pages/contracts/[contractAddress].tsx b/src/pages/contracts/[contractAddress].tsx new file mode 100644 index 000000000..5776fddfd --- /dev/null +++ b/src/pages/contracts/[contractAddress].tsx @@ -0,0 +1,3 @@ +import ContractDetails from "lib/pages/contract-details"; + +export default ContractDetails; diff --git a/src/pages/my-codes.tsx b/src/pages/my-codes.tsx new file mode 100644 index 000000000..4a19ab5f8 --- /dev/null +++ b/src/pages/my-codes.tsx @@ -0,0 +1,3 @@ +import Codes from "lib/pages/codes"; + +export default Codes; diff --git a/src/pages/projects/[slug].tsx b/src/pages/projects/[slug].tsx new file mode 100644 index 000000000..cb35ef6f5 --- /dev/null +++ b/src/pages/projects/[slug].tsx @@ -0,0 +1,3 @@ +import ProjectDetail from "lib/pages/public-project/slug"; + +export default ProjectDetail; diff --git a/src/pages/projects/[slug]/[tab].tsx b/src/pages/projects/[slug]/[tab].tsx new file mode 100644 index 000000000..cb35ef6f5 --- /dev/null +++ b/src/pages/projects/[slug]/[tab].tsx @@ -0,0 +1,3 @@ +import ProjectDetail from "lib/pages/public-project/slug"; + +export default ProjectDetail; diff --git a/src/pages/projects/[slug]/index.tsx b/src/pages/projects/[slug]/index.tsx new file mode 100644 index 000000000..cb35ef6f5 --- /dev/null +++ b/src/pages/projects/[slug]/index.tsx @@ -0,0 +1,3 @@ +import ProjectDetail from "lib/pages/public-project/slug"; + +export default ProjectDetail; diff --git a/src/pages/projects/index.tsx b/src/pages/projects/index.tsx new file mode 100644 index 000000000..8308e5555 --- /dev/null +++ b/src/pages/projects/index.tsx @@ -0,0 +1,3 @@ +import { AllPublicProjectsPage } from "lib/pages/public-project"; + +export default AllPublicProjectsPage; diff --git a/src/pages/proposals/whitelist.tsx b/src/pages/proposals/whitelist.tsx new file mode 100644 index 000000000..cd4b54f1f --- /dev/null +++ b/src/pages/proposals/whitelist.tsx @@ -0,0 +1,3 @@ +import Whitelist from "lib/pages/proposal/whitelist"; + +export default Whitelist; diff --git a/src/pages/txs/[txHash].tsx b/src/pages/txs/[txHash].tsx new file mode 100644 index 000000000..fd2aa4abb --- /dev/null +++ b/src/pages/txs/[txHash].tsx @@ -0,0 +1,3 @@ +import TxDetails from "lib/pages/tx-details"; + +export default TxDetails; diff --git a/src/pages/txs/index.tsx b/src/pages/txs/index.tsx new file mode 100644 index 000000000..3d9d35789 --- /dev/null +++ b/src/pages/txs/index.tsx @@ -0,0 +1,3 @@ +import Txs from "lib/pages/txs"; + +export default Txs; From b7457a1862a684b5c558b56b98ce99b35a24d061 Mon Sep 17 00:00:00 2001 From: poomthiti Date: Wed, 24 May 2023 18:34:25 +0700 Subject: [PATCH 4/6] fix: delete unnecessary path files --- src/lib/pages/public-project/slug.tsx | 6 +++--- src/pages/[network]/accounts/[accountAddress].tsx | 3 --- .../{account => accounts}/[accountAddress]/[tab].tsx | 0 .../{account => accounts}/[accountAddress]/index.tsx | 0 src/pages/[network]/public-project/[slug]/[tab].tsx | 3 --- src/pages/[network]/public-project/[slug]/index.tsx | 3 --- src/pages/accounts/[accountAddress].tsx | 3 --- src/pages/{account => accounts}/[accountAddress]/[tab].tsx | 0 src/pages/{account => accounts}/[accountAddress]/index.tsx | 0 src/pages/public-project/[slug]/[tab].tsx | 3 --- src/pages/public-project/[slug]/index.tsx | 3 --- 11 files changed, 3 insertions(+), 21 deletions(-) delete mode 100644 src/pages/[network]/accounts/[accountAddress].tsx rename src/pages/[network]/{account => accounts}/[accountAddress]/[tab].tsx (100%) rename src/pages/[network]/{account => accounts}/[accountAddress]/index.tsx (100%) delete mode 100644 src/pages/[network]/public-project/[slug]/[tab].tsx delete mode 100644 src/pages/[network]/public-project/[slug]/index.tsx delete mode 100644 src/pages/accounts/[accountAddress].tsx rename src/pages/{account => accounts}/[accountAddress]/[tab].tsx (100%) rename src/pages/{account => accounts}/[accountAddress]/index.tsx (100%) delete mode 100644 src/pages/public-project/[slug]/[tab].tsx delete mode 100644 src/pages/public-project/[slug]/index.tsx diff --git a/src/lib/pages/public-project/slug.tsx b/src/lib/pages/public-project/slug.tsx index 1c784c906..6bbc36d3f 100644 --- a/src/lib/pages/public-project/slug.tsx +++ b/src/lib/pages/public-project/slug.tsx @@ -38,7 +38,7 @@ const ProjectDetail = () => { const handleTabChange = (nextTab: TabIndex) => () => { if (nextTab === tab) return; navigate({ - pathname: "/public-projects/[slug]/[tab]", + pathname: "/projects/[slug]/[tab]", query: { slug, tab: nextTab, @@ -53,7 +53,7 @@ const ProjectDetail = () => { if (router.isReady) { if (!tab || !Object.values(TabIndex).includes(tab)) { navigate({ - pathname: "/public-projects/[slug]/[tab]", + pathname: "/projects/[slug]/[tab]", query: { slug, tab: TabIndex.Overview, @@ -73,7 +73,7 @@ const ProjectDetail = () => { - + Date: Thu, 20 Jul 2023 16:26:10 +0700 Subject: [PATCH 5/6] fix: add replace option to redirection --- src/lib/pages/account-details/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/pages/account-details/index.tsx b/src/lib/pages/account-details/index.tsx index b39af814d..929e16c88 100644 --- a/src/lib/pages/account-details/index.tsx +++ b/src/lib/pages/account-details/index.tsx @@ -103,6 +103,7 @@ const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { useEffect(() => { if (router.isReady && (!tab || !Object.values(TabIndex).includes(tab))) { navigate({ + replace: true, pathname: "/accounts/[accountAddress]/[tab]", query: { accountAddress, From 797032fbda537c3212984fb93d93347205028bf1 Mon Sep 17 00:00:00 2001 From: poomthiti Date: Thu, 20 Jul 2023 16:29:12 +0700 Subject: [PATCH 6/6] chore: add todo --- src/lib/pages/account-details/index.tsx | 1 + src/lib/pages/public-project/slug.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/src/lib/pages/account-details/index.tsx b/src/lib/pages/account-details/index.tsx index 929e16c88..bc69af68d 100644 --- a/src/lib/pages/account-details/index.tsx +++ b/src/lib/pages/account-details/index.tsx @@ -66,6 +66,7 @@ const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { const wasm = useWasmConfig({ shouldRedirect: false }); const navigate = useInternalNavigate(); const router = useRouter(); + // TODO: remove assertion later const tab = getFirstQueryParam(router.query.tab) as TabIndex; const { data: publicInfo } = usePublicProjectByAccountAddress(accountAddress); const { data: publicInfoBySlug } = usePublicProjectBySlug(publicInfo?.slug); diff --git a/src/lib/pages/public-project/slug.tsx b/src/lib/pages/public-project/slug.tsx index 10bee11c1..540306066 100644 --- a/src/lib/pages/public-project/slug.tsx +++ b/src/lib/pages/public-project/slug.tsx @@ -30,6 +30,7 @@ const ProjectDetail = () => { const router = useRouter(); const wasm = useWasmConfig({ shouldRedirect: false }); const navigate = useInternalNavigate(); + // TODO: remove assertion later const tab = getFirstQueryParam(router.query.tab) as TabIndex; const { publicCodes,