Skip to content

Commit 026d136

Browse files
huisqalex4506
authored andcommitted
100243246
1 parent ba02ed3 commit 026d136

33 files changed

+6888
-0
lines changed

100243246/front_end/.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

100243246/front_end/.gitignore

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts

100243246/front_end/README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
"use client";
2+
import axios from "axios";
3+
import React, { useEffect, useState } from "react";
4+
import Cookies from "js-cookie";
5+
import Link from "next/link";
6+
7+
const REACT_APP_GATEWAY_URL = "https://gateway.netsepio.com/";
8+
9+
const Navbar = () => {
10+
const wallet = Cookies.get("taylor_wallet");
11+
12+
const [hovered, setHovered] = useState(false);
13+
const [avatarUrl, setAvatarUrl] = useState("");
14+
15+
const logout = {
16+
color: hovered ? "red" : "black",
17+
};
18+
19+
const getAptosWallet = () => {
20+
if ("aptos" in window) {
21+
return window.aptos;
22+
} else {
23+
window.open("https://petra.app/", "_blank");
24+
}
25+
};
26+
27+
const connectWallet = async () => {
28+
const wallet = getAptosWallet();
29+
try {
30+
const response = await wallet.connect();
31+
32+
const account = await wallet.account();
33+
console.log("account", account);
34+
35+
const networkwallet = await window.aptos.network();
36+
37+
// Check if the connected network is Mainnet
38+
if (networkwallet === "Testnet") {
39+
const { data } = await axios.get(
40+
`${REACT_APP_GATEWAY_URL}api/v1.0/flowid?walletAddress=${account.address}`
41+
);
42+
console.log(data);
43+
44+
const message = data.payload.eula;
45+
const nonce = data.payload.flowId;
46+
const publicKey = account.publicKey;
47+
48+
const { signature, fullMessage } = await wallet.signMessage({
49+
message,
50+
nonce,
51+
});
52+
console.log("sign", signature, "full message", fullMessage);
53+
54+
const authenticationData = {
55+
flowId: nonce,
56+
signature: `0x${signature}`,
57+
pubKey: publicKey,
58+
};
59+
60+
const authenticateApiUrl = `${REACT_APP_GATEWAY_URL}api/v1.0/authenticate`;
61+
62+
const config = {
63+
url: authenticateApiUrl,
64+
method: "POST",
65+
headers: {
66+
"Content-Type": "application/json",
67+
},
68+
data: authenticationData,
69+
};
70+
71+
try {
72+
const response = await axios(config);
73+
console.log("auth data", response.data);
74+
const token = await response?.data?.payload?.token;
75+
const userId = await response?.data?.payload?.userId;
76+
// localStorage.setItem("platform_token", token);
77+
Cookies.set("taylor_token", token, { expires: 7 });
78+
Cookies.set("taylor_wallet", account.address, { expires: 7 });
79+
Cookies.set("taylor_userid", userId, { expires: 7 });
80+
81+
window.location.reload();
82+
} catch (error) {
83+
console.error(error);
84+
}
85+
} else {
86+
alert(`Switch to Testnet in your wallet`);
87+
}
88+
} catch (err) {
89+
console.log(err);
90+
}
91+
};
92+
93+
const handleDeleteCookie = () => {
94+
Cookies.remove("taylor_wallet");
95+
Cookies.remove("taylor_token");
96+
window.location.href = "/";
97+
};
98+
99+
useEffect(() => {
100+
const fetchData = async () => {
101+
try {
102+
const getRandomNumber = () => Math.floor(Math.random() * 1000);
103+
const apiUrl = `https://api.multiavatar.com/${getRandomNumber()}`;
104+
105+
const response = await axios.get(apiUrl);
106+
const svgDataUri = `data:image/svg+xml,${encodeURIComponent(response.data)}`;
107+
setAvatarUrl(svgDataUri);
108+
} catch (error) {
109+
console.error('Error fetching avatar:', error.message);
110+
}
111+
};
112+
113+
fetchData();
114+
}, []);
115+
116+
return (
117+
<div>
118+
{wallet ? (
119+
<div className="flex gap-4">
120+
<Link href="/profile">{avatarUrl && <img src={avatarUrl} alt="Avatar" style={{width: 45}}/>} </Link>
121+
<div>
122+
<div className="ltext-black rounded-lg text-lg font-bold text-center">
123+
{wallet.slice(0, 4)}...{wallet.slice(-4)}
124+
</div>
125+
<button
126+
onClick={handleDeleteCookie}
127+
style={logout}
128+
className="mx-auto hover:text-red-400 text-black text-lg font-bold"
129+
onMouseEnter={() => setHovered(true)}
130+
onMouseLeave={() => setHovered(false)}
131+
>
132+
Logout
133+
</button>
134+
</div>
135+
</div>
136+
) : (
137+
<>
138+
<button onClick={connectWallet}>Connect wallet</button>
139+
</>
140+
)}
141+
</div>
142+
);
143+
};
144+
145+
export default Navbar;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"use client";
2+
import React from "react";
3+
import NftdataCard from "./NftdataCard";
4+
import Link from "next/link";
5+
6+
const NftdataContainer = ({
7+
metaDataArray,
8+
MyReviews = false,
9+
}) => {
10+
const handleReviewDeleted = () => {
11+
window.location.reload();
12+
};
13+
14+
const renderNoReviewsFound = () => (
15+
<div className="w-full text-center py-20">
16+
<h2 className="text-4xl font-bold text-white">No Readings Minted</h2>
17+
<div className="bg-blue-500 text-white font-bold py-4 px-6 rounded-lg w-1/5 mx-auto my-20">
18+
<Link href="/">Mint Now</Link>
19+
</div>
20+
</div>
21+
);
22+
23+
return (
24+
<>
25+
<div
26+
className="mx-auto px-10 min-h-screen py-10"
27+
>
28+
{metaDataArray?.length === 0 ? (
29+
renderNoReviewsFound()
30+
) : (
31+
<div
32+
style={{
33+
display: "grid",
34+
gridTemplateColumns: "repeat(4, minmax(0, 1fr))",
35+
gap: "2rem",
36+
}}
37+
>
38+
{metaDataArray?.map((metaData, index) => (
39+
<div
40+
key={index}
41+
className="py-2 flex"
42+
>
43+
<NftdataCard
44+
metaData={metaData}
45+
MyReviews={MyReviews}
46+
onReviewDeleted={handleReviewDeleted}
47+
/>
48+
</div>
49+
))}
50+
</div>
51+
)}
52+
</div>
53+
</>
54+
);
55+
};
56+
57+
export default NftdataContainer;

0 commit comments

Comments
 (0)