Skip to content

Commit 3ac49e4

Browse files
committed
mainnet table/testnet table conditional
1 parent ca15d30 commit 3ac49e4

File tree

1 file changed

+10
-119
lines changed

1 file changed

+10
-119
lines changed

src/features/feeds/components/FeedList.tsx

Lines changed: 10 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export const FeedList = ({
5656

5757
// Initialize state with the URL value
5858
const [currentNetwork, setCurrentNetwork] = useState(effectiveInitialNetwork)
59+
60+
// Track the selected network type (mainnet/testnet)
61+
const [selectedNetworkType, setSelectedNetworkType] = useState<"mainnet" | "testnet">("mainnet")
5962

6063
// Get network directly from URL or fall back to initialNetwork
6164
const getNetworkFromURL = () => {
@@ -297,6 +300,9 @@ export const FeedList = ({
297300

298301
// Network type change handler for testnet/mainnet switching
299302
function handleNetworkTypeChange(networkType: "mainnet" | "testnet", chain: Chain) {
303+
// Update the selected network type
304+
setSelectedNetworkType(networkType)
305+
300306
// Reset filters and pagination when switching network types
301307
setSearchValue("")
302308
setTestnetSearchValue("")
@@ -673,7 +679,7 @@ export const FeedList = ({
673679

674680
// Handle regular network processing
675681
return chainMetadata.processedData?.networks
676-
?.filter((network: { metadata: unknown[]; tags: string | string[] }) => {
682+
?.filter((network: { metadata: unknown[]; tags: string | string[]; networkType: string }) => {
677683
if (isDeprecating) {
678684
let foundDeprecated = false
679685
network.metadata?.forEach((feed: any) => {
@@ -695,7 +701,8 @@ export const FeedList = ({
695701

696702
if (isUSGovernmentMacroeconomicData) return network.tags?.includes("usGovernmentMacroeconomicData")
697703

698-
return true
704+
// Filter by selected network type (mainnet/testnet)
705+
return network.networkType === selectedNetworkType
699706
})
700707
.map((network: ChainNetwork) => {
701708
return (
@@ -759,7 +766,7 @@ export const FeedList = ({
759766
</div>
760767
</div>
761768
)}
762-
{network.networkType === "mainnet" ? (
769+
{selectedNetworkType === "mainnet" ? (
763770
<>
764771
{!isStreams && chain.l2SequencerFeed && (
765772
<p>
@@ -1147,122 +1154,6 @@ export const FeedList = ({
11471154
<strong>No data feeds are scheduled for deprecation at this time.</strong>
11481155
</div>
11491156
)}
1150-
1151-
{!isDeprecating &&
1152-
chainMetadata.processedData?.testnetProcessedData &&
1153-
chainMetadata.processedData?.testnetProcessedData.length > 0 && (
1154-
<SectionWrapper
1155-
title={isStreams ? streamsTestnetSectionTitle : "Testnet Feeds"}
1156-
depth={2}
1157-
updateTOC={true}
1158-
idOverride={
1159-
chainMetadata.processedData.testnetNetwork?.name?.toLowerCase().replace(/\s+/g, "-") || "testnet-feeds"
1160-
}
1161-
>
1162-
<div className={feedList.tableFilters}>
1163-
{!isStreams && isSmartData && (
1164-
<details class={feedList.filterDropdown_details}>
1165-
<summary class="text-200" onClick={() => setShowCategoriesDropdown((prev) => !prev)}>
1166-
SmartData Type
1167-
</summary>
1168-
<nav ref={wrapperRef} style={!showCategoriesDropdown ? { display: "none" } : {}}>
1169-
<ul>
1170-
{smartDataTypes.map((category) => (
1171-
<li>
1172-
<button onClick={() => handleCategorySelection(category.key)}>
1173-
<input
1174-
type="checkbox"
1175-
checked={selectedFeedCategories?.includes(category.key)}
1176-
readonly
1177-
style="cursor:pointer;"
1178-
/>
1179-
<span> {category.name}</span>
1180-
</button>
1181-
</li>
1182-
))}
1183-
</ul>
1184-
</nav>
1185-
</details>
1186-
)}
1187-
<div className={feedList.searchAndCheckbox}>
1188-
<form class={feedList.filterDropdown_search}>
1189-
<input
1190-
id="testnetSearch"
1191-
class={feedList.filterDropdown_searchInput}
1192-
placeholder="Search"
1193-
onInput={(event) => {
1194-
setTestnetSearchValue((event.target as HTMLInputElement).value)
1195-
setTestnetCurrentPage("1")
1196-
}}
1197-
/>
1198-
{testnetSearchValue && (
1199-
<button
1200-
type="button"
1201-
className={clsx(button.secondary, feedList.clearFilterBtn)}
1202-
onClick={() => {
1203-
setTestnetSearchValue("")
1204-
setTestnetCurrentPage("1")
1205-
const inputElement = document.getElementById("testnetSearch") as HTMLInputElement
1206-
if (inputElement) {
1207-
inputElement.value = ""
1208-
}
1209-
}}
1210-
aria-label="Clear search filter"
1211-
>
1212-
Clear filter
1213-
</button>
1214-
)}
1215-
</form>
1216-
{!isStreams && (
1217-
<label className={feedList.detailsLabel}>
1218-
<input
1219-
type="checkbox"
1220-
style="width:15px;height:15px;display:inline;margin-right:8px;"
1221-
checked={showExtraDetails}
1222-
onChange={() => setShowExtraDetails((old) => !old)}
1223-
/>
1224-
Show more details
1225-
</label>
1226-
)}
1227-
</div>
1228-
<div className={feedList.checkboxContainer}>
1229-
{!isStreams && isSmartData && (
1230-
<label className={feedList.detailsLabel}>
1231-
<input
1232-
type="checkbox"
1233-
style="width:15px;height:15px;display:inline;margin-right:8px;"
1234-
checked={showOnlyMVRFeedsTestnet}
1235-
onChange={() => {
1236-
setShowOnlyMVRFeedsTestnet((old) => !old)
1237-
setTestnetCurrentPage("1") // Reset to first page when filter changes
1238-
}}
1239-
/>
1240-
Show Multiple-Variable Response (MVR) feeds
1241-
</label>
1242-
)}
1243-
</div>
1244-
</div>
1245-
<TestnetTable
1246-
network={chainMetadata.processedData.testnetNetwork}
1247-
showExtraDetails={showExtraDetails}
1248-
dataFeedType={dataFeedType}
1249-
selectedFeedCategories={
1250-
Array.isArray(selectedFeedCategories)
1251-
? selectedFeedCategories
1252-
: selectedFeedCategories
1253-
? [selectedFeedCategories]
1254-
: []
1255-
}
1256-
showOnlyMVRFeeds={showOnlyMVRFeedsTestnet}
1257-
firstAddr={testnetFirstAddr}
1258-
lastAddr={testnetLastAddr}
1259-
addrPerPage={testnetAddrPerPage}
1260-
currentPage={Number(testnetCurrentPage)}
1261-
paginate={testnetPaginate}
1262-
searchValue={typeof testnetSearchValue === "string" ? testnetSearchValue : ""}
1263-
/>
1264-
</SectionWrapper>
1265-
)}
12661157
</SectionWrapper>
12671158
)
12681159
}

0 commit comments

Comments
 (0)