From eb54c417b0a685565edb976486c174e26dddee84 Mon Sep 17 00:00:00 2001 From: Iveta Date: Fri, 5 Apr 2024 16:21:37 -0400 Subject: [PATCH] Renamed Explore Endpoints to Endpoints --- package.json | 2 +- .../[[...pages]]/page.tsx | 26 ++-- .../layout.tsx | 6 +- src/components/MainNav.tsx | 4 +- .../layout/LayoutSidebarContent.tsx | 4 +- ...oreEndpointsPages.ts => endpointsPages.ts} | 122 +++++++++--------- src/constants/routes.ts | 92 ++++++------- .../{useExploreEndpoint.ts => useEndpoint.ts} | 7 +- src/store/createStore.ts | 36 +++--- src/styles/globals.scss | 2 +- tests/endpointsPage.test.ts | 14 +- 11 files changed, 155 insertions(+), 160 deletions(-) rename src/app/(sidebar)/{explore-endpoints => endpoints}/[[...pages]]/page.tsx (97%) rename src/app/(sidebar)/{explore-endpoints => endpoints}/layout.tsx (59%) rename src/constants/{exploreEndpointsPages.ts => endpointsPages.ts} (88%) rename src/query/{useExploreEndpoint.ts => useEndpoint.ts} (84%) diff --git a/package.json b/package.json index ba10109c..95a6b0bf 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "install-if-package-changed": "git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep --quiet yarn.lock && yarn install || exit 0", "prepare": "husky", "pre-commit": "yarn lint-staged", - "pre-push": "yarn lint:ts", + "pre-push": "yarn lint:ts && yarn test", "git-info": "rm -rf src/generated/ && mkdir src/generated/ && echo export default \"{\\\"commitHash\\\": \\\"$(git rev-parse --short HEAD)\\\", \\\"version\\\": \\\"$(git describe --tags --always)\\\"};\" > src/generated/gitInfo.ts" }, "dependencies": { diff --git a/src/app/(sidebar)/explore-endpoints/[[...pages]]/page.tsx b/src/app/(sidebar)/endpoints/[[...pages]]/page.tsx similarity index 97% rename from src/app/(sidebar)/explore-endpoints/[[...pages]]/page.tsx rename to src/app/(sidebar)/endpoints/[[...pages]]/page.tsx index 122b7171..0bb86c63 100644 --- a/src/app/(sidebar)/explore-endpoints/[[...pages]]/page.tsx +++ b/src/app/(sidebar)/endpoints/[[...pages]]/page.tsx @@ -29,8 +29,8 @@ import { parseJsonString } from "@/helpers/parseJsonString"; import { openUrl } from "@/helpers/openUrl"; import { Routes } from "@/constants/routes"; -import { EXPLORE_ENDPOINTS_PAGES_HORIZON } from "@/constants/exploreEndpointsPages"; -import { useExploreEndpoint } from "@/query/useExploreEndpoint"; +import { ENDPOINTS_PAGES_HORIZON } from "@/constants/endpointsPages"; +import { useEndpoint } from "@/query/useEndpoint"; import { AnyObject, AssetObject, @@ -38,11 +38,11 @@ import { Network, } from "@/types/types"; -export default function ExploreEndpoints() { +export default function Endpoints() { const pathname = usePathname(); - const currentPage = pathname.split(Routes.EXPLORE_ENDPOINTS)?.[1]; + const currentPage = pathname.split(Routes.ENDPOINTS)?.[1]; - const page = EXPLORE_ENDPOINTS_PAGES_HORIZON.navItems + const page = ENDPOINTS_PAGES_HORIZON.navItems .find((page) => pathname.includes(page.route)) ?.nestedItems?.find((i) => i.route === pathname); @@ -51,7 +51,7 @@ export default function ExploreEndpoints() { pageData?.requiredParams?.split(",") || [], ); - const { exploreEndpoints, network } = useStore(); + const { endpoints, network } = useStore(); const { params, currentEndpoint, @@ -60,7 +60,7 @@ export default function ExploreEndpoints() { updateCurrentEndpoint, updateNetwork, resetParams, - } = exploreEndpoints; + } = endpoints; const REGEX_TEMPLATE_SEARCH_PARAMS = /\{\?.+?\}/; const REGEX_TEMPLATE_SEARCH_PARAMS_VALUE = /(?<=\{\?).+?(?=\})/; @@ -122,7 +122,7 @@ export default function ExploreEndpoints() { refetch, isSuccess, isError, - } = useExploreEndpoint( + } = useEndpoint( requestUrl, // There is only one endpoint request for POST, using params directly for // simplicity. @@ -216,7 +216,7 @@ export default function ExploreEndpoints() { const resetQuery = useCallback( () => queryClient.resetQueries({ - queryKey: ["exploreEndpoint", "response"], + queryKey: ["endpoint", "response"], }), [queryClient], ); @@ -607,8 +607,8 @@ export default function ExploreEndpoints() { ); }; - if (pathname === Routes.EXPLORE_ENDPOINTS) { - return ; + if (pathname === Routes.ENDPOINTS) { + return ; } if (!pageData) { @@ -704,7 +704,7 @@ export default function ExploreEndpoints() { ); } -const ExploreEndpointsLandingPage = () => { +const EndpointsLandingPage = () => { const infoCards = [ { id: "stellar-rpc", @@ -731,7 +731,7 @@ const ExploreEndpointsLandingPage = () => {
- Explore Endpoints + Endpoints diff --git a/src/app/(sidebar)/explore-endpoints/layout.tsx b/src/app/(sidebar)/endpoints/layout.tsx similarity index 59% rename from src/app/(sidebar)/explore-endpoints/layout.tsx rename to src/app/(sidebar)/endpoints/layout.tsx index 3b18ddb8..9b8bcd20 100644 --- a/src/app/(sidebar)/explore-endpoints/layout.tsx +++ b/src/app/(sidebar)/endpoints/layout.tsx @@ -2,9 +2,9 @@ import React from "react"; import { LayoutSidebarContent } from "@/components/layout/LayoutSidebarContent"; -import { EXPLORE_ENDPOINTS_PAGES_HORIZON } from "@/constants/exploreEndpointsPages"; +import { ENDPOINTS_PAGES_HORIZON } from "@/constants/endpointsPages"; -export default function ExploreEndpointsTemplate({ +export default function EndpointsTemplate({ children, }: { children: React.ReactNode; @@ -12,7 +12,7 @@ export default function ExploreEndpointsTemplate({ return ( // TODO: add saved endpoints // TODO: add RPC endpoints - + {children} ); diff --git a/src/components/MainNav.tsx b/src/components/MainNav.tsx index cbfa7189..d3cb0667 100644 --- a/src/components/MainNav.tsx +++ b/src/components/MainNav.tsx @@ -18,8 +18,8 @@ const primaryNavLinks: NavLink[] = [ label: "Account", }, { - href: Routes.EXPLORE_ENDPOINTS, - label: "Explore Endpoints", + href: Routes.ENDPOINTS, + label: "Endpoints", }, { href: Routes.BUILD_TRANSACTION, diff --git a/src/components/layout/LayoutSidebarContent.tsx b/src/components/layout/LayoutSidebarContent.tsx index b12fb568..591522b1 100644 --- a/src/components/layout/LayoutSidebarContent.tsx +++ b/src/components/layout/LayoutSidebarContent.tsx @@ -91,8 +91,8 @@ export const LayoutSidebarContent = ({ const Link = ({ item, pathname }: { item: SidebarLink; pathname: string }) => { const isSelectedParent = item.nestedItems?.length - ? pathname?.split(Routes.EXPLORE_ENDPOINTS)?.[1]?.split("/")?.[1] === - item.route?.split(Routes.EXPLORE_ENDPOINTS)?.[1]?.split("/")?.[1] + ? pathname?.split(Routes.ENDPOINTS)?.[1]?.split("/")?.[1] === + item.route?.split(Routes.ENDPOINTS)?.[1]?.split("/")?.[1] : false; const [isExpanded, setIsExpanded] = useState(isSelectedParent); diff --git a/src/constants/exploreEndpointsPages.ts b/src/constants/endpointsPages.ts similarity index 88% rename from src/constants/exploreEndpointsPages.ts rename to src/constants/endpointsPages.ts index 5b6b6472..116d1691 100644 --- a/src/constants/exploreEndpointsPages.ts +++ b/src/constants/endpointsPages.ts @@ -1,7 +1,7 @@ import { Routes } from "@/constants/routes"; import { AnyObject } from "@/types/types"; -type ExploreEndpointsPagesProps = { +type EndpointsPagesProps = { instruction: string; navItems: { route: Routes; @@ -22,15 +22,15 @@ type ExploreEndpointsPagesProps = { }[]; }; -export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { +export const ENDPOINTS_PAGES_HORIZON: EndpointsPagesProps = { instruction: "Horizon Endpoints", navItems: [ { - route: Routes.EXPLORE_ENDPOINTS_ACCOUNTS, + route: Routes.ENDPOINTS_ACCOUNTS, label: "Accounts", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_ACCOUNTS, + route: Routes.ENDPOINTS_ACCOUNTS, label: "All Accounts", form: { docsUrl: @@ -50,7 +50,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_ACCOUNTS_SINGLE, + route: Routes.ENDPOINTS_ACCOUNTS_SINGLE, label: "Single Account", form: { docsUrl: @@ -65,11 +65,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_ASSETS, + route: Routes.ENDPOINTS_ASSETS, label: "Assets", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_ASSETS, + route: Routes.ENDPOINTS_ASSETS, label: "All Assets", form: { docsUrl: @@ -85,11 +85,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_CLAIMABLE_BALANCES, + route: Routes.ENDPOINTS_CLAIMABLE_BALANCES, label: "Claimable Balances", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_CLAIMABLE_BALANCES, + route: Routes.ENDPOINTS_CLAIMABLE_BALANCES, label: "All Claimable Balances", form: { docsUrl: @@ -103,7 +103,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_CLAIMABLE_BALANCES_SINGLE, + route: Routes.ENDPOINTS_CLAIMABLE_BALANCES_SINGLE, label: "Single Claimable Balance", form: { docsUrl: @@ -118,11 +118,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_EFFECTS, + route: Routes.ENDPOINTS_EFFECTS, label: "Effects", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_EFFECTS, + route: Routes.ENDPOINTS_EFFECTS, label: "All Effects", form: { docsUrl: @@ -135,7 +135,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_EFFECTS_ACCOUNT, + route: Routes.ENDPOINTS_EFFECTS_ACCOUNT, label: "Effects for Account", form: { docsUrl: @@ -149,7 +149,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_EFFECTS_LEDGER, + route: Routes.ENDPOINTS_EFFECTS_LEDGER, label: "Effects for Ledger", form: { docsUrl: @@ -163,7 +163,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_EFFECTS_LIQUIDITY_POOL, + route: Routes.ENDPOINTS_EFFECTS_LIQUIDITY_POOL, label: "Effects for Liquidity Pool", form: { docsUrl: @@ -177,7 +177,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_EFFECTS_OPERATION, + route: Routes.ENDPOINTS_EFFECTS_OPERATION, label: "Effects for Operation", form: { docsUrl: @@ -191,7 +191,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_EFFECTS_TRANSACTION, + route: Routes.ENDPOINTS_EFFECTS_TRANSACTION, label: "Effects for Transaction", form: { docsUrl: @@ -207,11 +207,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_FEE_STATS, + route: Routes.ENDPOINTS_FEE_STATS, label: "Fee Stats", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_FEE_STATS, + route: Routes.ENDPOINTS_FEE_STATS, label: "All Fee Stats", form: { docsUrl: @@ -226,11 +226,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_LEDGERS, + route: Routes.ENDPOINTS_LEDGERS, label: "Ledgers", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_LEDGERS, + route: Routes.ENDPOINTS_LEDGERS, label: "All Ledgers", form: { docsUrl: @@ -243,7 +243,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_LEDGERS_SINGLE, + route: Routes.ENDPOINTS_LEDGERS_SINGLE, label: "Single Ledger", form: { docsUrl: @@ -258,11 +258,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_LIQUIDITY_POOLS, + route: Routes.ENDPOINTS_LIQUIDITY_POOLS, label: "Liquidity Pools", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_LIQUIDITY_POOLS, + route: Routes.ENDPOINTS_LIQUIDITY_POOLS, label: "All Liquidity Pools", form: { docsUrl: @@ -276,7 +276,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_LIQUIDITY_POOLS_SINGLE, + route: Routes.ENDPOINTS_LIQUIDITY_POOLS_SINGLE, label: "Single Liquidity Pool", form: { docsUrl: @@ -291,11 +291,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_OFFERS, + route: Routes.ENDPOINTS_OFFERS, label: "Offers", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_OFFERS, + route: Routes.ENDPOINTS_OFFERS, label: "All Offers", form: { docsUrl: @@ -319,7 +319,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_OFFERS_SINGLE, + route: Routes.ENDPOINTS_OFFERS_SINGLE, label: "Single Offer", form: { docsUrl: @@ -332,7 +332,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_OFFERS_ACCOUNT, + route: Routes.ENDPOINTS_OFFERS_ACCOUNT, label: "Offers for Account", form: { docsUrl: @@ -348,11 +348,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_OPERATIONS, + route: Routes.ENDPOINTS_OPERATIONS, label: "Operations", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_OPERATIONS, + route: Routes.ENDPOINTS_OPERATIONS, label: "All Operations", form: { docsUrl: @@ -366,7 +366,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_OPERATIONS_SINGLE, + route: Routes.ENDPOINTS_OPERATIONS_SINGLE, label: "Single Operation", form: { docsUrl: @@ -379,7 +379,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_OPERATIONS_ACCOUNT, + route: Routes.ENDPOINTS_OPERATIONS_ACCOUNT, label: "Operations for Account", form: { docsUrl: @@ -393,7 +393,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_OPERATIONS_LEDGER, + route: Routes.ENDPOINTS_OPERATIONS_LEDGER, label: "Operations for Ledger", form: { docsUrl: @@ -407,7 +407,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_OPERATIONS_LIQUIDITY_POOL, + route: Routes.ENDPOINTS_OPERATIONS_LIQUIDITY_POOL, label: "Operations for Liquidity Pool", form: { docsUrl: @@ -421,7 +421,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_OPERATIONS_TRANSACTION, + route: Routes.ENDPOINTS_OPERATIONS_TRANSACTION, label: "Operations for Transaction", form: { docsUrl: @@ -437,11 +437,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_ORDER_BOOK_DETAILS, + route: Routes.ENDPOINTS_ORDER_BOOK_DETAILS, label: "Order Book", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_ORDER_BOOK_DETAILS, + route: Routes.ENDPOINTS_ORDER_BOOK_DETAILS, label: "Details", form: { docsUrl: @@ -476,11 +476,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_PATHS, + route: Routes.ENDPOINTS_PATHS, label: "Paths", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_PATHS, + route: Routes.ENDPOINTS_PATHS, label: "Find Payment Paths", form: { docsUrl: @@ -507,7 +507,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_PATHS_STRICT_RECEIVE, + route: Routes.ENDPOINTS_PATHS_STRICT_RECEIVE, label: "Find Strict Receive Payment Paths", form: { docsUrl: @@ -534,7 +534,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_PATHS_STRICT_SEND, + route: Routes.ENDPOINTS_PATHS_STRICT_SEND, label: "Find Strict Send Payment Paths", form: { docsUrl: @@ -562,11 +562,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_PAYMENTS, + route: Routes.ENDPOINTS_PAYMENTS, label: "Payments", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_PAYMENTS, + route: Routes.ENDPOINTS_PAYMENTS, label: "All Payments", form: { docsUrl: @@ -580,7 +580,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_PAYMENTS_ACCOUNT, + route: Routes.ENDPOINTS_PAYMENTS_ACCOUNT, label: "Payments for Account", form: { docsUrl: @@ -594,7 +594,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_PAYMENTS_LEDGER, + route: Routes.ENDPOINTS_PAYMENTS_LEDGER, label: "Payments for Ledger", form: { docsUrl: @@ -608,7 +608,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_PAYMENTS_TRANSACTION, + route: Routes.ENDPOINTS_PAYMENTS_TRANSACTION, label: "Payments for Transaction", form: { docsUrl: @@ -625,11 +625,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_TRADE_AGGREGATIONS, + route: Routes.ENDPOINTS_TRADE_AGGREGATIONS, label: "Trade Aggregations", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_TRADE_AGGREGATIONS, + route: Routes.ENDPOINTS_TRADE_AGGREGATIONS, label: "All Trade Aggregations", form: { docsUrl: @@ -664,11 +664,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_TRADES, + route: Routes.ENDPOINTS_TRADES, label: "Trades", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_TRADES, + route: Routes.ENDPOINTS_TRADES, label: "All Trades", form: { docsUrl: @@ -701,7 +701,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_TRADES_ACCOUNT, + route: Routes.ENDPOINTS_TRADES_ACCOUNT, label: "Trades for Account", form: { docsUrl: @@ -715,7 +715,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_TRADES_LIQUIDITY_POOL, + route: Routes.ENDPOINTS_TRADES_LIQUIDITY_POOL, label: "Trades for Liquidity Pool", form: { docsUrl: @@ -729,7 +729,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_TRADES_OFFER, + route: Routes.ENDPOINTS_TRADES_OFFER, label: "Trades for Offer", form: { docsUrl: @@ -745,11 +745,11 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { ], }, { - route: Routes.EXPLORE_ENDPOINTS_TRANSACTIONS, + route: Routes.ENDPOINTS_TRANSACTIONS, label: "Transactions", nestedItems: [ { - route: Routes.EXPLORE_ENDPOINTS_TRANSACTIONS, + route: Routes.ENDPOINTS_TRANSACTIONS, label: "All Transactions", form: { docsUrl: @@ -763,7 +763,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_TRANSACTIONS_SINGLE, + route: Routes.ENDPOINTS_TRANSACTIONS_SINGLE, label: "Single Transaction", form: { docsUrl: @@ -776,7 +776,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_TRANSACTIONS_POST, + route: Routes.ENDPOINTS_TRANSACTIONS_POST, label: "Post Transaction", form: { docsUrl: @@ -789,7 +789,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_TRANSACTIONS_ACCOUNT, + route: Routes.ENDPOINTS_TRANSACTIONS_ACCOUNT, label: "Transactions for Account", form: { docsUrl: @@ -803,7 +803,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_TRANSACTIONS_LEDGER, + route: Routes.ENDPOINTS_TRANSACTIONS_LEDGER, label: "Transactions for Ledger", form: { docsUrl: @@ -817,7 +817,7 @@ export const EXPLORE_ENDPOINTS_PAGES_HORIZON: ExploreEndpointsPagesProps = { }, }, { - route: Routes.EXPLORE_ENDPOINTS_TRANSACTIONS_LIQUIDITY_POOL, + route: Routes.ENDPOINTS_TRANSACTIONS_LIQUIDITY_POOL, label: "Transactions for Liquidity Pool", form: { docsUrl: diff --git a/src/constants/routes.ts b/src/constants/routes.ts index 29d91d43..f8e6b3b1 100644 --- a/src/constants/routes.ts +++ b/src/constants/routes.ts @@ -7,52 +7,52 @@ export enum Routes { ACCOUNT_FUND = "/account/fund", ACCOUNT_CREATE_MUXED = "/account/muxed-create", ACCOUNT_PARSE_MUXED = "/account/muxed-parse", - // Explore Endpoints - EXPLORE_ENDPOINTS = "/explore-endpoints", - EXPLORE_ENDPOINTS_ACCOUNTS = "/explore-endpoints/accounts", - EXPLORE_ENDPOINTS_ACCOUNTS_SINGLE = "/explore-endpoints/accounts/single", - EXPLORE_ENDPOINTS_ASSETS = "/explore-endpoints/assets", - EXPLORE_ENDPOINTS_CLAIMABLE_BALANCES = "/explore-endpoints/claimable-balances", - EXPLORE_ENDPOINTS_CLAIMABLE_BALANCES_SINGLE = "/explore-endpoints/claimable-balances/single", - EXPLORE_ENDPOINTS_EFFECTS = "/explore-endpoints/effects", - EXPLORE_ENDPOINTS_EFFECTS_ACCOUNT = "/explore-endpoints/effects/account", - EXPLORE_ENDPOINTS_EFFECTS_LEDGER = "/explore-endpoints/effects/ledger", - EXPLORE_ENDPOINTS_EFFECTS_LIQUIDITY_POOL = "/explore-endpoints/effects/liquidity-pool", - EXPLORE_ENDPOINTS_EFFECTS_OPERATION = "/explore-endpoints/effects/operation", - EXPLORE_ENDPOINTS_EFFECTS_TRANSACTION = "/explore-endpoints/effects/transaction", - EXPLORE_ENDPOINTS_FEE_STATS = "/explore-endpoints/fee-stats", - EXPLORE_ENDPOINTS_LEDGERS = "/explore-endpoints/ledgers", - EXPLORE_ENDPOINTS_LEDGERS_SINGLE = "/explore-endpoints/ledgers/single", - EXPLORE_ENDPOINTS_LIQUIDITY_POOLS = "/explore-endpoints/liquidity-pools", - EXPLORE_ENDPOINTS_LIQUIDITY_POOLS_SINGLE = "/explore-endpoints/liquidity-pools/single", - EXPLORE_ENDPOINTS_OFFERS = "/explore-endpoints/offers", - EXPLORE_ENDPOINTS_OFFERS_SINGLE = "/explore-endpoints/offers/single", - EXPLORE_ENDPOINTS_OFFERS_ACCOUNT = "/explore-endpoints/offers/account", - EXPLORE_ENDPOINTS_OPERATIONS = "/explore-endpoints/operations", - EXPLORE_ENDPOINTS_OPERATIONS_SINGLE = "/explore-endpoints/operations/single", - EXPLORE_ENDPOINTS_OPERATIONS_ACCOUNT = "/explore-endpoints/operations/account", - EXPLORE_ENDPOINTS_OPERATIONS_LEDGER = "/explore-endpoints/operations/ledger", - EXPLORE_ENDPOINTS_OPERATIONS_LIQUIDITY_POOL = "/explore-endpoints/operations/liquidity-pool", - EXPLORE_ENDPOINTS_OPERATIONS_TRANSACTION = "/explore-endpoints/operations/transaction", - EXPLORE_ENDPOINTS_ORDER_BOOK_DETAILS = "/explore-endpoints/order-book/details", - EXPLORE_ENDPOINTS_PATHS = "/explore-endpoints/paths", - EXPLORE_ENDPOINTS_PATHS_STRICT_RECEIVE = "/explore-endpoints/paths/strict-receive", - EXPLORE_ENDPOINTS_PATHS_STRICT_SEND = "/explore-endpoints/paths/strict-send", - EXPLORE_ENDPOINTS_PAYMENTS = "/explore-endpoints/payments", - EXPLORE_ENDPOINTS_PAYMENTS_ACCOUNT = "/explore-endpoints/payments/account", - EXPLORE_ENDPOINTS_PAYMENTS_LEDGER = "/explore-endpoints/payments/ledger", - EXPLORE_ENDPOINTS_PAYMENTS_TRANSACTION = "/explore-endpoints/payments/transaction", - EXPLORE_ENDPOINTS_TRADE_AGGREGATIONS = "/explore-endpoints/trade-aggregations", - EXPLORE_ENDPOINTS_TRADES = "/explore-endpoints/trades", - EXPLORE_ENDPOINTS_TRADES_ACCOUNT = "/explore-endpoints/trades/account", - EXPLORE_ENDPOINTS_TRADES_LIQUIDITY_POOL = "/explore-endpoints/trades/liquidity-pool", - EXPLORE_ENDPOINTS_TRADES_OFFER = "/explore-endpoints/trades/offer", - EXPLORE_ENDPOINTS_TRANSACTIONS = "/explore-endpoints/transactions", - EXPLORE_ENDPOINTS_TRANSACTIONS_SINGLE = "/explore-endpoints/transactions/single", - EXPLORE_ENDPOINTS_TRANSACTIONS_POST = "/explore-endpoints/transactions/post", - EXPLORE_ENDPOINTS_TRANSACTIONS_ACCOUNT = "/explore-endpoints/transactions/account", - EXPLORE_ENDPOINTS_TRANSACTIONS_LEDGER = "/explore-endpoints/transactions/ledger", - EXPLORE_ENDPOINTS_TRANSACTIONS_LIQUIDITY_POOL = "/explore-endpoints/transactions/liquidity-pool", + // Endpoints + ENDPOINTS = "/endpoints", + ENDPOINTS_ACCOUNTS = "/endpoints/accounts", + ENDPOINTS_ACCOUNTS_SINGLE = "/endpoints/accounts/single", + ENDPOINTS_ASSETS = "/endpoints/assets", + ENDPOINTS_CLAIMABLE_BALANCES = "/endpoints/claimable-balances", + ENDPOINTS_CLAIMABLE_BALANCES_SINGLE = "/endpoints/claimable-balances/single", + ENDPOINTS_EFFECTS = "/endpoints/effects", + ENDPOINTS_EFFECTS_ACCOUNT = "/endpoints/effects/account", + ENDPOINTS_EFFECTS_LEDGER = "/endpoints/effects/ledger", + ENDPOINTS_EFFECTS_LIQUIDITY_POOL = "/endpoints/effects/liquidity-pool", + ENDPOINTS_EFFECTS_OPERATION = "/endpoints/effects/operation", + ENDPOINTS_EFFECTS_TRANSACTION = "/endpoints/effects/transaction", + ENDPOINTS_FEE_STATS = "/endpoints/fee-stats", + ENDPOINTS_LEDGERS = "/endpoints/ledgers", + ENDPOINTS_LEDGERS_SINGLE = "/endpoints/ledgers/single", + ENDPOINTS_LIQUIDITY_POOLS = "/endpoints/liquidity-pools", + ENDPOINTS_LIQUIDITY_POOLS_SINGLE = "/endpoints/liquidity-pools/single", + ENDPOINTS_OFFERS = "/endpoints/offers", + ENDPOINTS_OFFERS_SINGLE = "/endpoints/offers/single", + ENDPOINTS_OFFERS_ACCOUNT = "/endpoints/offers/account", + ENDPOINTS_OPERATIONS = "/endpoints/operations", + ENDPOINTS_OPERATIONS_SINGLE = "/endpoints/operations/single", + ENDPOINTS_OPERATIONS_ACCOUNT = "/endpoints/operations/account", + ENDPOINTS_OPERATIONS_LEDGER = "/endpoints/operations/ledger", + ENDPOINTS_OPERATIONS_LIQUIDITY_POOL = "/endpoints/operations/liquidity-pool", + ENDPOINTS_OPERATIONS_TRANSACTION = "/endpoints/operations/transaction", + ENDPOINTS_ORDER_BOOK_DETAILS = "/endpoints/order-book/details", + ENDPOINTS_PATHS = "/endpoints/paths", + ENDPOINTS_PATHS_STRICT_RECEIVE = "/endpoints/paths/strict-receive", + ENDPOINTS_PATHS_STRICT_SEND = "/endpoints/paths/strict-send", + ENDPOINTS_PAYMENTS = "/endpoints/payments", + ENDPOINTS_PAYMENTS_ACCOUNT = "/endpoints/payments/account", + ENDPOINTS_PAYMENTS_LEDGER = "/endpoints/payments/ledger", + ENDPOINTS_PAYMENTS_TRANSACTION = "/endpoints/payments/transaction", + ENDPOINTS_TRADE_AGGREGATIONS = "/endpoints/trade-aggregations", + ENDPOINTS_TRADES = "/endpoints/trades", + ENDPOINTS_TRADES_ACCOUNT = "/endpoints/trades/account", + ENDPOINTS_TRADES_LIQUIDITY_POOL = "/endpoints/trades/liquidity-pool", + ENDPOINTS_TRADES_OFFER = "/endpoints/trades/offer", + ENDPOINTS_TRANSACTIONS = "/endpoints/transactions", + ENDPOINTS_TRANSACTIONS_SINGLE = "/endpoints/transactions/single", + ENDPOINTS_TRANSACTIONS_POST = "/endpoints/transactions/post", + ENDPOINTS_TRANSACTIONS_ACCOUNT = "/endpoints/transactions/account", + ENDPOINTS_TRANSACTIONS_LEDGER = "/endpoints/transactions/ledger", + ENDPOINTS_TRANSACTIONS_LIQUIDITY_POOL = "/endpoints/transactions/liquidity-pool", // Transactions BUILD_TRANSACTION = "/transaction/build", SIGN_TRANSACTION = "/transaction/sign", diff --git a/src/query/useExploreEndpoint.ts b/src/query/useEndpoint.ts similarity index 84% rename from src/query/useExploreEndpoint.ts rename to src/query/useEndpoint.ts index 279ffbaa..e3a66246 100644 --- a/src/query/useExploreEndpoint.ts +++ b/src/query/useEndpoint.ts @@ -1,12 +1,9 @@ import { useQuery } from "@tanstack/react-query"; import { AnyObject } from "@/types/types"; -export const useExploreEndpoint = ( - requestUrl: string, - postData?: AnyObject, -) => { +export const useEndpoint = (requestUrl: string, postData?: AnyObject) => { const query = useQuery({ - queryKey: ["exploreEndpoint", "response", postData], + queryKey: ["endpoint", "response", postData], queryFn: async () => { const endpointResponse = await fetch( requestUrl, diff --git a/src/store/createStore.ts b/src/store/createStore.ts index c187aef5..9823c20e 100644 --- a/src/store/createStore.ts +++ b/src/store/createStore.ts @@ -26,8 +26,8 @@ export interface Store { reset: () => void; }; - // Explore Endpoints - exploreEndpoints: { + // Endpoints + endpoints: { network: Network | EmptyObj; currentEndpoint: string | undefined; params: AnyObject; @@ -44,7 +44,7 @@ interface CreateStoreOptions { } // Initial states -const initExploreEndpointState = { +const initEndpointState = { network: {}, currentEndpoint: undefined, params: {}, @@ -65,9 +65,9 @@ export const createStore = (options: CreateStoreOptions) => resetStoredData: () => set((state) => { // Add stores that need global reset - state.exploreEndpoints = { - ...state.exploreEndpoints, - ...initExploreEndpointState, + state.endpoints = { + ...state.endpoints, + ...initEndpointState, }; }), // Account @@ -111,33 +111,33 @@ export const createStore = (options: CreateStoreOptions) => state.account.publicKey = ""; }), }, - // Explore Endpoints - exploreEndpoints: { - ...initExploreEndpointState, + // Endpoints + endpoints: { + ...initEndpointState, updateNetwork: (network: Network) => set((state) => { - state.exploreEndpoints.network = network; + state.endpoints.network = network; }), updateCurrentEndpoint: (endpoint: string) => set((state) => { - state.exploreEndpoints.currentEndpoint = endpoint; + state.endpoints.currentEndpoint = endpoint; }), updateParams: (params: AnyObject) => set((state) => { - state.exploreEndpoints.params = sanitizeObject({ - ...state.exploreEndpoints.params, + state.endpoints.params = sanitizeObject({ + ...state.endpoints.params, ...params, }); }), resetParams: () => set((state) => { - state.exploreEndpoints.params = {}; + state.endpoints.params = {}; }), reset: () => set((state) => { - state.exploreEndpoints = { - ...state.exploreEndpoints, - ...initExploreEndpointState, + state.endpoints = { + ...state.endpoints, + ...initEndpointState, }; }), }, @@ -149,7 +149,7 @@ export const createStore = (options: CreateStoreOptions) => return { network: true, account: false, - exploreEndpoints: { + endpoints: { params: true, isStreaming: true, }, diff --git a/src/styles/globals.scss b/src/styles/globals.scss index 172eaa9f..a71b2792 100644 --- a/src/styles/globals.scss +++ b/src/styles/globals.scss @@ -380,7 +380,7 @@ line-height: pxToRem(20px); } -// Endpoint Explorer +// Endpoints .Endpoints { &__urlBar { display: flex; diff --git a/tests/endpointsPage.test.ts b/tests/endpointsPage.test.ts index ac2aca15..277a7dab 100644 --- a/tests/endpointsPage.test.ts +++ b/tests/endpointsPage.test.ts @@ -2,11 +2,11 @@ import { test, expect } from "@playwright/test"; test.describe("Endpoints page", () => { test.beforeEach(async ({ page }) => { - await page.goto("http://localhost:3000/explore-endpoints"); + await page.goto("http://localhost:3000/endpoints"); }); test("Loads", async ({ page }) => { - await expect(page.locator("h1")).toHaveText("Explore Endpoints"); + await expect(page.locator("h1")).toHaveText("Endpoints"); }); test("Renders info cards", async ({ page }) => { @@ -53,7 +53,7 @@ test.describe("Endpoints page", () => { .filter({ hasText: "Accounts" }); const parent = sidebar.getByTestId( - "endpoints-sidebar/explore-endpoints/accounts", + "endpoints-sidebar/endpoints/accounts", ); await expect(parent).toBeVisible(); @@ -73,13 +73,13 @@ test.describe("Endpoints page", () => { linksContainer .getByTestId("endpoints-sidebar-link") .filter({ hasText: "All Accounts" }), - ).toHaveAttribute("href", "/explore-endpoints/accounts"); + ).toHaveAttribute("href", "/endpoints/accounts"); }); }); test.describe("All Accounts", () => { test.beforeEach(async ({ page }) => { - await page.goto("http://localhost:3000/explore-endpoints/accounts"); + await page.goto("http://localhost:3000/endpoints/accounts"); }); test("Page loads with correct title and view docs link", async ({ @@ -125,9 +125,7 @@ test.describe("Endpoints page", () => { test.describe("Effects for Account", () => { test.beforeEach(async ({ page }) => { - await page.goto( - "http://localhost:3000/explore-endpoints/effects/account", - ); + await page.goto("http://localhost:3000/endpoints/effects/account"); }); test("Page loads with correct title and view docs link", async ({