11import React , { useState , useEffect } from "react" ;
22import { ApiPromise } from "@polkadot/api" ;
33import type { InjectedAccountWithMeta } from "@polkadot/extension-inject/types" ;
4- import type { Signer } from "@polkadot/types/types" ;
54import { Button } from "./ui/components/Button" ;
65import { decodeMetadata } from "../utils/utils" ;
76import { CreateCollectionModal } from "./ui/modals/CreateCollectionModal" ;
87import { CreateNFTModal } from "./ui/modals/CreateNFTModal" ;
98import toast from "react-hot-toast" ;
9+ import Image from "next/image" ;
10+ import { Signer } from "@polkadot/api/types" ;
1011
1112interface CollectionManagerProps {
1213 api : ApiPromise ;
1314 account : InjectedAccountWithMeta ;
14- signer : Signer ;
15+ signer : Signer | unknown ;
1516}
1617
1718interface Collection {
@@ -67,12 +68,14 @@ export const CollectionManager: React.FC<CollectionManagerProps> = ({
6768
6869 useEffect ( ( ) => {
6970 loadCollections ( ) ;
71+ // eslint-disable-next-line react-hooks/exhaustive-deps
7072 } , [ api , account ] ) ;
7173
7274 useEffect ( ( ) => {
7375 if ( selectedCollection ) {
7476 loadNFTs ( selectedCollection . id ) ;
7577 }
78+ // eslint-disable-next-line react-hooks/exhaustive-deps
7679 } , [ selectedCollection ] ) ;
7780
7881 const loadCollections = async ( ) => {
@@ -122,7 +125,9 @@ export const CollectionManager: React.FC<CollectionManagerProps> = ({
122125 ) ;
123126 setCollections ( formattedCollections ) ;
124127 } catch ( error ) {
125- toast . error ( "Failed to load collections:" , error ) ;
128+ const errorMessage =
129+ error instanceof Error ? error . message : String ( error ) ;
130+ toast . error ( "Failed to load collections: " + errorMessage ) ;
126131 setError ( "Failed to load collections" ) ;
127132 }
128133 } ;
@@ -173,8 +178,13 @@ export const CollectionManager: React.FC<CollectionManagerProps> = ({
173178 isSold : nftData . isSold ,
174179 } ;
175180 } catch ( error ) {
181+ const errorMessage =
182+ error instanceof Error
183+ ? error . message
184+ : String ( error ) ;
176185 toast . error (
177- `Error loading NFT ${ itemId } : ` + error
186+ `Error loading NFT ${ itemId } : ` +
187+ errorMessage
178188 ) ;
179189 return null ;
180190 }
@@ -211,7 +221,9 @@ export const CollectionManager: React.FC<CollectionManagerProps> = ({
211221 }
212222 ) ;
213223 } catch ( error ) {
214- toast . error ( "Failed to burn NFT: " + error ) ;
224+ const errorMessage =
225+ error instanceof Error ? error . message : String ( error ) ;
226+ toast . error ( "Failed to burn NFT: " + errorMessage ) ;
215227 setError ( "Failed to burn NFT" ) ;
216228 }
217229 } ;
@@ -242,7 +254,9 @@ export const CollectionManager: React.FC<CollectionManagerProps> = ({
242254 }
243255 } ) ;
244256 } catch ( error ) {
245- toast . error ( "Failed to transfer NFT: " + error ) ;
257+ const errorMessage =
258+ error instanceof Error ? error . message : String ( error ) ;
259+ toast . error ( "Failed to transfer NFT: " + errorMessage ) ;
246260 setError ( "Failed to transfer NFT" ) ;
247261 }
248262 } ;
@@ -302,7 +316,6 @@ export const CollectionManager: React.FC<CollectionManagerProps> = ({
302316 </ div >
303317 </ div >
304318
305- { /* NFTs in Selected Collection */ }
306319 < div className = "bg-white rounded-lg shadow-lg p-4 sm:p-6" >
307320 < div className = "flex flex-col sm:flex-row justify-between items-start sm:items-center mb-4 sm:mb-6" >
308321 < h2 className = "text-xl sm:text-2xl font-bold text-gray-800 mb-4 sm:mb-0" >
@@ -353,7 +366,14 @@ export const CollectionManager: React.FC<CollectionManagerProps> = ({
353366 </ p >
354367 { nft . metadata
355368 . image && (
356- < img
369+ < Image
370+ width = {
371+ 0
372+ }
373+ height = {
374+ 0
375+ }
376+ sizes = "100vw"
357377 src = {
358378 nft
359379 . metadata
@@ -447,7 +467,7 @@ export const CollectionManager: React.FC<CollectionManagerProps> = ({
447467 < CreateCollectionModal
448468 api = { api }
449469 account = { account }
450- signer = { signer }
470+ signer = { signer as unknown }
451471 isOpen = { isCreateCollectionModalOpen }
452472 onClose = { ( ) => setIsCreateCollectionModalOpen ( false ) }
453473 onSuccess = { loadCollections }
@@ -457,7 +477,7 @@ export const CollectionManager: React.FC<CollectionManagerProps> = ({
457477 < CreateNFTModal
458478 api = { api }
459479 account = { account }
460- signer = { signer }
480+ signer = { signer as unknown }
461481 collectionId = { selectedCollection . id }
462482 isOpen = { isCreateNFTModalOpen }
463483 onClose = { ( ) => setIsCreateNFTModalOpen ( false ) }
0 commit comments