diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2024-08-19 00:23:18 +0200 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2024-08-19 00:23:18 +0200 |
commit | 35f2e0e45d0e1f8aa709d927c6354433b5577d46 (patch) | |
tree | 01e79f86aeb79f66e1ed2491aef1131655e77ee9 | |
parent | Pages: File: Add placeholder restore button (diff) | |
download | fs-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.tsx | 7 |
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> </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> </span><b>Restore</b></button> </div> )) } |