Skip to content

Commit

Permalink
Merge pull request #7 from itxtoledo/feat/integrations
Browse files Browse the repository at this point in the history
Feat/integrations
  • Loading branch information
itxtoledo authored Sep 14, 2024
2 parents caddb0e + ff02195 commit f53de77
Show file tree
Hide file tree
Showing 15 changed files with 608 additions and 358 deletions.
2 changes: 0 additions & 2 deletions apps/app/.env

This file was deleted.

2 changes: 2 additions & 0 deletions apps/app/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_WC_PROJECT_ID=b57492a3490d9766ce9d2e3f30f6a755
VITE_PRESALE_FACTORY=0x016e627e24b8bCD5753afA90FE95E72338f72e12
2 changes: 1 addition & 1 deletion apps/app/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Routes = () => {
element: <PresaleCreation />,
},
{
path: "/PresaleDetails",
path: "/presale-details/:address",
element: <PresaleDetails />,
},
{
Expand Down
76 changes: 16 additions & 60 deletions apps/app/src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,75 +7,31 @@ export default function Footer() {
<div className="container max-w-7xl grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-8 text-sm">
<div className="grid gap-1">
<h3 className="font-semibold">Company</h3>
<Link href="#">
About Us
</Link>
<Link href="#">
Our Team
</Link>
<Link href="#">
Careers
</Link>
<Link href="#">
News
</Link>
</div>
<div className="grid gap-1">
<h3 className="font-semibold">Products</h3>
<Link href="#">
Men
</Link>
<Link href="#">
Women
</Link>
<Link href="#">
Kids
</Link>
<Link href="#">
Accessories
</Link>
<Link to="/">About Us</Link>
<Link to="/">Our Team</Link>
<Link to="/">Careers</Link>
<Link to="/">News</Link>
</div>

<div className="grid gap-1">
<h3 className="font-semibold">Resources</h3>
<Link href="#">
Blog
</Link>
<Link href="#">
Community
</Link>
<Link href="#">
Support
</Link>
<Link href="#">
FAQs
</Link>
<Link to="/">Blog</Link>
<Link to="/">Community</Link>
<Link to="/">Support</Link>
<Link to="/">FAQs</Link>
</div>
<div className="grid gap-1">
<h3 className="font-semibold">Legal</h3>
<Link href="#">
Privacy Policy
</Link>
<Link href="#">
Terms of Service
</Link>
<Link href="#">
Cookie Policy
</Link>
<Link to="/">Privacy Policy</Link>
<Link to="/">Terms of Service</Link>
<Link to="/">Cookie Policy</Link>
</div>
<div className="grid gap-1">
<h3 className="font-semibold">Contact</h3>
<Link href="#">
Support
</Link>
<Link href="#">
Sales
</Link>
<Link href="#">
Press
</Link>
<Link href="#">
Partnerships
</Link>
<Link to="/">Support</Link>
<Link to="/">Sales</Link>
<Link to="/">Press</Link>
<Link to="/">Partnerships</Link>
</div>
</div>
</footer>
Expand Down
52 changes: 52 additions & 0 deletions apps/app/src/components/intgration_components/withdrawETH.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Button } from "@/components/ui/button";

import * as React from "react";

//importing necessary wagmi contracts integrations
import {
useWriteContract,
useWaitForTransactionReceipt,
type BaseError,
} from "wagmi";

// importing contract ABI
import abi from "@tokenization-platform/contracts/abi_ts/contracts/Presale.sol/Presale";

export function WithdrawETH() {
const { data: hash, isPending, error, writeContract } = useWriteContract();
async function submit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault();

writeContract({
address: "0xE3920963fedC0b83cdd8CBdAB0fce942ee95eD59",
abi,
functionName: "withdrawETH",
});
}

const { isLoading: isConfirming, isSuccess: isConfirmed } =
useWaitForTransactionReceipt({
hash,
});

return (
<form onSubmit={submit}>
<div className="grid gap-4">
<Button
type="submit"
disabled={isPending}
variant="outline"
className="bg-black text-white"
>
{isPending ? "Confirming..." : "Withdraw ETH"}
</Button>
{hash && <div>Transaction Hash: {hash}</div>}
{isConfirming && <div>Waiting for confirmation...</div>}
{isConfirmed && <div>Transaction confirmed.</div>}
{error && (
<div>Error: {(error as BaseError).shortMessage || error.message}</div>
)}
</div>
</form>
);
}
68 changes: 68 additions & 0 deletions apps/app/src/components/intgration_components/withdrawTokens.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";

import * as React from "react";

//importing necessary wagmi contracts integrations
import {
useWriteContract,
useWaitForTransactionReceipt,
type BaseError,
} from "wagmi";

// importing contract ABI
import abi from "@tokenization-platform/contracts/abi_ts/contracts/Presale.sol/Presale";

export function WithdrawToken() {
const { data: hash, isPending, error, writeContract } = useWriteContract();
async function submit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault();
const formData = new FormData(e.target as HTMLFormElement);
const tokenAddress = formData.get("tokenAddress") as "0x{string}";

writeContract({
address: "0xE3920963fedC0b83cdd8CBdAB0fce942ee95eD59",
abi,
functionName: "withdrawToken",
args: [tokenAddress],
});
}

const { isLoading: isConfirming, isSuccess: isConfirmed } =
useWaitForTransactionReceipt({
hash,
});

return (
<form onSubmit={submit}>
<div>
<label htmlFor="recipient" className="block text-muted-foreground mb-1">
Token Address
</label>
<Input
id="recipient"
type="text"
name="tokenAddress"
placeholder="0x..."
className="w-full"
/>
</div>
<div className="grid gap-4">
<Button
type="submit"
disabled={isPending}
variant="outline"
className="bg-black text-white"
>
{isPending ? "Confirming..." : "Withdraw Tokens"}
</Button>
{hash && <div>Transaction Hash: {hash}</div>}
{isConfirming && <div>Waiting for confirmation...</div>}
{isConfirmed && <div>Transaction confirmed.</div>}
{error && (
<div>Error: {(error as BaseError).shortMessage || error.message}</div>
)}
</div>
</form>
);
}
44 changes: 2 additions & 42 deletions apps/app/src/pages/about.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";

import { Link } from "react-router-dom";
import Header from "@/components/Header";
import Footer from "@/components/Footer";

export default function About() {

return (
<>
<Header />
Expand All @@ -31,46 +31,6 @@ export default function About() {
</div>
</div>
</div>
<div className="bg-background rounded-lg shadow-md p-6">
<h2 className="text-2xl font-bold mb-4">Mint Tokens</h2>
<form className="space-y-4">
<div>
<label
htmlFor="recipient"
className="block text-muted-foreground mb-1"
>
Recipient Address
</label>
<Input
id="recipient"
type="text"
placeholder="0x..."
className="w-full"
/>
</div>
<div>
<label
htmlFor="amount"
className="block text-muted-foreground mb-1"
>
Amount to Mint
</label>
<Input
id="amount"
type="number"
placeholder="100"
className="w-full"
/>
</div>
<Button
type="submit"
variant="outline"
className="w-full bg-black text-white"
>
Mint Tokens
</Button>
</form>
</div>
<div className="bg-background rounded-lg shadow-md p-6">
<h2 className="text-2xl font-bold mb-4">About Token Minting</h2>
<p className="text-muted-foreground">
Expand Down
12 changes: 5 additions & 7 deletions apps/app/src/pages/adminDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ import {
import { Badge } from "@/components/ui/badge";
import Header from "@/components/Header";
import Footer from "@/components/Footer";
import { WithdrawETH } from "@/components/intgration_components/withdrawETH";
import { WithdrawToken } from "@/components/intgration_components/withdrawTokens";

export default function AdminDashboard() {
return (
<>
<Header />
<div className="flex min-h-screen w-full flex-col bg-muted/40">
<main className="grid flex-1 items-start gap-4 p-4 sm:px-6 sm:py-0 md:gap-8">
<div className="grid w-full gap-4 md:grid-cols-2 lg:grid-cols-3">
<div className="grid w-full gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
<Card>
<CardHeader className="flex flex-row items-center justify-between pb-2">
<CardTitle>Presale Overview</CardTitle>
Expand Down Expand Up @@ -297,12 +299,8 @@ export default function AdminDashboard() {
</CardHeader>
<CardContent>
<div className="grid gap-4">
<Button variant="outline" className="bg-black text-white">
Withdraw ETH
</Button>
<Button variant="outline" className="bg-black text-white">
Withdraw Tokens
</Button>
<WithdrawETH />
<WithdrawToken />
</div>
</CardContent>
</Card>
Expand Down
9 changes: 3 additions & 6 deletions apps/app/src/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ export default function Home() {
</CardContent>
<CardFooter>
<Link
href="#"
to="#"
className="text-primary hover:underline"
prefetch={false}
>
View Details
</Link>
Expand Down Expand Up @@ -201,9 +200,8 @@ export default function Home() {
</CardContent>
<CardFooter>
<Link
href="#"
to="#"
className="text-primary hover:underline"
prefetch={false}
>
View Details
</Link>
Expand Down Expand Up @@ -236,9 +234,8 @@ export default function Home() {
</CardContent>
<CardFooter>
<Link
href="#"
to="#"
className="text-primary hover:underline"
prefetch={false}
>
View Details
</Link>
Expand Down
Loading

0 comments on commit f53de77

Please sign in to comment.