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