Skip to content

Commit

Permalink
Merge pull request #44 from hollow-leaf/fix/buyer_postapi
Browse files Browse the repository at this point in the history
fix: buyer post api
  • Loading branch information
crypto0627 authored Aug 29, 2023
2 parents beafc59 + 9fdba6f commit b898832
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 74 deletions.
37 changes: 0 additions & 37 deletions apps/web/components/buyerAlertBox.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions apps/web/components/buyerCard.tsx

This file was deleted.

8 changes: 1 addition & 7 deletions apps/web/components/buyerSubmitBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ import { useState } from 'react'
import { buy } from '../service/contract';
import { getbuyList } from '../service/api';

interface BuyerSubmitProps {
sharedState: boolean;
setSharedState: React.Dispatch<React.SetStateAction<boolean>>;
}

function BuyerSubmit({sharedState,setSharedState}:BuyerSubmitProps) {
function BuyerSubmit() {
const [inputValue, setInputValue] = useState<number>(0);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string>('');
const [dat,setData]=useState()

const handleInputChange = (event:any) => {
setInputValue(event.target.value);
Expand Down
4 changes: 2 additions & 2 deletions apps/web/components/buyerTable.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BuyerTableItem from "./buyerTableItem";
import { formatAddress } from "../utils/stringify";

function BuyerTable() {
function BuyerTable(props: any) {
const fakeData = [
{
powerType: "sun",
Expand Down Expand Up @@ -65,7 +65,7 @@ function BuyerTable() {
</thead>
<tbody>
{/* body */}
{fakeData.map((item, index) => {
{props.buyList.map((item:any, index:any) => {
return (
<BuyerTableItem
key={index}
Expand Down
20 changes: 13 additions & 7 deletions apps/web/pages/buyer.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import BuyerCard from "../components/buyerCard";
import BuyerSubmit from "../components/buyerSubmitBox"
import BuyerTable from "../components/buyerTable"
import {useState} from "react"
import { useAccount } from "wagmi";
import { getCert } from "../service/api";
import { useEffect, useState } from "react";

export default function Page(){
const [sharedState, setSharedState] = useState(false);

const [buyList, setBuyList] = useState<any[]>([]);

useEffect(() => {
getCert('').then((res) => {
setBuyList(res);
});
}, []);

return(
<div className="grid grid-cols-2">
<div className="mx-auto mt-14 mb-14">
<p className="text-3xl text-black">Your NFT</p>
<div className="divider"></div>
<BuyerTable/>
<BuyerTable buyList={buyList}/>
</div>
<div className="mx-auto mt-14 mb-20 flex flex-col justify-between ml-10">
<div className="mb-2">
<BuyerSubmit sharedState={sharedState} setSharedState={setSharedState} />
<BuyerCard sharedState={sharedState} setSharedState={setSharedState} />
<BuyerSubmit/>
</div>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions apps/web/service/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,20 @@ export async function getbuyList(amount: number) {
catch (err) {
console.log("error", err);
}
}

export async function getCert(account: string) {
try {
const res = await axios({
method: 'get',
url: host + "/cert",
data: {
account: account
}
})
return res.data;
}
catch (err) {
console.log("error", err);
}
}

0 comments on commit b898832

Please sign in to comment.