import React from 'react';
import PropTypes from 'prop-types';
import { useDispatch } from 'react-redux';

import { archiveAction } from '../../redux/slices';

import useGetSelectedVideo from '@/modules/editorial/bulkActions/hooks/useGetSelectedVideo';
import { Button, Dialog, DialogActions, DialogContent, DialogTitle } from '@/mui/components';

function BulkActionArchive(props) {
  const dispatch = useDispatch();

  const selectedVideo = useGetSelectedVideo();

  const handleArchive = () => {
    dispatch(archiveAction());
    props.onClose();
  };

  return (
    <Dialog open={props.open} onClose={props.onClose} maxWidth="md">
      <DialogTitle onClose={props.onClose}>Archive Videos</DialogTitle>
      <DialogContent>{`Are you sure you want to archive ${selectedVideo} videos?`}</DialogContent>
      <DialogActions>
        <Button variant="text" color="primary" onClick={props.onClose}>
          Cancel
        </Button>
        <Button variant="contained" color="error" onClick={handleArchive}>
          Archive
        </Button>
      </DialogActions>
    </Dialog>
  );
}

BulkActionArchive.propTypes = {
  open: PropTypes.bool.isRequired,
  onClose: PropTypes.func.isRequired,
};

export default BulkActionArchive;
