2023-06-28 15:25:28 +02:00
|
|
|
|
import React, { useEffect, useState, useRef } from 'react';
|
|
|
|
|
|
import Modal from 'react-modal';
|
|
|
|
|
|
import Draggable from 'react-draggable';
|
|
|
|
|
|
import { StyledModal } from '../styled/modals/ReplyModal.styled';
|
|
|
|
|
|
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
2023-09-26 14:46:11 +02:00
|
|
|
|
import { BoardForm } from '../styled/views/Board.styled';
|
2023-06-28 15:25:28 +02:00
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
|
|
|
|
|
|
|
const AdminListModal = ({ isOpen, closeModal, roles }) => {
|
2023-09-26 14:46:11 +02:00
|
|
|
|
const { selectedStyle } = useGeneralStore((state) => state);
|
2023-06-28 15:25:28 +02:00
|
|
|
|
|
|
|
|
|
|
const [isMobile, setIsMobile] = useState(window.innerWidth <= 480);
|
|
|
|
|
|
const nodeRef = useRef(null);
|
2023-09-26 14:46:11 +02:00
|
|
|
|
const rolesList = roles ? Object.entries(roles).map(([address, { role }]) => ({ address, role })) : [];
|
2023-06-28 15:25:28 +02:00
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const handleResize = () => setIsMobile(window.innerWidth <= 480);
|
|
|
|
|
|
window.addEventListener('resize', handleResize);
|
|
|
|
|
|
|
|
|
|
|
|
// Cleanup function
|
|
|
|
|
|
return () => {
|
|
|
|
|
|
window.removeEventListener('resize', handleResize);
|
|
|
|
|
|
};
|
|
|
|
|
|
}, [setIsMobile]);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<StyledModal
|
2023-09-26 14:46:11 +02:00
|
|
|
|
isOpen={isOpen}
|
|
|
|
|
|
onRequestClose={closeModal}
|
|
|
|
|
|
contentLabel='Reply Modal'
|
|
|
|
|
|
shouldCloseOnEsc={true}
|
|
|
|
|
|
shouldCloseOnOverlayClick={isMobile}
|
|
|
|
|
|
selectedStyle={selectedStyle}
|
|
|
|
|
|
overlayClassName='overlay'
|
|
|
|
|
|
style={isMobile ? { overlay: { backgroundColor: 'rgba(0,0,0,.25)' } } : { overlay: { backgroundColor: 'rgba(0,0,0,0)' } }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Draggable handle='.modal-header' nodeRef={nodeRef} disabled={isMobile}>
|
|
|
|
|
|
<div
|
|
|
|
|
|
className='modal-content'
|
|
|
|
|
|
ref={nodeRef}
|
|
|
|
|
|
style={{
|
2023-06-28 15:25:28 +02:00
|
|
|
|
maxWidth: '300px',
|
2023-09-26 14:46:11 +02:00
|
|
|
|
maxHeight: '250px',
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
2023-09-29 12:31:05 +02:00
|
|
|
|
<button className='icon' style={{ imageRendering: 'pixelated', margin: '1px 1px 0 0' }} onClick={() => closeModal()} title='close' />
|
2023-09-29 09:24:43 +02:00
|
|
|
|
<div className='modal-header'> Moderators</div>
|
2023-09-26 14:46:11 +02:00
|
|
|
|
<div
|
|
|
|
|
|
className='list'
|
|
|
|
|
|
style={{
|
|
|
|
|
|
padding: '10px',
|
|
|
|
|
|
maxHeight: '200px',
|
|
|
|
|
|
maxWidth: '300px',
|
|
|
|
|
|
overflowY: 'auto',
|
|
|
|
|
|
overflowX: 'hidden',
|
|
|
|
|
|
wordWrap: 'break-word',
|
|
|
|
|
|
wordBreak: 'break-all',
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<BoardForm selectedStyle={selectedStyle} style={{ all: 'unset' }}>
|
2023-09-29 20:17:49 +02:00
|
|
|
|
{roles ? (
|
|
|
|
|
|
rolesList.map(({ address, role }, index) => (
|
|
|
|
|
|
<p key={index}>
|
|
|
|
|
|
•{' '}
|
|
|
|
|
|
<Link to={() => {}} className='quote-link'>
|
|
|
|
|
|
u/{address}
|
|
|
|
|
|
</Link>
|
|
|
|
|
|
: {role}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
))
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<p>This board doesn't have moderators yet.</p>
|
|
|
|
|
|
)}
|
2023-06-28 15:25:28 +02:00
|
|
|
|
</BoardForm>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Draggable>
|
|
|
|
|
|
</StyledModal>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Modal.setAppElement('#root');
|
|
|
|
|
|
|
2023-09-26 14:46:11 +02:00
|
|
|
|
export default AdminListModal;
|