Improved upload
This commit is contained in:
@@ -91,7 +91,7 @@ interface StoredFile {
|
||||
excludedSuggestions: string[]
|
||||
}
|
||||
|
||||
export const postFetchJson = async (url: string, body: Dict<unknown>) => {
|
||||
export const postFetchJson = async (url: string, body: unknown) => {
|
||||
const res = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
@@ -4,11 +4,12 @@ import styles from './Home.module.css'
|
||||
import { useFactories } from '../../src/hooks/useFactories'
|
||||
import { EnrichedEntity } from '../../src/types'
|
||||
import { EntitySpan } from './EntitySpan/EntitySpan'
|
||||
import { useGroups } from '../contexts/GroupProvider'
|
||||
import {postFetchJson, useGroups} from '../contexts/GroupProvider'
|
||||
import { Preferences } from './Preferences/Preferences'
|
||||
import { download, streamToArrayBuffer } from '../../src/download'
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
import {UploadDataBody} from '../../src/types/ApiSchemasFrontend'
|
||||
|
||||
export const Home: FC = () => {
|
||||
const router = useRouter()
|
||||
@@ -49,19 +50,7 @@ export const Home: FC = () => {
|
||||
Store
|
||||
</button>
|
||||
<button
|
||||
onClick={async () => {
|
||||
const res = await fetch('/api/submit', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ groups, ignored: ignoredFactories, base: baseFactories })
|
||||
})
|
||||
if (res.ok) {
|
||||
const { uuid } = await res.json()
|
||||
if (uuid) await router.push({ query: { ...router.query, id: uuid } })
|
||||
}
|
||||
}}
|
||||
onClick={() => postFetchJson(`/api/${router.query.id}/upload`, { groups, ignored: ignoredFactories, base: baseFactories } as UploadDataBody)}
|
||||
>
|
||||
Upload
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user