Skip to content

Commit

Permalink
Added Things
Browse files Browse the repository at this point in the history
  • Loading branch information
SWAGATSWAROOP committed Jun 19, 2024
1 parent dea531c commit 358a687
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 111 deletions.
27 changes: 13 additions & 14 deletions frontend-next/app/trade/bnb/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ export default function BNBCard() {
// fetchImage();
// }, [days]);

// async function buy() {
// const session = useSession();
// console.log(session);
// const email = sessionStorage.getItem("email");
// const createUser = await contract.buy(email, 0, "Binance", 0);
// await createUser.wait();
// }
async function buy() {
const session = useSession();
const email = sessionStorage.getItem("email");
const createUser = await contract.buy(email, 0, "Binance", 0);
await createUser.wait();
}

// async function sell() {
// const email = sessionStorage.getItem("email");
// const createUser = await contract.sell(email, "Binance", 0, 0);
// await createUser.wait();
// }
async function sell() {
const email = sessionStorage.getItem("email");
const createUser = await contract.sell(email, "Binance", 0, 0);
await createUser.wait();
}
return (
<div className="flex min-h-screen flex-col items-center justify-center bg-gradient-to-r from-pink-700 from-30% via-purple-900 to-indigo-900">
<div className="w-full bg-gradient-to-r from-pink-700 via-purple-900 to-indigo-900 py-4 text-center font-serif text-3xl font-bold text-white">
Expand Down Expand Up @@ -106,13 +105,13 @@ export default function BNBCard() {
<div className="flex w-1/2 flex-row justify-around">
<button
className="flex items-center self-start rounded-lg bg-green-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-green-500 md:text-base"
// onClick={buy}
onClick={buy}
>
Buy
</button>
<button
className="flex items-center self-start rounded-lg bg-red-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-red-500 md:text-base"
// onClick={sell}
onClick={sell}
>
Sell
</button>
Expand Down
92 changes: 43 additions & 49 deletions frontend-next/app/trade/btc/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,47 @@ import { useState, useEffect } from "react";
import axios from "axios";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faArrowUp, faArrowDown } from "@fortawesome/free-solid-svg-icons";
import { ethers } from "ethers";
import Account from "../../contracts/account.sol/Account.json";
import { contract } from "@/lib/constant";
import Image from "next/image";

export default function BitcoinCard() {
const [days, setDays] = useState(7);
// const [imageUrl, setImageUrl] = useState(
// "https://res.cloudinary.com/djtudleky/image/upload/v1717468043/ogib3zfczrxpyfeo6mod.png"
// );
const [imageUrl, setImageUrl] = useState(
"https://res.cloudinary.com/djtudleky/image/upload/v1717468043/ogib3zfczrxpyfeo6mod.png",
);

const data = {
desc: 12,
inc: 23,
};

// useEffect(() => {
// const fetchImage = async () => {
// try {
// const res = await axios.get(
// `http://127.0.0.1:5000/upload?days=${days}&type=btc`
// );
// setImageUrl(res.data.secure_url);
// } catch (error) {
// console.error("Error fetching image:", error);
// }
// };
// fetchImage();
// }, [days]);
useEffect(() => {
const fetchImage = async () => {
console.log("Change occurred");
try {
const res = await axios.get(
`http://127.0.0.1:5000/upload?days=${days}&type=btc`,
);
console.log(res);
setImageUrl(res.data.secure_url);
} catch (error) {
console.error("Error fetching image:", error);
}
};

// async function buy() {
// const email = sessionStorage.getItem("email");
// const createUser = await contract.buy(email, 0, "Bitcoin", 0);
// await createUser.wait();
// }
fetchImage();
}, [days]);

// async function sell() {
// let provider = new ethers.JsonRpcProvider();
// let signer = await provider.getSigner();
// let contract = new ethers.Contract(
// "0x5FbDB2315678afecb367f032d93F642f64180aa3",
// Account.abi,
// signer
// );
// const email = sessionStorage.getItem("email");
// const createUser = await contract.sell(email, "Bitcoin", 0, 0);
// await createUser.wait();
// }
async function buy() {
const email = sessionStorage.getItem("email");
const createUser = await contract.buy(email, 0, "Bitcoin", 0);
await createUser.wait();
}

async function sell() {
const email = sessionStorage.getItem("email");
const createUser = await contract.sell(email, "Bitcoin", 0, 0);
await createUser.wait();
}

return (
<>
Expand All @@ -65,15 +63,11 @@ export default function BitcoinCard() {
<option value={365}>365 Days</option>
</select>
<div className="flex w-full justify-center p-3 md:w-2/3 lg:w-1/2">
<div className="relative w-full h-auto">
{/* <Image
src={imageUrl}
alt="Bitcoin Image"
layout="fill"
objectFit="cover"~
className="rounded"
/> */}
</div>
<img
src={imageUrl}
alt="Bitcoin Image"
className="h-auto w-full rounded"
/>
</div>
<div className="w-full px-6 py-4 md:w-1/3 lg:w-1/2">
<div className="mb-2 text-center text-xl font-bold">
Expand All @@ -94,13 +88,13 @@ export default function BitcoinCard() {
<div className="mt-4 flex space-x-4">
<button
className="rounded-lg bg-green-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-green-500 md:text-base"
// onClick={buy}
onClick={buy}
>
Buy
</button>
<button
className="rounded-lg bg-red-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-red-500 md:text-base"
// onClick={sell}
onClick={sell}
>
Sell
</button>
Expand All @@ -114,13 +108,13 @@ export default function BitcoinCard() {
<div className="flex items-center self-start rounded-lg bg-green-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-green-500 md:text-base">
<FontAwesomeIcon icon={faArrowUp} size="2x" color="white" />
<h1 className="pl-4 text-white">
<strong>0.4670%</strong>
<strong>0.32007%</strong>
</h1>
</div>
<div className="flex items-center self-start rounded-lg bg-red-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-red-500 md:text-base">
<FontAwesomeIcon icon={faArrowDown} size="2x" color="white" />
<h1 className="pl-4 text-white">
<strong>0.5330%</strong>
<strong>0.6800%</strong>
</h1>
</div>
</div>
Expand Down
35 changes: 13 additions & 22 deletions frontend-next/app/trade/eth/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { useState, useEffect } from "react";
import axios from "axios";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faArrowUp, faArrowDown } from "@fortawesome/free-solid-svg-icons";
import { ethers } from "ethers";
import Account from "../../contracts/account.sol/Account.json";
import { contract } from "@/lib/constant";

export default function ETHCARD() {
Expand All @@ -30,24 +28,17 @@ export default function ETHCARD() {
// fetchImage();
// }, [days]);

// async function buy() {
// const email = sessionStorage.getItem("email");
// const createUser = await contract.buy(email, 0, "Etherium", 0);
// await createUser.wait();
// }
async function buy() {
const email = sessionStorage.getItem("email");
const createUser = await contract.buy(email, 0, "Etherium", 0);
await createUser.wait();
}

// async function sell() {
// let provider = new ethers.JsonRpcProvider();
// let signer = await provider.getSigner();
// let contract = new ethers.Contract(
// "0x5FbDB2315678afecb367f032d93F642f64180aa3",
// Account.abi,
// signer,
// );
// const email = sessionStorage.getItem("email");
// const createUser = await contract.sell(email, "Etherium", 0, 0);
// await createUser.wait();
// }
async function sell() {
const email = sessionStorage.getItem("email");
const createUser = await contract.sell(email, "Etherium", 0, 0);
await createUser.wait();
}

return (
<>
Expand All @@ -67,7 +58,7 @@ export default function ETHCARD() {
<option value={365}>365 Days</option>
</select>
<div className="flex w-full justify-center p-3 md:w-2/3 lg:w-1/2">
{/* <img
{/* <img
src={imageUrl}
alt="Ethereum Image"
className="h-auto w-full rounded"
Expand All @@ -93,13 +84,13 @@ export default function ETHCARD() {
<div className="mt-4 flex space-x-4">
<button
className="flex items-center self-start rounded-lg bg-green-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-green-500 md:text-base"
// onClick={buy}
onClick={buy}
>
Buy
</button>
<button
className="flex items-center self-start rounded-lg bg-red-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-red-500 md:text-base"
// onClick={sell}
onClick={sell}
>
Sell
</button>
Expand Down
24 changes: 12 additions & 12 deletions frontend-next/app/trade/sol/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ export default function SOLCard() {
// fetchImage();
// }, [days]);

// async function buy() {
// const email = sessionStorage.getItem("email");
// const createUser = await contract.buy(email, 0, "Solana", 0);
// await createUser.wait();
// }
async function buy() {
const email = sessionStorage.getItem("email");
const createUser = await contract.buy(email, 0, "Solana", 0);
await createUser.wait();
}

// async function sell() {
// const email = sessionStorage.getItem("email");
// const createUser = await contract.sell(email, "Solana", 0, 0);
// await createUser.wait();
// }
async function sell() {
const email = sessionStorage.getItem("email");
const createUser = await contract.sell(email, "Solana", 0, 0);
await createUser.wait();
}

return (
<>
Expand Down Expand Up @@ -83,13 +83,13 @@ export default function SOLCard() {
<div className="mt-4 flex space-x-4">
<button
className="flex items-center self-start rounded-lg bg-green-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-green-500 md:text-base"
// onClick={buy}
onClick={buy}
>
Buy
</button>
<button
className="flex items-center self-start rounded-lg bg-red-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-red-500 md:text-base"
// onClick={sell}
onClick={sell}
>
Sell
</button>
Expand Down
28 changes: 14 additions & 14 deletions frontend-next/app/trade/usdt/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ export default function BitcoinCard() {
// fetchImage();
// }, [days]);

// async function buy() {
// const email = sessionStorage.getItem("email");
// const createUser = await contract.buy(email, 0, "USDT", 0);
// await createUser.wait();
// }
async function buy() {
const email = sessionStorage.getItem("email");
const createUser = await contract.buy(email, 0, "USDT", 0);
await createUser.wait();
}

// async function sell() {
// const email = sessionStorage.getItem("email");
// const createUser = await contract.sell(email, "USDT", 0, 0);
// await createUser.wait();
// }
async function sell() {
const email = sessionStorage.getItem("email");
const createUser = await contract.sell(email, "USDT", 0, 0);
await createUser.wait();
}

return (
<div className="flex min-h-screen flex-col items-center justify-center bg-gradient-to-r from-pink-700 from-30% via-purple-900 to-indigo-900">
Expand Down Expand Up @@ -67,8 +67,8 @@ export default function BitcoinCard() {
<div className="mb-2 text-center text-xl font-bold">USDT</div>
<p className="text-center text-base text-gray-700">
Tether is a cryptocurrency stablecoin, launched by the company
Tether Limited Inc. in 2014. As of January 2024,the website
lists fourteen protocols and blockchains on which Tether has been
Tether Limited Inc. in 2014. As of January 2024,the website lists
fourteen protocols and blockchains on which Tether has been
minted. Tether has been criticized for a lack of transparency and
verifiability of its claimed fiat reserves.
</p>
Expand All @@ -81,13 +81,13 @@ export default function BitcoinCard() {
<div className="mt-4 flex space-x-4">
<button
className="flex items-center self-start rounded-lg bg-green-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-green-500 md:text-base"
// onClick={buy}
onClick={buy}
>
BUY
</button>
<button
className="flex items-center self-start rounded-lg bg-red-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-red-500 md:text-base"
// onClick={sell}
onClick={sell}
>
SELL
</button>
Expand Down

0 comments on commit 358a687

Please sign in to comment.