Skip to content

Commit 9b27a36

Browse files
committed
Show NFTs to children and add html skeleton for NFT list
1 parent 47dfb86 commit 9b27a36

File tree

5 files changed

+140
-16
lines changed

5 files changed

+140
-16
lines changed

packages/nextjs/app/nfts/page.tsx

-7
This file was deleted.

packages/nextjs/components/Header.tsx

-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ export const menuLinks: HeaderMenuLink[] = [
3737
href: "/perks",
3838
visibleTo: "parent",
3939
},
40-
{
41-
label: "NFTs",
42-
href: "/nfts",
43-
visibleTo: "child",
44-
},
4540
{
4641
label: "Debug Contracts",
4742
href: "/debug",

packages/nextjs/components/kiddo-perks/ChildDashboard.tsx

+35
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ContentHeader, PerksListGrid, TasksList, TasksProgress, TokensBalance } from ".";
2+
import { NftList } from "./ChildDashboard/NftList";
23
import { useAccount } from "wagmi";
34
import { useTaskManager, useTokenBalance } from "~~/hooks/kiddo-perks";
45

@@ -26,6 +27,40 @@ export const ChildDashboard = () => {
2627
</div>
2728
<TasksList />
2829
<PerksListGrid childTokens={rawTokenBalance} />
30+
<NftList
31+
availableNfts={[
32+
{
33+
id: "1",
34+
image: "/images/nft1.png",
35+
name: "Super Star NFT",
36+
description: "A special NFT for completing 5 tasks.",
37+
cost: 10,
38+
isMinted: false,
39+
canBeMinted: true,
40+
},
41+
{
42+
id: "2",
43+
image: "/images/nft2.png",
44+
name: "Task Master",
45+
description: "Awarded for completing all tasks this week.",
46+
cost: 20,
47+
isMinted: false,
48+
canBeMinted: false,
49+
},
50+
{
51+
id: "3",
52+
image: "/images/nft3.png",
53+
name: "Legendary Helper",
54+
description: "Given to children who help every day for a month.",
55+
cost: 50,
56+
isMinted: true,
57+
canBeMinted: false,
58+
},
59+
]}
60+
onMint={nftId => {
61+
console.log(`Minting NFT with ID: ${nftId}`);
62+
}}
63+
/>
2964
</div>
3065
);
3166
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React from "react";
2+
import Image from "next/image";
3+
4+
interface NftItem {
5+
id: string;
6+
image: string;
7+
name: string;
8+
description: string;
9+
cost: number; // Cost in KDO tokens
10+
isMinted: boolean; // Indicates if the NFT is already minted by the user
11+
canBeMinted: boolean; // Determines if the user has enough tokens to mint
12+
}
13+
14+
interface NftListProps {
15+
availableNfts: NftItem[];
16+
onMint: (nftId: string) => void; // Callback to handle NFT minting
17+
}
18+
19+
export const NftList: React.FC<NftListProps> = ({ availableNfts, onMint }) => {
20+
return (
21+
<section className="mt-6">
22+
<h2 className="text-lg font-semibold mb-4 text-secondary">Available NFTs</h2>
23+
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
24+
{availableNfts.map(nft => (
25+
<div key={nft.id} className="flex items-center bg-base-200 rounded-lg shadow-md p-4">
26+
<Image
27+
width={20}
28+
height={20}
29+
src={nft.image}
30+
alt={nft.name}
31+
className="w-20 h-20 object-cover rounded-md mr-4"
32+
/>
33+
<div className="flex-1">
34+
<h3 className="text-primary font-semibold text-md">{nft.name}</h3>
35+
<p className="text-neutral text-sm">{nft.description}</p>
36+
<div className="mt-2">
37+
<span className="badge badge-secondary">Cost: {nft.cost} KDO</span>
38+
</div>
39+
</div>
40+
<div className="ml-4">
41+
{nft.isMinted ? (
42+
<button className="btn btn-disabled btn-success">Minted</button>
43+
) : nft.canBeMinted ? (
44+
<button className="btn btn-primary btn-sm" onClick={() => onMint(nft.id)}>
45+
Mint
46+
</button>
47+
) : (
48+
<button className="btn btn-disabled btn-sm">Cannot Mint</button>
49+
)}
50+
</div>
51+
</div>
52+
))}
53+
</div>
54+
</section>
55+
);
56+
};

packages/nextjs/contracts/deployedContracts.ts

+49-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";
77
const deployedContracts = {
88
31337: {
99
KDOToken: {
10-
address: "0xe1da8919f262ee86f9be05059c9280142cf23f48",
10+
address: "0x700b6a60ce7eaaea56f065753d8dcb9653dbad35",
1111
abi: [
1212
{
1313
type: "constructor",
@@ -450,11 +450,37 @@ const deployedContracts = {
450450
},
451451
},
452452
KDONft: {
453-
address: "0x0c8e79f3534b00d9a3d4a856b665bf4ebc22f2ba",
453+
address: "0xa15bb66138824a1c7167f5e85b957d04dd34e468",
454454
abi: [
455455
{
456456
type: "constructor",
457-
inputs: [],
457+
inputs: [
458+
{
459+
name: "fiveSvgImageUri",
460+
type: "string",
461+
internalType: "string",
462+
},
463+
{
464+
name: "tenSvgImageUri",
465+
type: "string",
466+
internalType: "string",
467+
},
468+
{
469+
name: "twentySvgImageUri",
470+
type: "string",
471+
internalType: "string",
472+
},
473+
{
474+
name: "fiftySvgImageUri",
475+
type: "string",
476+
internalType: "string",
477+
},
478+
{
479+
name: "hundredSvgImageUri",
480+
type: "string",
481+
internalType: "string",
482+
},
483+
],
458484
stateMutability: "nonpayable",
459485
},
460486
{
@@ -638,6 +664,25 @@ const deployedContracts = {
638664
],
639665
stateMutability: "view",
640666
},
667+
{
668+
type: "function",
669+
name: "s_tokenIdToMilestone",
670+
inputs: [
671+
{
672+
name: "tokenId",
673+
type: "uint256",
674+
internalType: "uint256",
675+
},
676+
],
677+
outputs: [
678+
{
679+
name: "taskMilestone",
680+
type: "uint8",
681+
internalType: "enum KDONft.TaskMilestone",
682+
},
683+
],
684+
stateMutability: "view",
685+
},
641686
{
642687
type: "function",
643688
name: "safeTransferFrom",
@@ -1022,7 +1067,7 @@ const deployedContracts = {
10221067
},
10231068
},
10241069
KiddoPerks: {
1025-
address: "0xed1db453c3156ff3155a97ad217b3087d5dc5f6e",
1070+
address: "0xb19b36b1456e65e3a6d514d3f715f204bd59f431",
10261071
abi: [
10271072
{
10281073
type: "constructor",

0 commit comments

Comments
 (0)