import React, { useState } from "react"; import { TezosToolkit } from "@taquito/taquito"; import "./App.css"; import ConnectButton from "./components/ConnectWallet"; import DisconnectButton from "./components/DisconnectWallet"; import qrcode from "qrcode-generator"; import Records from "./components/Records"; import Transfers from "./components/Transfers"; enum BeaconConnection { NONE = "", LISTENING = "Listening to P2P channel", CONNECTED = "Channel connected", PERMISSION_REQUEST_SENT = "Permission request sent, waiting for response", PERMISSION_REQUEST_SUCCESS = "Wallet is connected" } const App = () => { const [Tezos, setTezos] = useState( new TezosToolkit("https://api.tez.ie/rpc/granadanet") ); const [contract, setContract] = useState(undefined); const [publicToken, setPublicToken] = useState(""); const [wallet, setWallet] = useState(null); const [userAddress, setUserAddress] = useState(""); const [userBalance, setUserBalance] = useState(0); const [storage, setStorage] = useState({dates: [], records: [],}); const [copiedPublicToken, setCopiedPublicToken] = useState(false); const [beaconConnection, setBeaconConnection] = useState(false); const [activeTab, setActiveTab] = useState("transfer"); // Granadanet Memoir contract const contractAddress: string = "KT1XDxSuXHBBtLDZRd2ZpEMYkxgutMc7a6mU"; const generateQrCode = (): { __html: string } => { const qr = qrcode(0, "L"); qr.addData(publicToken || ""); qr.make(); return { __html: qr.createImgTag(4) }; }; if (publicToken && (!userAddress || isNaN(userBalance))) { return (

MyMedMemoir

Decentralized Medical Reports

  Connecting to your wallet

{copiedPublicToken ? ( ) : ( { if (publicToken) { navigator.clipboard.writeText(publicToken); setCopiedPublicToken(true); setTimeout(() => setCopiedPublicToken(false), 2000); } }} > )} Public token: {publicToken}

Status: {beaconConnection ? "Connected" : "Disconnected"}

); } else if (userAddress && !isNaN(userBalance)) { return (

Memoir

setActiveTab("transfer")} > Wallet
setActiveTab("contract")} > New Report
setActiveTab("reports")} > Reports
{activeTab === "transfer" &&

Make a transfer

  {contractAddress}

  {userAddress}

  {(userBalance / 1000000).toLocaleString("en-US")} ꜩ

} {activeTab === "contract" &&
} {activeTab === "reports" &&
{storage.dates.map((val: boolean | React.ReactChild | React.ReactFragment | React.ReactPortal | null | undefined, idx: any) =>
{JSON.parse(storage.records[idx]).date} Name: {JSON.parse(storage.records[idx]).name}

Age: {JSON.parse(storage.records[idx]).age}

Height: {JSON.parse(storage.records[idx]).height}

Weight: {JSON.parse(storage.records[idx]).weight}

Prescription: {JSON.parse(storage.records[idx]).prescription}

)}
}
); } else if (!publicToken && !userAddress && !userBalance) { return (

MyMedMemoir

Welcome to MyMedMemoir!

Hello!

Go forth and M³!

); } else { return
An error has occurred
; } }; export default App;