Skip to content

Commit

Permalink
Ipfs Gatweay
Browse files Browse the repository at this point in the history
  • Loading branch information
Corantin committed Jun 26, 2024
1 parent c3512c5 commit 03bd198
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
29 changes: 16 additions & 13 deletions packages/nextjs/pages/overview/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { WithRouterProps } from "next/dist/client/with-router";
import Image from "next/image";
import Link from "next/link";
Expand Down Expand Up @@ -59,23 +59,15 @@ const Page = ({ router }: WithRouterProps) => {
const isOwner = useIsOwner(deedData);
const fileClient = useFileClient();

const picturesRef = useRef<string[] | undefined>();

useEffect(() => {
if (router.isReady && !isConnecting) {
setIsLoading(true);
fetchDeedInfo(id as string);
}
}, [router.isReady, isConnecting, authToken]);

const pictures =
deedData?.propertyDetails.propertyImages
?.filter(x => !!x.fileId && !x.restricted)
?.map(image => getTargetNetwork().ipfsGateway + image.fileId) ?? [];
if (pictures.length < 4) {
for (let index = pictures.length; index < 4; index++) {
pictures.push(`/images/residential${index + 1}.png`);
}
}

const handleChange = (ev: LightChangeEvent<DeedInfoModel>) => {
setDeedData((prevState: DeedInfoModel) => ({ ...prevState, [ev.name]: ev.value }));
};
Expand Down Expand Up @@ -104,6 +96,17 @@ const Page = ({ router }: WithRouterProps) => {
if (resp.ok && resp.value) {
setInitialData(resp.value);
setDeedData(resp.value);
const pictures =
resp.value?.propertyDetails.propertyImages
?.filter(x => !!x.fileId && !x.restricted)
?.map(image => getTargetNetwork().ipfsGateway + image.fileId) ?? [];

if (pictures.length < 4) {
for (let index = pictures.length; index < 4; index++) {
pictures.push(`/images/residential${index + 1}.png`);
}
}
picturesRef.current = pictures;
if (resp.value.mintedId && id === resp.value.id) {
await router.replace(`/overview/${resp.value.mintedId}`, undefined, { shallow: true });
}
Expand All @@ -116,7 +119,7 @@ const Page = ({ router }: WithRouterProps) => {
}
},
[id, deedData.mintedId, chainId, authToken, isValidator],
);
).bind(this);

const handleErrorClick = async () => {
if (errorCode === "unexpected") {
Expand Down Expand Up @@ -297,7 +300,7 @@ const Page = ({ router }: WithRouterProps) => {
</div>
{/* Images */}
<div className="w-[30%] sm:w-1/2 grid grid-rows-4 sm:grid-rows-2 sm:grid-cols-2 gap-2 sm:gap-4">
{pictures?.slice(0, 4).map((picture, index) => {
{picturesRef.current?.slice(0, 4).map((picture, index) => {
return (
<div key={index} className="w-full h-[85px] sm:h-[300px]">
<Image
Expand Down
25 changes: 13 additions & 12 deletions packages/nextjs/utils/scaffold-eth/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,17 @@ export const NETWORKS_EXTRA_DATA: Record<string, TChainAttributes> = {
deedSubgraph: "http://localhost:8000/subgraphs/name/Deed3",
ipfsGateway: "http://localhost:8080/ipfs/",
},
[chains.mainnet.id]: {
color: "#ff8b9e",
storageAddress: "0x91B0d67D3F47A30FBEeB159E67209Ad6cb2cE22E",
deedMintingFeeDollar: 0,
stableCoin: {
address: "0x0000000000",
decimals: 18,
symbol: "ETH",
},
},
[chains.arbitrum.id]: {
color: "#28a0f0",
storageAddress: "arb1:0x84F1d8D4B10b1C56e032aE09bCA57f393638cd4E",
storageAddress: "0x84F1d8D4B10b1C56e032aE09bCA57f393638cd4E",
deedMintingFeeDollar: 500,
stableCoin: {
address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
decimals: 6,
symbol: "USDC",
},
ipfsGateway: "https://ipfs.io/ipfs/",
blockExplorer: "https://arbiscan.io/",
},
[chains.sepolia.id]: {
color: "#2bbdf7",
Expand All @@ -58,7 +50,6 @@ export const NETWORKS_EXTRA_DATA: Record<string, TChainAttributes> = {
decimals: 18,
symbol: "DAI",
},
deedSubgraph: "https://api.studio.thegraph.com/query/56229/deed3-sepolia/version/latest",
ipfsGateway: "https://ipfs.io/ipfs/",
blockExplorer: "https://blockscout.com/xdai/mainnet",
},
Expand All @@ -75,6 +66,16 @@ export const NETWORKS_EXTRA_DATA: Record<string, TChainAttributes> = {
},
blockExplorer: "https://polygonscan.com/",
},
[chains.mainnet.id]: {
color: "#ff8b9e",
storageAddress: "0x91B0d67D3F47A30FBEeB159E67209Ad6cb2cE22E",
deedMintingFeeDollar: 0,
stableCoin: {
address: "0x0000000000",
decimals: 18,
symbol: "ETH",
},
},
// [chains.hardhat.id]: {
// color: "#b8af0c",
// nativeCurrencyTokenAddress: "0x0000000000",
Expand Down

0 comments on commit 03bd198

Please sign in to comment.