Skip to content

Commit

Permalink
Merge pull request #77 from SecureDocsChain/User-Front
Browse files Browse the repository at this point in the history
Button send to avalanch
  • Loading branch information
QuenumGerald authored May 27, 2024
2 parents 6c89bc5 + 2f5aa22 commit 3d80266
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions Frontend/securedocs/src/pages/account.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useEffect, useState } from "react";
import axios from "axios";
import { useRouter } from 'next/router'; // Importez useRouter
import { useRouter } from 'next/router';
import "../app/styles/globals.css";
import { useWeb3Auth } from "../context/web3AuthContext";
import { ethers } from "ethers"; // Importez ethers.js

const axiosInstance = axios.create({
baseURL: 'http://localhost:3000', // URL de base pour toutes les requêtes
Expand All @@ -13,7 +14,7 @@ const AccountPage = () => {
const [userInfo, setUserInfo] = useState(null);
const [documents, setDocuments] = useState([]);
const [error, setError] = useState(null);
const router = useRouter(); // Initialisez useRouter
const router = useRouter();

useEffect(() => {
if (email) {
Expand Down Expand Up @@ -53,14 +54,18 @@ const AccountPage = () => {

const handleDocumentSubmit = async () => {
try {
// Redirigez vers la page /upload directement
router.push('/upload');
} catch (error) {
setError("Error submitting document");
console.error("Error submitting document:", error);
}
};

const sendToAvalanche = async (document) => {
// Fonction vide pour interagir avec le contrat Avalanche
console.log('Sending document to Avalanche:', document);
};

if (loading) return <div>Loading...</div>;

if (error) return <div>{error}</div>;
Expand Down Expand Up @@ -92,7 +97,7 @@ const AccountPage = () => {
</div>
</header>
<main className="flex flex-col items-center justify-center flex-1 w-full px-4">
<h1 className="mt-10 mb-4 text-3xl font-bold text-center md:text-5xl">Account</h1>
<h1 className="mt-10 mb-4 text-3xl font-bold text-center md:text-5xl">Account Page</h1>
<div className="w-full max-w-2xl p-4 bg-white rounded-md shadow-md">
<h2 className="mb-4 text-xl font-semibold">Update Information</h2>
<input
Expand Down Expand Up @@ -123,7 +128,17 @@ const AccountPage = () => {
<ul className="space-y-2">
{documents.map(doc => (
<li key={doc._id} className="px-4 py-2 bg-gray-100 rounded-md">
{doc.fileName} - {doc.status}
<div className="flex items-center justify-between">
<span>{doc.fileName} - {doc.status}</span>
{doc.status === 'validé' && (
<button
onClick={() => sendToAvalanche(doc)}
className="px-4 py-2 font-bold text-white bg-green-600 rounded-md hover:bg-green-800"
>
Send to Avalanche Chain
</button>
)}
</div>
</li>
))}
</ul>
Expand Down

0 comments on commit 3d80266

Please sign in to comment.