From 27ef72e91bcc41136d5ccc67205907715a1c99da Mon Sep 17 00:00:00 2001 From: Sai Kumar <113705018+Saiweb3dev@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:09:46 +0530 Subject: [PATCH] Fix: Create NFT Form UI inconsistency (#52) changes made in CreateNFTPage.jsx component with more modern, responsive and color combination matching existing color palattes. --- frontend/src/pages/CreateNFTPage.jsx | 243 +++++++++++++-------------- 1 file changed, 118 insertions(+), 125 deletions(-) diff --git a/frontend/src/pages/CreateNFTPage.jsx b/frontend/src/pages/CreateNFTPage.jsx index 92cfb66..b3e4e9f 100644 --- a/frontend/src/pages/CreateNFTPage.jsx +++ b/frontend/src/pages/CreateNFTPage.jsx @@ -1,146 +1,139 @@ -// src/pages/CreateNFT.jsx -import { React, useState } from 'react' -import PropTypes from 'prop-types' +import { useState } from 'react' import { connectWallet, createNFT, getNFTContract } from '../utils/ethereum' import { ethers } from 'ethers' const nftAddress = import.meta.env.VITE_NFT_ADDRESS const marketplaceAddress = import.meta.env.VITE_MARKET_ADDRESS -const PRIVATE_KEY = import.meta.env.VITE_PRIVATE_KEY +export default function CreateNFT({ wallet }) { -const CreateNFT = ({ wallet }) => { - const [formData, setFormData] = useState({ - name: '', - description: '', - price: '', - file: null, - }) + const [formData, setFormData] = useState({ + name: '', + description: '', + price: '', + file: null , + }) - const handleChange = (e) => { - const { name, value, files } = e.target - setFormData((prevState) => ({ - ...prevState, - [name]: files ? files[0] : value, - })) - } + const handleChange = () => { + const { name, value, files } = e.target + setFormData((prevState) => ({ + ...prevState, + [name]: files ? files[0] : value, + })) + } - const handleSubmit = async (e) => { - e.preventDefault() + const handleSubmit = async (e) => { + e.preventDefault() - try { - const { name, description, price, file } = formData + try { + const { name, description, price, file } = formData - // Ensure all required fields are filled - if (!name || !description || !price || !file) { - throw new Error('All fields are required') - } + // Ensure all required fields are filled + if (!name || !description || !price || !file) { + throw new Error('All fields are required') + } - const signer = await connectWallet() + const signer = await connectWallet() - try { - const tokenId = await createNFT( - signer, - name, - description, - price, - file, - nftAddress, - marketplaceAddress - ) - console.log('NFT created and listed with token ID:', tokenId) - } catch (error) { - console.error('Failed to create and list NFT:', error) - } - } catch (error) { - console.error('Error creating NFT:', error) - } + try { + const tokenId = await createNFT( + signer, + name, + description, + price, + file, + nftAddress, + marketplaceAddress + ) + console.log('NFT created and listed with token ID:', tokenId) + } catch (error) { + console.error('Failed to create and list NFT:', error) + } + } catch (error) { + console.error('Error creating NFT:', error) } + } - return ( -
-

Create NFT

-
-
- - -
-
- - -
-
- - -
-
- - -
+ return ( +
+
+
+
+

Create your NFT

+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
- ) -} -CreateNFT.propTypes = { - wallet: PropTypes.object.isRequired, - // wallet: PropTypes.object, +
+
+ ) } - -export default CreateNFT