|
|
@ -5,9 +5,8 @@ import { FiSearch } from 'react-icons/fi'
|
|
|
|
import { useDispatch } from '../store'
|
|
|
|
import { useDispatch } from '../store'
|
|
|
|
|
|
|
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { search } from '../lib/gutenberg'
|
|
|
|
import { search, getBook } from '../lib/gutenberg'
|
|
|
|
import { Spinner } from '../styles/Spinner'
|
|
|
|
import { Spinner } from '../styles/Spinner'
|
|
|
|
import { Dropdown } from './generics/Dropdown'
|
|
|
|
import { Dropdown } from './generics/Dropdown'
|
|
|
|
import { Book } from './Book'
|
|
|
|
import { Book } from './Book'
|
|
|
@ -32,12 +31,10 @@ export const SearchBar = () => {
|
|
|
|
[]
|
|
|
|
[]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const handleClick = async idx => {
|
|
|
|
const handleSelect = async idx => {
|
|
|
|
const { id, language } = results[idx]
|
|
|
|
const { id, language } = results[idx]
|
|
|
|
const url = `https://gutenberg.muperfredi.de/texts/${id}/stripped-body`
|
|
|
|
setText(await getBook(id))
|
|
|
|
const text = await axios.get(url).then(res => res.data.body)(setText(text))(
|
|
|
|
setLang(language[0])
|
|
|
|
setLang(language[0])
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
@ -72,7 +69,7 @@ export const SearchBar = () => {
|
|
|
|
items={results.map(entry => (
|
|
|
|
items={results.map(entry => (
|
|
|
|
<Book {...entry} />
|
|
|
|
<Book {...entry} />
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
onSelect={handleClick}
|
|
|
|
onSelect={handleSelect}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</Dropdown>
|
|
|
|
</Dropdown>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|