import { useState } from 'react'; import { Col, ListGroup, Row } from 'react-bootstrap'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faRightLeft } from '@fortawesome/free-solid-svg-icons'; function TransferList({ available, assigned }) { const [availableList, setAvailableList] = useState(available); const [assignedList, setAssignedList] = useState(assigned); const filteredList = (selectedItem, setState) => { setState((list) => list.filter((item) => item.id !== selectedItem.id)); }; const appendList = (selectedItem, setState) => { setState((list) => [...list, selectedItem]); }; return (
Available Roles
{availableList.map((item) => ( { filteredList(item, setAvailableList); appendList(item, setAssignedList); }} > {item.data} ))}
Assigned Roles
{assignedList.map((item) => ( { appendList(item, setAvailableList); filteredList(item, setAssignedList); }} > {item.data} ))}
); } export default TransferList;