42 lines
962 B
JavaScript
42 lines
962 B
JavaScript
import React, { useState } from "react";
|
|
import { IconButton } from "theme-ui";
|
|
|
|
import SelectMapModal from "../../modals/SelectMapModal";
|
|
import SelectMapIcon from "../../icons/SelectMapIcon";
|
|
|
|
function SelectMapButton({ onMapChange, onMapStateChange, currentMap }) {
|
|
const [isAddModalOpen, setIsAddModalOpen] = useState(false);
|
|
function openModal() {
|
|
setIsAddModalOpen(true);
|
|
}
|
|
function closeModal() {
|
|
setIsAddModalOpen(false);
|
|
}
|
|
|
|
function handleDone() {
|
|
closeModal();
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<IconButton
|
|
aria-label="Select Map"
|
|
title="Select Map"
|
|
onClick={openModal}
|
|
>
|
|
<SelectMapIcon />
|
|
</IconButton>
|
|
<SelectMapModal
|
|
isOpen={isAddModalOpen}
|
|
onRequestClose={closeModal}
|
|
onDone={handleDone}
|
|
onMapChange={onMapChange}
|
|
onMapStateChange={onMapStateChange}
|
|
currentMap={currentMap}
|
|
/>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default SelectMapButton;
|