Fix selectMapButton name and a bug with deleting a map that isn't the current one
This commit is contained in:
41
src/components/map/SelectMapButton.js
Normal file
41
src/components/map/SelectMapButton.js
Normal file
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user