import React from 'react';

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

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

type PropTypes = {
  disabled?: boolean;
};

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

  const priorityVerification = useAppSelector(priorityVerificationSelector);

  return (
    <Switch
      data-id="priorityVerification"
      size={size as GeneralSizeProp}
      color="primary"
      checked={priorityVerification}
      disabled={disabled}
      onChange={(e) => dispatch(setAction({ priorityVerification: e.target.checked }))}
    />
  );
}

export default PriorityVerification;
