From 23b4d45c34bdf2211cb74ac19b36d8086eccbb89 Mon Sep 17 00:00:00 2001
From: xXJSONDeruloXx <danielhimebauch@gmail.com>
Date: Thu, 23 Jan 2025 00:08:36 -0500
Subject: add uninstaller button and script

---
 src/index.tsx | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

(limited to 'src/index.tsx')

diff --git a/src/index.tsx b/src/index.tsx
index b5211ea..aa2c55e 100755
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -12,6 +12,11 @@ const runInstallFGMod = callable<
   { status: string; message?: string; output?: string }
 >("run_install_fgmod");
 
+const runUninstallFGMod = callable<
+  [],
+  { status: string; message?: string; output?: string }
+>("run_uninstall_fgmod");
+
 const checkFGModPath = callable<
   [],
   { exists: boolean }
@@ -19,11 +24,17 @@ const checkFGModPath = callable<
 
 function FGModInstallerSection() {
   const [installing, setInstalling] = useState(false);
+  const [uninstalling, setUninstalling] = useState(false);
   const [installResult, setInstallResult] = useState<{
     status: string;
     output?: string;
     message?: string;
   } | null>(null);
+  const [uninstallResult, setUninstallResult] = useState<{
+    status: string;
+    output?: string;
+    message?: string;
+  } | null>(null);
   const [pathExists, setPathExists] = useState<boolean | null>(null);
 
   useEffect(() => {
@@ -46,6 +57,13 @@ function FGModInstallerSection() {
     setInstallResult(result);
   };
 
+  const handleUninstallClick = async () => {
+    setUninstalling(true);
+    const result = await runUninstallFGMod();
+    setUninstalling(false);
+    setUninstallResult(result);
+  };
+
   return (
     <PanelSection title="FG Mod Installer">
       <PanelSectionRow>
@@ -53,6 +71,11 @@ function FGModInstallerSection() {
           {installing ? "Installing..." : "Install FG Mod"}
         </ButtonItem>
       </PanelSectionRow>
+      <PanelSectionRow>
+        <ButtonItem layout="below" onClick={handleUninstallClick} disabled={uninstalling}>
+          {uninstalling ? "Uninstalling..." : "Uninstall FG Mod"}
+        </ButtonItem>
+      </PanelSectionRow>
       {installResult && (
         <PanelSectionRow>
           <div>
@@ -73,6 +96,26 @@ function FGModInstallerSection() {
           </div>
         </PanelSectionRow>
       )}
+      {uninstallResult && (
+        <PanelSectionRow>
+          <div>
+            <strong>Status:</strong>{" "}
+            {uninstallResult.status === "success" ? "Success" : "Error"}
+            <br />
+            {uninstallResult.output && (
+              <>
+                <strong>Output:</strong>
+                <pre style={{ whiteSpace: "pre-wrap" }}>{uninstallResult.output}</pre>
+              </>
+            )}
+            {uninstallResult.message && (
+              <>
+                <strong>Error:</strong> {uninstallResult.message}
+              </>
+            )}
+          </div>
+        </PanelSectionRow>
+      )}
       {pathExists !== null && (
         <PanelSectionRow>
           <div style={{ color: pathExists ? "green" : "red" }}>
-- 
cgit v1.2.3

