115 download button (#119)

* code refactoring, added file download

* code refactoring
This commit is contained in:
Marco
2023-12-27 15:38:02 +01:00
committed by GitHub
parent 3859c80214
commit f3302c17cc
2 changed files with 9 additions and 7 deletions

View File

@@ -15,11 +15,13 @@ const fetcher = async <T>(url: string, opt?: RequestInit) => {
} }
} }
if (opt?.headers) { const res = await fetch(url, {
opt.headers = { ...opt.headers, 'X-Authentication': jwt ?? '' } ...opt,
} headers: {
...opt?.headers,
const res = await fetch(url, opt) 'X-Authentication': jwt ?? ''
}
})
if (!res.ok) { if (!res.ok) {
throw await res.text() throw await res.text()

View File

@@ -122,7 +122,7 @@ export default function Downloaded() {
combineLatestWith(selected$), combineLatestWith(selected$),
map(([data, selected]) => data.map(x => ({ map(([data, selected]) => data.map(x => ({
...x, ...x,
selected: selected.includes(x.path) selected: selected.includes(x.name)
}))), }))),
share() share()
), []) ), [])
@@ -212,7 +212,7 @@ export default function Downloaded() {
<Checkbox <Checkbox
edge="end" edge="end"
checked={file.selected} checked={file.selected}
onChange={() => addSelected(file.path)} onChange={() => addSelected(file.name)}
/> />
</>} </>}
</div> </div>