import { useVideosQuery, Video } from '../../../src/gql'
import { FunctionComponent } from 'react'
import { AdminList } from '../../../src/app'
import theme from '../../../src/styles/theme'
import FileSelector from '../../../src/file/components/FileSelector'

const AdminVideo: FunctionComponent<{ item: Partial<Video>; className?: string }> = ({
  item,
  className,
}) => {
  return (
    <div className={className}>
      <div className='admin-video-title'>{item.title}</div>
      <div className='admin-video-description'>{item.description}</div>
      <div className='admin-video-file'>{item.file?.filename}</div>
      <style jsx>{`
        .${className} {
          display: flex;
        }
        .admin-video-title {
          width: 15%;
        }
        .admin-video-description {
          width: 65%;
        }
        .admin-video-file {
          width: 20%;
          text-align: right;
        }
        button {
          margin: 0 0.4em;
          padding: 0;
          color: ${theme.colors.buttonBackground};
          background-color: transparent;
        }
        button.false {
          color: #5557;
        }
      `}</style>
    </div>
  )
}

const AdminVideos = () => {
  const props = {
    name: 'Videos',
    adminMenu: '/admin/video',
    get: useVideosQuery(),
    dataKey: 'videos',
    Component: AdminVideo,
  }
  return <AdminList {...props} />
}

export default AdminVideos
