import React from 'react';

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

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

import { aspectRatioSelector } 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 AspectRatio({ disabled = false }: PropTypes) {
  const dispatch = useAppDispatch();
  const { size } = useFormSettings();

  const aspectRatio = useAppSelector(aspectRatioSelector);

  return (
    <Select
      // placeholder="Aspect Ratio"
      size={size as GeneralSizeProp}
      value={aspectRatio}
      disabled={disabled}
      onChange={(e) => dispatch(setAction({ aspectRatio: e.target.value as typeof aspectRatio }))}
    >
      {ASPECT_RATIO_OPTIONS.map((option) => (
        <MenuItem key={option.value} value={option.value}>
          {option.label}
        </MenuItem>
      ))}
    </Select>
  );
}

export default AspectRatio;
