Skip to content

Commit

Permalink
Merge pull request #3 from indexnetwork/api-integration
Browse files Browse the repository at this point in the history
API integration
  • Loading branch information
confxsd authored Jan 17, 2024
2 parents 33722f3 + 0b9775c commit d57bb4c
Show file tree
Hide file tree
Showing 6 changed files with 456 additions and 520 deletions.
52 changes: 24 additions & 28 deletions web-app/src/components/site/indexes/SearchIndexes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Col from "components/layout/base/Grid/Col";
import FlexRow from "components/layout/base/Grid/FlexRow";
import React, { useCallback } from "react";
import React, { useCallback, useMemo } from "react";
import List from "components/base/List";
import { useRouter } from "next/router";
import { Indexes } from "types/entity";
import InfiniteScroll from "react-infinite-scroller";
import { Tabs } from "components/base/Tabs";
import TabPane from "components/base/Tabs/TabPane";

Expand All @@ -20,10 +19,9 @@ const SearchIndexes: React.VFC<SearchIndexesProps> = () => {
viewedProfile,
section,
indexes,
getIndexes,
} = useApp();

const { did, indexId } = router.query;
const { indexId } = router.query;

const handleTabChange = useCallback((tabClickValue: string) => {
if (viewedProfile && tabClickValue) {
Expand All @@ -34,39 +32,37 @@ const SearchIndexes: React.VFC<SearchIndexesProps> = () => {
}
}, [viewedProfile]);

const sortIndexes = (items: Indexes[]) => items.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
const sectionIndexes = useMemo(() => {
if (section === 'all') {
return indexes;
} else {
return indexes.filter(
section === 'owner' ? i => i.isOwner === true : i => i.isStarred === true
);
}
}, [indexes, section]);

return <>
<FlexRow className={"mr-6 pb-4"}>
<Col className="idxflex-grow-1">
<Tabs destroyInactiveTabPane={false} theme={"rounded"} activeKey={section} onTabChange={handleTabChange}>
<TabPane enabled={true} tabKey={"all"} title={`All Indexes`} />
<TabPane enabled={true} tabKey={"owner"} total={indexes.owner?.totalCount} title={`Owned`} />
<TabPane enabled={true} tabKey={"starred"} total={indexes.starred?.totalCount} title={`Starred`} />
<TabPane enabled={true} tabKey={"owner"} total={indexes.filter(i => i.isOwner === true)?.length} title={`Owned`} />
<TabPane enabled={true} tabKey={"starred"} total={indexes.filter(i => i.isStarred === true)?.length} title={`Starred`} />
</Tabs>
</Col>
</FlexRow>
<FlexRow className={"scrollable-area index-list pr-6"}>
{ (indexes[section].totalCount > 0) ? <>
<InfiniteScroll
key={section}
initialLoad={false}
hasMore={indexes[section].hasMore}
loadMore={getIndexes}
useWindow={false}
marginHeight={50}
className={"idxflex-grow-1"}
>
<List
data={sortIndexes(indexes[section].indexes!) || []}
render={(itm: Indexes) => <IndexItem
index={itm}
selected={itm.id === indexId}
/>}
divided={false}
/>
</InfiniteScroll>
</> :
<FlexRow className={"scrollable-area index-list pr-6 idxflex-grow-1"}>
{ (sectionIndexes.length > 0) ? <div className={"idxflex-grow-1"}>
<List
data={sectionIndexes}
render={(itm: Indexes) => <IndexItem
index={itm}
selected={itm.id === indexId}
/>}
divided={false}
/>
</div> :
<Text fontWeight={500} style={{
color: "var(--gray-4)",
textAlign: "center",
Expand Down
176 changes: 88 additions & 88 deletions web-app/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,92 +1,92 @@
export const appConfig = {
baseUrl: "https://index.network/",
apiUrl: "https://index.network/api",
ipfsProxy: "https://indexas.infura-ipfs.io/ipfs",
ipfsInfura: "http://localhost:3001/avatar",
defaultCID: "QmRisjM1uZ18wUE22XsREDYEXYdsVuZ6P312XWcMj3Apys", // Empty.
testNetwork: {
chainId: "0x2ac49",
chainName: "Chronicle - Lit Protocol Testnet",
nativeCurrency: {
name: "LIT",
symbol: "LIT",
decimals: 18,
},
rpcUrls: ["https://chain-rpc.litprotocol.com/http"],
blockExplorerUrls: ["https://chain.litprotocol.com"],
},
chains: {
ethereum: {
value: "ethereum",
label: "Ethereum",
abbreviation: "eth",
logo: "ethLogo.svg",
chainId: 1,
},
polygon: {
value: "polygon",
label: "Polygon",
abbreviation: "matic",
logo: "polygonLogo.svg",
chainId: 137,
baseUrl: "https://index.network/",
apiUrl: "https://dev.index.network/api", // TODO: handle better
ipfsProxy: "https://indexas.infura-ipfs.io/ipfs",
ipfsInfura: "http://localhost:3001/avatar",
defaultCID: "QmZQ42inuRBMLh65UfUCGhMBWhHCsZtGVEKttV16mbrKrj", // Empty.
testNetwork: {
chainId: "0x2ac49",
chainName: "Chronicle - Lit Protocol Testnet",
nativeCurrency: {
name: "LIT",
symbol: "LIT",
decimals: 18,
},
rpcUrls: ["https://chain-rpc.litprotocol.com/http"],
blockExplorerUrls: ["https://chain.litprotocol.com"],
},
chains: {
ethereum: {
value: "ethereum",
label: "Ethereum",
abbreviation: "eth",
logo: "ethLogo.svg",
chainId: 1,
},
polygon: {
value: "polygon",
label: "Polygon",
abbreviation: "matic",
logo: "polygonLogo.svg",
chainId: 137,

},
arbitrum: {
value: "arbitrum",
label: "Arbitrum",
abbreviation: "arbitrum",
logo: "arbitrumLogo.svg",
chainId: 42161,
},
avalanche: {
value: "avalanche",
label: "Avalanche C-Chain",
abbreviation: "avax",
logo: "avalancheLogo.svg",
chainId: 43114,
},
optimism: {
value: "optimism",
label: "Optimism",
abbreviation: "op",
logo: "optimismLogo.jpeg",
chainId: 10,
},
celo: {
value: "celo",
label: "Celo",
abbreviation: "celo",
logo: "celoLogo.svg",
chainId: 42220,
},
fuji: {
value: "fuji",
label: "Avalanche FUJI Testnet",
abbreviation: "avalan",
logo: "avalancheLogo.svg",
chainId: 43113,
},
mumbai: {
value: "mumbai",
label: "Mumbai",
abbreviation: "mumbai",
logo: "polygonLogo.svg",
chainId: 80001,
},
goerli: {
value: "goerli",
label: "Goerli",
abbreviation: "goerli",
logo: "goerliLogo.png",
chainId: 5,
},
aurora: {
value: "aurora",
label: "Aurora",
abbreviation: "aoa",
logo: "auroraLogo.svg",
chainId: 1313161554,
},
},
},
arbitrum: {
value: "arbitrum",
label: "Arbitrum",
abbreviation: "arbitrum",
logo: "arbitrumLogo.svg",
chainId: 42161,
},
avalanche: {
value: "avalanche",
label: "Avalanche C-Chain",
abbreviation: "avax",
logo: "avalancheLogo.svg",
chainId: 43114,
},
optimism: {
value: "optimism",
label: "Optimism",
abbreviation: "op",
logo: "optimismLogo.jpeg",
chainId: 10,
},
celo: {
value: "celo",
label: "Celo",
abbreviation: "celo",
logo: "celoLogo.svg",
chainId: 42220,
},
fuji: {
value: "fuji",
label: "Avalanche FUJI Testnet",
abbreviation: "avalan",
logo: "avalancheLogo.svg",
chainId: 43113,
},
mumbai: {
value: "mumbai",
label: "Mumbai",
abbreviation: "mumbai",
logo: "polygonLogo.svg",
chainId: 80001,
},
goerli: {
value: "goerli",
label: "Goerli",
abbreviation: "goerli",
logo: "goerliLogo.png",
chainId: 5,
},
aurora: {
value: "aurora",
label: "Aurora",
abbreviation: "aoa",
logo: "auroraLogo.svg",
chainId: 1313161554,
},
},

};
Loading

0 comments on commit d57bb4c

Please sign in to comment.