import React from 'react';

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

import { keywordsSelector } 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 { TextField } from '@/mui/components';

type PropTypes = {
  disabled?: boolean;
};

const NAME_MAX_LENGTH = 1000;

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

  const keywords = useAppSelector(keywordsSelector);

  return (
    <TextField
      placeholder="Enter Keywords"
      size={size as GeneralSizeProp}
      value={keywords}
      disabled={disabled}
      inputProps={{ maxLength: NAME_MAX_LENGTH }}
      onChange={(e) => dispatch(setAction({ keywords: e.target.value }))}
    />
  );
}

export default Keywords;
