Skip to content

Commit

Permalink
Merge pull request #15 from satwikkamath/master
Browse files Browse the repository at this point in the history
final blockchain changes
  • Loading branch information
satwikkamath authored May 19, 2024
2 parents b00b07d + 44ef485 commit 8249823
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 100 deletions.
64 changes: 31 additions & 33 deletions components/AccessData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ function AccessData() {
const fileName = selectedFileName;
// const name = document.querySelector("#file-name").value;


console.log(anonymizedCols);
//const amount = document.querySelector("#amount").value;
const amount = { value: ethers.utils.parseEther("0.001") };
Expand All @@ -112,6 +111,7 @@ function AccessData() {
);

await transaction.wait();
console.log(transaction);
alert("Transaction is successul");

// const anonymize_columns =
Expand Down Expand Up @@ -169,16 +169,13 @@ function AccessData() {
};

try {
const response = await fetch(
`${baseUrl}/anonymize-data`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
}
);
const response = await fetch(`${baseUrl}/anonymize-data`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
console.log(response);
if (!response.ok) {
throw new Error("Network response was not ok");
Expand All @@ -190,27 +187,27 @@ function AccessData() {
} catch (error) {
console.error("Error:", error);
}
return
return;
}
const data = {
file_name: selectedFileName,
column_name: columnNames,
anonymize_columns: anonymizedCols,
search_query: search,
search_index: selectedFileName + "_index",
limit: 50
}
limit: 50,
};
const response = await fetch(`${baseUrl}/search`, {
method: 'POST',
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json",
},
body: JSON.stringify(data)
})
body: JSON.stringify(data),
});
const res_data = await response.json();
console.log(res_data);
setAnonymizedData(res_data["data"])
}
setAnonymizedData(res_data["data"]);
};
return (
<>
<div className="flex flex-col items-center">
Expand Down Expand Up @@ -313,19 +310,20 @@ function AccessData() {
</thead>

<tbody className="divide-y divide-gray-200 dark:divide-gray-700">
{anonymizedData && anonymizedData.map((data) => {
return (
<tr>
{columnNames.map((key) => {
return (
<td className="whitespace-nowrap px-4 py-2 text-gray-700 dark:text-gray-200">
{data[key]}
</td>
);
})}
</tr>
);
})}
{anonymizedData &&
anonymizedData.map((data) => {
return (
<tr>
{columnNames.map((key) => {
return (
<td className="whitespace-nowrap px-4 py-2 text-gray-700 dark:text-gray-200">
{data[key]}
</td>
);
})}
</tr>
);
})}
</tbody>
</table>
</div>
Expand Down
138 changes: 71 additions & 67 deletions components/Memos.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,81 +11,85 @@ const Memos = ({ state }) => {
};
contract && memosMessage();
}, [contract]);

return (
<div className="container-fluid">
<h3 style={{ textAlign: "center", marginTop: "20px" }}>History</h3>
<table>
<tbody>
{memos.map((memo) => {
return (
<tr>
<td
style={{
backgroundColor: "dodgerblue",
border: "1px solid white",
borderCollapse: "collapse",
padding: "7px",
width: "100px",
color: "white",
}}
>
{memo.user_name}
</td>
<td
style={{
backgroundColor: "dodgerblue",
border: "1px solid white",
borderCollapse: "collapse",
padding: "7px",
width: "100px",
color: "white",
}}
>
{memo.file_name}
</td>
<td
style={{
backgroundColor: "dodgerblue",
border: "1px solid white",
borderCollapse: "collapse",
padding: "7px",
width: "300px",
color: "white",
}}
>
{memo.column_name}
</td>
<td
style={{
backgroundColor: "dodgerblue",
border: "1px solid white",
borderCollapse: "collapse",
padding: "7px",
width: "800px",
color: "white",
}}
>
{new Date(memo.timestamp * 1000).toLocaleString()}
</td>
<td
className="container-fluid"
style={{
backgroundColor: "dodgerblue",
border: "1px solid white",
borderCollapse: "collapse",
padding: "7px",
width: "400px",
color: "white",
}}
>
{memo.from}
</td>
</tr>
);
})}
{memos.map((memo, index) => (
<tr key={index}>
<td
style={{
backgroundColor: "dodgerblue",
border: "1px solid white",
borderCollapse: "collapse",
padding: "7px",
width: "100px",
color: "white",
}}
>
{memo.user_name}
</td>
<td
style={{
backgroundColor: "dodgerblue",
border: "1px solid white",
borderCollapse: "collapse",
padding: "7px",
width: "100px",
color: "white",
}}
>
{memo.file_name}
</td>
<td
style={{
backgroundColor: "dodgerblue",
border: "1px solid white",
borderCollapse: "collapse",
padding: "7px",
width: "300px",
color: "white",
}}
>
{memo.column_names.join(", ")}
{/* If you need more complex formatting, you can use something like:
{memo.column_name.map((name, idx) => (
<span key={idx}>{name}</span>
))} */}
</td>
<td
style={{
backgroundColor: "dodgerblue",
border: "1px solid white",
borderCollapse: "collapse",
padding: "7px",
width: "800px",
color: "white",
}}
>
{new Date(memo.timestamp * 1000).toLocaleString()}
</td>
<td
className="container-fluid"
style={{
backgroundColor: "dodgerblue",
border: "1px solid white",
borderCollapse: "collapse",
padding: "7px",
width: "400px",
color: "white",
}}
>
{memo.from}
</td>
</tr>
))}
</tbody>
</table>
</div>
);
};

export default Memos;

0 comments on commit 8249823

Please sign in to comment.