diff --git a/Govt-Billing-React/src/components/Menu/Menu.tsx b/Govt-Billing-React/src/components/Menu/Menu.tsx index 392becf..0ea33b9 100644 --- a/Govt-Billing-React/src/components/Menu/Menu.tsx +++ b/Govt-Billing-React/src/components/Menu/Menu.tsx @@ -3,7 +3,6 @@ import * as AppGeneral from "../socialcalc/index.js"; import { File, Local } from "../Storage/LocalStorage"; import { isPlatform, IonToast } from "@ionic/react"; import { EmailComposer } from "capacitor-email-composer"; -import { Printer } from "@ionic-native/printer"; import { IonActionSheet, IonAlert } from "@ionic/react"; import { saveOutline, save, mail, print } from "ionicons/icons"; import { APP_NAME } from "../../app-data.js"; @@ -57,16 +56,10 @@ const Menu: React.FC<{ }; const doPrint = () => { - if (isPlatform("hybrid")) { - const printer = Printer; - printer.print(AppGeneral.getCurrentHTMLContent()); - } else { - const content = AppGeneral.getCurrentHTMLContent(); - // useReactToPrint({ content: () => content }); - const printWindow = window.open("/printwindow", "Print Invoice"); - printWindow.document.write(content); - printWindow.print(); - } + const content = AppGeneral.getCurrentHTMLContent(); + const printWindow = window.open("/printwindow", "Print Invoice"); + printWindow.document.write(content); + printWindow.print(); }; const doSave = () => { if (props.file === "default") { diff --git a/Govt-Billing-React/src/pages/Home.tsx b/Govt-Billing-React/src/pages/Home.tsx index 7c4e143..c42d653 100644 --- a/Govt-Billing-React/src/pages/Home.tsx +++ b/Govt-Billing-React/src/pages/Home.tsx @@ -22,6 +22,13 @@ import Menu from "../components/Menu/Menu"; import Files from "../components/Files/Files"; import NewFile from "../components/NewFile/NewFile"; import { initFirebase } from "../firebase/index"; +import { ethers, BrowserProvider } from "ethers"; + +declare global { + interface Window { + ethereum?: any; + } +} const Home: React.FC = () => { const [showMenu, setShowMenu] = useState(false); @@ -32,6 +39,7 @@ const Home: React.FC = () => { const [selectedFile, updateSelectedFile] = useState("default"); const [billType, updateBillType] = useState(1); const [device] = useState("default"); + const [walletAddress, setWalletAddress] = useState(""); initFirebase(); @@ -73,6 +81,22 @@ const Home: React.FC = () => { ); }); + const connectWallet = async () => { + if (window.ethereum) { + try { + const provider = new BrowserProvider(window.ethereum); + await provider.send("eth_requestAccounts", []); + const signer = await provider.getSigner(); + const address = await signer.getAddress(); + setWalletAddress(address); + } catch (err) { + alert("Wallet connection failed"); + } + } else { + alert("MetaMask is not installed. Please install it to use this feature."); + } + }; + return ( @@ -83,7 +107,9 @@ const Home: React.FC = () => { - + + {walletAddress ? `Connected: ${walletAddress.slice(0, 6)}...${walletAddress.slice(-4)}` : "Connect Wallet"} +