-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb28290
commit 0d11801
Showing
18 changed files
with
481 additions
and
33 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from "react"; | ||
|
||
const Challenges = () => { | ||
return ( | ||
<div style={{ marginTop: 20 }} className="bg-blue-800 min-h-screen py-16"> | ||
<div className="container mx-auto px-4"> | ||
<div | ||
style={{ | ||
gap: 20, | ||
}} | ||
className="grid grid-cols-1 md:grid-cols-2 gap-8" | ||
> | ||
<div | ||
style={{ | ||
padding: 20, | ||
}} | ||
className="bg-yellow-400 p-8 rounded-lg shadow-lg hover:shadow-2xl transition-shadow duration-300" | ||
> | ||
<h2 className="text-4xl text-blue-900 font-bold mb-6"> | ||
Weekly Bottle Challenge | ||
</h2> | ||
<p className="text-lg text-blue-900 mb-6"> | ||
Participate in the weekly challenge and earn extra $XOTL tokens by | ||
recycling more bottles! | ||
</p> | ||
<button className="px-6 py-3 bg-blue-900 text-white font-bold rounded-lg hover:bg-blue-700 transition-colors duration-300"> | ||
Join Challenge | ||
</button> | ||
</div> | ||
|
||
<div | ||
style={{ | ||
padding: 20, | ||
}} | ||
className="bg-yellow-400 p-8 rounded-lg shadow-lg hover:shadow-2xl transition-shadow duration-300" | ||
> | ||
<h2 className="text-4xl text-blue-900 font-bold mb-6"> | ||
Monthly Recycling Marathon | ||
</h2> | ||
<p className="text-lg text-blue-900 mb-6"> | ||
Collect and submit as many bottles as you can this month to win | ||
big rewards! | ||
</p> | ||
<button className="px-6 py-3 bg-blue-900 text-white font-bold rounded-lg hover:bg-blue-700 transition-colors duration-300"> | ||
Join Challenge | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Challenges; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from "react"; | ||
|
||
const leaderboardData = [ | ||
{ rank: 1, name: "Alice", bottles: 150 }, | ||
{ rank: 2, name: "Bob", bottles: 140 }, | ||
{ rank: 3, name: "Charlie", bottles: 130 }, | ||
{ rank: 4, name: "David", bottles: 120 }, | ||
{ rank: 5, name: "Eve", bottles: 110 }, | ||
]; | ||
|
||
const Leaderboard = () => { | ||
return ( | ||
<div className="bg-blue-800 min-h-screen py-16"> | ||
<div className="container mx-auto px-4"> | ||
<div | ||
style={{ | ||
padding: 20, | ||
}} | ||
className="bg-yellow-400 p-8 rounded-lg shadow-lg" | ||
> | ||
<table className="w-full text-center text-blue-900"> | ||
<thead> | ||
<tr> | ||
<th className="text-2xl font-bold py-4">Rank</th> | ||
<th className="text-2xl font-bold py-4">Name</th> | ||
<th className="text-2xl font-bold py-4">Bottles Collected</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{leaderboardData.map((entry) => ( | ||
<tr key={entry.rank} className="border-t border-blue-900"> | ||
<td className="py-4 text-xl">{entry.rank}</td> | ||
<td className="py-4 text-xl">{entry.name}</td> | ||
<td className="py-4 text-xl">{entry.bottles}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Leaderboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
"use client"; | ||
|
||
import React, { useState, useEffect } from "react"; | ||
import { Card, Button } from "flowbite-react"; | ||
import { ethers } from "ethers"; | ||
|
||
const nftTargets = [ | ||
{ | ||
id: 1, | ||
name: "Xottle-Warrior Badge", | ||
target: 10, | ||
image: "/images/earn.png", | ||
}, | ||
{ | ||
id: 2, | ||
name: "Xottle-Champion Badge", | ||
target: 100, | ||
image: "/images/earn.png", | ||
}, | ||
]; | ||
|
||
const NftBadge = () => { | ||
const [userAddress, setUserAddress] = useState<string | null>(null); | ||
const [totalBottles, setTotalBottles] = useState(0); | ||
|
||
useEffect(() => { | ||
const fetchUserAddress = async () => { | ||
if (window.ethereum) { | ||
const accounts = await window.ethereum.request({ | ||
method: "eth_accounts", | ||
}); | ||
if (accounts.length > 0) { | ||
setUserAddress(accounts[0]); | ||
} | ||
} | ||
}; | ||
fetchUserAddress(); | ||
}, []); | ||
|
||
useEffect(() => { | ||
const fetchTotalBottles = async () => { | ||
if (userAddress) { | ||
try { | ||
// const response = await axios.get( | ||
// `/api/get-total-bottles/${userAddress}` | ||
// ); | ||
// setTotalBottles(response.data.totalBottles); | ||
} catch (error) { | ||
console.error("Error fetching total bottles:", error); | ||
} | ||
} | ||
}; | ||
fetchTotalBottles(); | ||
}, [userAddress]); | ||
|
||
const handleClaimNft = async (nft: { | ||
id: number; | ||
name: string; | ||
target: number; | ||
}) => { | ||
if (totalBottles < nft.target) { | ||
alert( | ||
`You need to submit at least ${nft.target} bottles to claim this NFT.` | ||
); | ||
return; | ||
} | ||
|
||
try { | ||
const provider = new ethers.providers.Web3Provider( | ||
(window as any).ethereum | ||
); | ||
const signer = provider.getSigner(); | ||
const contractAddress = "YOUR_CONTRACT_ADDRESS"; // Replace with your contract address | ||
const abi: ethers.ContractInterface = [ | ||
// ABI for your contract's mint function | ||
]; | ||
|
||
const contract = new ethers.Contract(contractAddress, abi, signer); | ||
const tokenURI = `https://example.com/nft/${nft.id}`; // Replace with actual token URI | ||
const tx = await contract.mintNFT(userAddress, tokenURI); | ||
await tx.wait(); | ||
|
||
alert("NFT claimed successfully!"); | ||
} catch (error) { | ||
console.error("Error claiming NFT:", error); | ||
alert("NFT claim failed"); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="container mx-auto p-4"> | ||
{/* <p className="text-2xl text-center text-white mb-6"> | ||
Total Bottles Submitted:{" "} | ||
<span className="font-bold">{totalBottles}</span> | ||
</p> */} | ||
<div className="flex flex-wrap justify-center gap-4 mb-24"> | ||
{nftTargets.map((nft) => ( | ||
<Card key={nft.id} className="p-4 mb-4"> | ||
<img | ||
src={nft.image} | ||
alt={nft.name} | ||
className="mb-4 w-full h-32 object-cover rounded-lg" | ||
/> | ||
<h2 className="text-xl font-semibold mb-2">{nft.name}</h2> | ||
<p className="mb-4">Target: {nft.target} bottles</p> | ||
<Button | ||
className="w-full" | ||
onClick={() => handleClaimNft(nft)} | ||
disabled={totalBottles < nft.target} | ||
> | ||
{totalBottles >= nft.target | ||
? "Claim NFT" | ||
: `Need ${nft.target - totalBottles} more bottles`} | ||
</Button> | ||
</Card> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default NftBadge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,37 @@ | ||
import React from 'react'; | ||
import React from "react"; | ||
|
||
const Footers: React.FC = () => { | ||
return ( | ||
<footer style={footerStyle}> | ||
<div style={containerStyle}> | ||
<p style={textStyle}>© {new Date().getFullYear()} Xottle. All rights reserved.</p> | ||
<p style={textStyle}> | ||
© {new Date().getFullYear()} Xottle. All rights reserved. | ||
</p> | ||
</div> | ||
</footer> | ||
); | ||
}; | ||
|
||
const footerStyle: React.CSSProperties = { | ||
backgroundColor: '#F5CC00', | ||
color: '#003566', | ||
padding: '1rem 0', | ||
position: 'fixed', | ||
backgroundColor: "#F5CC00", | ||
color: "#003566", | ||
padding: "1rem 0", | ||
position: "fixed", | ||
bottom: 0, | ||
width: '100%', | ||
textAlign: 'center', | ||
width: "100%", | ||
textAlign: "center", | ||
marginTop: 100, | ||
}; | ||
|
||
const containerStyle: React.CSSProperties = { | ||
maxWidth: '1200px', | ||
margin: '0 auto', | ||
padding: '0 1rem', | ||
maxWidth: "1200px", | ||
margin: "0 auto", | ||
padding: "0 1rem", | ||
}; | ||
|
||
const textStyle: React.CSSProperties = { | ||
margin: 0, | ||
fontSize: '1rem', | ||
fontSize: "1rem", | ||
}; | ||
|
||
export default Footers; | ||
export default Footers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.