Fixed import
This commit is contained in:
@@ -7,7 +7,8 @@ import { fixedEncodeURIComponent } from '../../src/utils'
|
|||||||
import {
|
import {
|
||||||
GroupRenameBody,
|
GroupRenameBody,
|
||||||
GroupSetFactoryArrayBody,
|
GroupSetFactoryArrayBody,
|
||||||
SetFactoryArrayBody
|
SetFactoryArrayBody,
|
||||||
|
UploadDataBody
|
||||||
} from '../../src/types/ApiSchemasFrontend'
|
} from '../../src/types/ApiSchemasFrontend'
|
||||||
import { NextRouter, useRouter } from 'next/router'
|
import { NextRouter, useRouter } from 'next/router'
|
||||||
|
|
||||||
@@ -257,16 +258,19 @@ export const GroupProvider: FC<Props> = ({ children, id, initial }) => {
|
|||||||
}, [basicValues, excludedSuggestions, groups])
|
}, [basicValues, excludedSuggestions, groups])
|
||||||
|
|
||||||
const load = useCallback(
|
const load = useCallback(
|
||||||
(compressed: Uint8Array) => {
|
async (compressed: Uint8Array) => {
|
||||||
// const atob = (str: string) => Buffer.from(str, 'base64')
|
// const atob = (str: string) => Buffer.from(str, 'base64')
|
||||||
const uncompressed = pako.inflate(compressed, { to: 'string' })
|
const uncompressed = pako.inflate(compressed, { to: 'string' })
|
||||||
const value: StoredFile = JSON.parse(uncompressed)
|
const value: StoredFile = JSON.parse(uncompressed)
|
||||||
if (!value.groups || !value.basicValues || !value.excludedSuggestions) return
|
if (!value.groups || !value.basicValues || !value.excludedSuggestions) return
|
||||||
setGroups(value.groups)
|
await postFetchJson(router, `/api/${router.query.id}/upload`, {
|
||||||
setBasicValues(value.basicValues)
|
groups: value.groups,
|
||||||
setExcludedSuggestions(value.excludedSuggestions)
|
ignored: value.excludedSuggestions,
|
||||||
|
base: value.basicValues
|
||||||
|
} as UploadDataBody)
|
||||||
|
router.reload()
|
||||||
},
|
},
|
||||||
[setBasicValues, setExcludedSuggestions]
|
[router]
|
||||||
)
|
)
|
||||||
|
|
||||||
const value: GroupContextType = useMemo(
|
const value: GroupContextType = useMemo(
|
||||||
|
|||||||
@@ -4,26 +4,17 @@ import styles from './Home.module.css'
|
|||||||
import { useFactories } from '../../src/hooks/useFactories'
|
import { useFactories } from '../../src/hooks/useFactories'
|
||||||
import { EnrichedEntity } from '../../src/types'
|
import { EnrichedEntity } from '../../src/types'
|
||||||
import { EntitySpan } from './EntitySpan/EntitySpan'
|
import { EntitySpan } from './EntitySpan/EntitySpan'
|
||||||
import { postFetchJson, useGroups } from '../contexts/GroupProvider'
|
import { useGroups } from '../contexts/GroupProvider'
|
||||||
import { Preferences } from './Preferences/Preferences'
|
import { Preferences } from './Preferences/Preferences'
|
||||||
import { download, streamToArrayBuffer } from '../../src/download'
|
import { download, streamToArrayBuffer } from '../../src/download'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { UploadDataBody } from '../../src/types/ApiSchemasFrontend'
|
|
||||||
|
|
||||||
export const Home: FC = () => {
|
export const Home: FC = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { factories } = useFactories()
|
const { factories } = useFactories()
|
||||||
const {
|
const { groups, addGroup, doNotSuggest, ignoredFactories, setIgnoredFactories, store, load } =
|
||||||
groups,
|
useGroups()
|
||||||
addGroup,
|
|
||||||
doNotSuggest,
|
|
||||||
baseFactories,
|
|
||||||
ignoredFactories,
|
|
||||||
setIgnoredFactories,
|
|
||||||
store,
|
|
||||||
load
|
|
||||||
} = useGroups()
|
|
||||||
const [newGroupValue, setNewGroupValue] = useState('New group')
|
const [newGroupValue, setNewGroupValue] = useState('New group')
|
||||||
const inputRef = useRef<HTMLInputElement>(null)
|
const inputRef = useRef<HTMLInputElement>(null)
|
||||||
|
|
||||||
@@ -49,17 +40,6 @@ export const Home: FC = () => {
|
|||||||
>
|
>
|
||||||
Store
|
Store
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
onClick={() =>
|
|
||||||
postFetchJson(router, `/api/${router.query.id}/upload`, {
|
|
||||||
groups,
|
|
||||||
ignored: ignoredFactories,
|
|
||||||
base: baseFactories
|
|
||||||
} as UploadDataBody)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Upload
|
|
||||||
</button>
|
|
||||||
<input
|
<input
|
||||||
type={'file'}
|
type={'file'}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
|
|||||||
Reference in New Issue
Block a user