diff --git a/Components/placemarket.js b/Components/placemarket.js index 475410f..4a81470 100644 --- a/Components/placemarket.js +++ b/Components/placemarket.js @@ -18,6 +18,7 @@ import axios from "axios"; import DateTimePicker from './Datetimepicker'; import { removeItem } from "../pages/api/removeitem"; import { updatePrice } from "../pages/api/updateprice"; +import { updateTime } from "../pages/api/updatetime"; import { useAccount } from "wagmi"; const MyAssets = () => { @@ -372,6 +373,17 @@ refineArray.auctionStarteds = refineArray.auctionStarteds.map((asset) => { const newprice = ethers.utils.parseEther(saleprice.toString()); await updatePrice(nft,tradhubAddress,newprice); setLoading(false); + setShowModal(false); + } + + async function updateauctionfield(nft, saleprice) { + setLoading(true); + const newprice = ethers.utils.parseEther(saleprice.toString()); + await updatePrice(nft,tradhubAddress,newprice); + const updateauctiontime = (months * 30 * 24) + (days * 24) + (hours); + await updateTime(nft, tradhubAddress, updateauctiontime*60*60); + setLoading(false); + setShowModal2(false); } const handleInputChange = () => { @@ -618,8 +630,8 @@ refineArray.auctionStarteds = refineArray.auctionStarteds.map((asset) => { type="number" id="default-input" placeholder="Enter Price" - value={price} - onChange={handlePriceChange} + value={updatesaleprice} + onChange={handlesalePriceChange} className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" required /> @@ -646,7 +658,7 @@ refineArray.auctionStarteds = refineArray.auctionStarteds.map((asset) => { diff --git a/pages/api/updatetime.js b/pages/api/updatetime.js new file mode 100644 index 0000000..a23cc40 --- /dev/null +++ b/pages/api/updatetime.js @@ -0,0 +1,16 @@ +import { ethers } from "ethers"; +import Tradhub from '../../artifacts/contracts/tradehub/TradeHub.sol/TradeHub.json'; +import etherContract from "../../utils/web3Modal"; + +export const updateTime = async (nft, tradhubAddress, updateauctiontime) => { + const tradhubContarct = await etherContract(tradhubAddress, Tradhub.abi) + + try { + const transaction = await tradhubContarct.updateAuctionTime(nft.itemId,updateauctiontime); + console.log(transaction); + await transaction.wait(); + } catch (e) { + console.log(e?.data?.message); + console.error(e); + } +}; \ No newline at end of file