import React from 'react';

import { VIDEO_FILE_TYPE_OPTIONS } from '@/modules/feeds/Editor/constants';

import type { GeneralSizeProp } from '@/mui/types';

import { videoFileTypeSelector } from '@/modules/feeds/Editor/redux/selectors';
import { setAction } from '@/modules/feeds/Editor/redux/slices';

import { useFormSettings } from '@/modules/@common/Form';
import { useAppDispatch, useAppSelector } from '@/modules/@common/store/hooks';
import { MenuItem, Select } from '@/mui/components';

type PropTypes = {
  disabled?: boolean;
};

function VideoFileType({ disabled = false }: PropTypes) {
  const dispatch = useAppDispatch();
  const { size } = useFormSettings();

  const videoFileType = useAppSelector(videoFileTypeSelector);

  return (
    <Select
      // placeholder="Select File Type"
      size={size as GeneralSizeProp}
      value={videoFileType}
      disabled={disabled}
      onChange={(e) => dispatch(setAction({ videoFileType: e.target.value as typeof videoFileType }))}
    >
      {VIDEO_FILE_TYPE_OPTIONS.map((option) => (
        <MenuItem key={option.value} value={option.value}>
          {option.label}
        </MenuItem>
      ))}
    </Select>
  );
}

export default VideoFileType;
