Skip to content

Commit

Permalink
htmlInputs
Browse files Browse the repository at this point in the history
  • Loading branch information
rchak007 committed Dec 2, 2023
1 parent 97e77c3 commit e02e2bd
Show file tree
Hide file tree
Showing 6 changed files with 261 additions and 101 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ next-env.d.ts
*secret*
getData.ts
*getData.ts*
secret.json
secret.json
testingDataSecret.txt
108 changes: 59 additions & 49 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,32 @@ import Head from 'next/head'
import WalletConnect from '../components/WalletConnect'
import { useStoreActions, useStoreState } from "../utils/store"
import Link from 'next/link'
import { useState, useEffect } from 'react'
import { useState, useEffect} from 'react'
import { getAssets } from "../utils/cardano";
import NftGrid from "../components/NftGrid";
import initLucid from '../utils/lucid'

import { useRouter } from 'next/router';

const Home: NextPage = () => {
const walletStore = useStoreState((state: any) => state.wallet)
const [nftList, setNftList] = useState([])
const [jsonData, setJsonData] = useState<any>(null);
const [secretData, setSecretData] = useState<any>(null);
// for Redirect to offChain.tsx
const router = useRouter();

useEffect(() => {
// Call fetchSecretData when the component mounts or walletStore.address changes
fetchSecretData();
//const lucid = initLucid(walletStore.name)
if (walletStore.address != "") {
getAssets(walletStore.address)
.then((res: any) => { setNftList(res.addressInfo.nfts) })
}

// for Redirect to offChain.tsx
router.push('/offChain');
}, [walletStore.address])


Expand All @@ -43,53 +52,54 @@ const Home: NextPage = () => {
}
};

return (
<div className="px-10">
<Head>
<title>Cardano dapp quickstart</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<div className="navbar bg-base-100">
<div className="flex-1">
<Link href="/" className="btn btn-ghost normal-case text-xl">Cardano</Link>
</div>
<div className="flex-none">
<WalletConnect />
</div>
</div>
<div>Address: {walletStore.address}</div>
<div>Your NFTs:</div>
<NftGrid nfts={nftList} />
<div className="mx-40 my-10">
<Link href="offChain">
<button className="btn btn-primary m-5" >Smart Contract example</button>
</Link>
{/* <div>Your NFTs:</div>
<NftGrid nfts={nftList} /> */}
</div>
<div>
<button className="btn btn-secondary m-5" onClick={fetchData}>Fetch Data</button>
{/* <button className="btn btn-secondary m-5" onClick={() => { testCode() }}> testCode</button> */}
{jsonData && (
<div>
{/* <pre>{JSON.stringify(jsonData, null, 2)}</pre> // this gives the whole JSON file */}
<h2>Item 1 Description: {jsonData.items[0].description}</h2>
</div>
)}
</div>
<div>
<button className="btn btn-secondary m-5" onClick={fetchSecretData}>Fetch Secret Data</button>
{/* <button className="btn btn-secondary m-5" onClick={() => { testCode() }}> testCode</button> */}
{secretData && (
<div>
<pre>{JSON.stringify(secretData, null, 2)}</pre> // this gives the whole JSON file
<h2> {secretData.seed[0].name} : {secretData.seed[0].description}</h2>
</div>
)}
</div>
</div>
)
}
return null;
// return (
// <div className="px-10">
// <Head>
// <title>Cardano dapp quickstart</title>
// <meta name="description" content="Generated by create next app" />
// <link rel="icon" href="/favicon.ico" />
// </Head>
// <div className="navbar bg-base-100">
// <div className="flex-1">
// <Link href="/" className="btn btn-ghost normal-case text-xl">Cardano</Link>
// </div>
// <div className="flex-none">
// <WalletConnect />
// </div>
// </div>
// <div>Address: {walletStore.address}</div>
// <div>Your NFTs:</div>
// <NftGrid nfts={nftList} />
// <div className="mx-40 my-10">
// <Link href="offChain">
// <button className="btn btn-primary m-5" >Decentralized Seed Phrase Manager</button>
// </Link>
// {/* <div>Your NFTs:</div>
// <NftGrid nfts={nftList} /> */}
// </div>
// <div>
// {/* <button className="btn btn-secondary m-5" onClick={fetchData}>Fetch Data</button> */}
// {/* <button className="btn btn-secondary m-5" onClick={() => { testCode() }}> testCode</button> */}
// {jsonData && (
// <div>
// {/* <pre>{JSON.stringify(jsonData, null, 2)}</pre> // this gives the whole JSON file */}
// <h2>Item 1 Description: {jsonData.items[0].description}</h2>
// </div>
// )}
// </div>
// {/* <div> */}
// {/* <button className="btn btn-secondary m-5" onClick={fetchSecretData}>Fetch Secret Data</button> */}
// {/* <button className="btn btn-secondary m-5" onClick={() => { testCode() }}> testCode</button> */}
// {/* {secretData && ( */}
// {/* <div> */}
// {/* <pre>{JSON.stringify(secretData, null, 2)}</pre> // this gives the whole JSON file */}
// {/* <h2> {secretData.seed[0].name} : {secretData.seed[0].description}</h2> */}
// {/* </div> */}
// {/* )} */}
// {/* </div> */}
// </div>
// )
}

export default Home
Loading

0 comments on commit e02e2bd

Please sign in to comment.