From f3302c17cc20f165255e1ec2228900ef87aaa39b Mon Sep 17 00:00:00 2001 From: Marco <35533749+marcopeocchi@users.noreply.github.com> Date: Wed, 27 Dec 2023 15:38:02 +0100 Subject: [PATCH] 115 download button (#119) * code refactoring, added file download * code refactoring --- frontend/src/lib/httpClient.ts | 12 +++++++----- frontend/src/views/Archive.tsx | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/frontend/src/lib/httpClient.ts b/frontend/src/lib/httpClient.ts index b9767a2..ee7a15e 100644 --- a/frontend/src/lib/httpClient.ts +++ b/frontend/src/lib/httpClient.ts @@ -15,11 +15,13 @@ const fetcher = async (url: string, opt?: RequestInit) => { } } - if (opt?.headers) { - opt.headers = { ...opt.headers, 'X-Authentication': jwt ?? '' } - } - - const res = await fetch(url, opt) + const res = await fetch(url, { + ...opt, + headers: { + ...opt?.headers, + 'X-Authentication': jwt ?? '' + } + }) if (!res.ok) { throw await res.text() diff --git a/frontend/src/views/Archive.tsx b/frontend/src/views/Archive.tsx index bb95aaa..cabdd3c 100644 --- a/frontend/src/views/Archive.tsx +++ b/frontend/src/views/Archive.tsx @@ -122,7 +122,7 @@ export default function Downloaded() { combineLatestWith(selected$), map(([data, selected]) => data.map(x => ({ ...x, - selected: selected.includes(x.path) + selected: selected.includes(x.name) }))), share() ), []) @@ -212,7 +212,7 @@ export default function Downloaded() { addSelected(file.path)} + onChange={() => addSelected(file.name)} /> }