import PropTypes from 'prop-types'
import {Box, CircularProgress} from '@mui/material'
import dynamic from 'next/dynamic'

const MIZIK_URL = process.env.NEXT_PUBLIC_OKI_MIZIK_URL || 'https://funkwhale-server.com'

const DinamikLekte = dynamic(
  () => import('./lekte'), // eslint-disable-line node/no-unsupported-features/es-syntax
  {ssr: false, loading: () => <CircularProgress sx={{color: '#29d'}} />}
)

export default function OkiMizik({id, parole}) {
  const mizikStreamUrl = `/api/mizik-stream/${id}`
  const detailsUrl = `${MIZIK_URL}/library/tracks/${id}`

  return (
    <Box style={{marginTop: '0.3em', display: 'flex', flexDirection: 'column', alignItems: 'center'}}>
      <DinamikLekte audio={mizikStreamUrl} url={detailsUrl} parole={parole} />
    </Box>
  )
}

OkiMizik.propTypes = {
  id: PropTypes.number.isRequired,
  parole: PropTypes.object.isRequired
}
