import React, {useCallback} from 'react'
import {Select} from 'antd'
import {IBookContext, bookViewModes} from './BookComponent'


const {Option} = Select

export default function ViewSwitcher(props: IBookContext) {
    const {mode, setBookContextState} = props

    const viewModeChange = useCallback((mode) => {
        setBookContextState({
            mode
        })
    },[])

    return (
        <Select value={mode} onSelect={viewModeChange}>
            {
                bookViewModes.map((item: any)=>{
                    return <Option value={item.value}>{item.text}</Option>
                })
            }
        </Select> 
    )
}
