about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2024-08-19 00:23:18 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2024-08-19 00:23:18 +0200
commit35f2e0e45d0e1f8aa709d927c6354433b5577d46 (patch)
tree01e79f86aeb79f66e1ed2491aef1131655e77ee9
parentPages: File: Add placeholder restore button (diff)
downloadfs-tracer-frontend-35f2e0e45d0e1f8aa709d927c6354433b5577d46.tar.gz
fs-tracer-frontend-35f2e0e45d0e1f8aa709d927c6354433b5577d46.tar.bz2
fs-tracer-frontend-35f2e0e45d0e1f8aa709d927c6354433b5577d46.zip
Pages: File: Add functionality to restore button
-rw-r--r--src/pages/File.tsx7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pages/File.tsx b/src/pages/File.tsx
index 4e06d01..5a69d01 100644
--- a/src/pages/File.tsx
+++ b/src/pages/File.tsx
@@ -65,6 +65,11 @@ export default function File(props: any) {
     return parts[parts.length - 1]
   }
 
+  const restoreFile = async (file: FSTracerFile) => {
+    console.log("RESTORING FILE: user_id: ", props.session.user.id, " file: ", file.absolute_path, " ", file.contents, " ", file.timestamp)
+    await props.supabase.from('restored_file').insert({ absolute_path: file.absolute_path, contents: file.contents, timestamp: file.timestamp, user_id: props.session.user.id })
+  }
+
   return (
     <>
       <div className="flex h-screen">
@@ -85,7 +90,7 @@ export default function File(props: any) {
               <div className="block border rounded shadow py-5 px-5 bg-blue">
                 {files.map((currFile: FSTracerFile) => (
                   <div key={currFile.id}>
-                    <span>{currFile.absolute_path} - {currFile.timestamp} {currFile.id === file.id && "*"}</span><button onClick={() => { }}><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><b>Restore</b></button>
+                    <a href={"/file/" + currFile.id}>{currFile.absolute_path} - {currFile.timestamp} {currFile.id === file.id && "*"}</a><button onClick={() => { restoreFile(currFile) }}><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><b>Restore</b></button>
                   </div>
                 ))
                 }