2021-05-24 14:13:24 +02:00
|
|
|
import React, { useCallback } from "react"
|
2021-05-11 16:37:15 +02:00
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
2021-05-23 05:35:17 +02:00
|
|
|
import { faLocationArrow, faPlus } from "@fortawesome/free-solid-svg-icons"
|
2021-04-30 22:10:00 +02:00
|
|
|
import ButtonIconOnly from "../base/ButtonIconOnly"
|
|
|
|
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
|
2021-05-18 16:53:42 +02:00
|
|
|
import BoxMap from "../base/BoxMap"
|
2021-05-22 04:44:08 +02:00
|
|
|
import useMapAreaState from "../../hooks/useMapAreaState"
|
2021-05-22 04:57:38 +02:00
|
|
|
import { ConditionLocation } from "../../objects/Condition"
|
2021-05-24 14:13:24 +02:00
|
|
|
import useStrings from "../../hooks/useStrings"
|
2021-05-07 16:30:12 +02:00
|
|
|
|
2021-05-01 02:33:46 +02:00
|
|
|
|
2021-04-30 22:10:00 +02:00
|
|
|
/**
|
2021-05-22 04:57:38 +02:00
|
|
|
* A {@link BoxMap} that allows the user to select a geographical location, and then to add it as a
|
|
|
|
* {@link ConditionLocation} of a RepositoryEditor.
|
2021-04-30 22:10:00 +02:00
|
|
|
*
|
|
|
|
* @param props - Additional props to pass to the box.
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2021-05-22 04:57:38 +02:00
|
|
|
export default function BoxConditionLocation({ ...props }) {
|
2021-05-22 04:44:08 +02:00
|
|
|
const mapViewHook = useMapAreaState()
|
2021-05-11 16:37:15 +02:00
|
|
|
const { addCondition } = useRepositoryEditor()
|
2021-05-24 14:13:24 +02:00
|
|
|
const strings = useStrings()
|
2021-04-30 22:10:00 +02:00
|
|
|
|
2021-05-21 19:52:56 +02:00
|
|
|
const onButtonClick = useCallback(
|
2021-05-22 04:57:38 +02:00
|
|
|
() => addCondition(new ConditionLocation(mapViewHook.mapArea)),
|
2021-05-23 16:20:53 +02:00
|
|
|
[mapViewHook, addCondition],
|
2021-05-07 05:02:20 +02:00
|
|
|
)
|
2021-04-30 22:10:00 +02:00
|
|
|
|
|
|
|
return (
|
2021-05-18 16:53:42 +02:00
|
|
|
<BoxMap
|
2021-05-21 19:52:56 +02:00
|
|
|
mapViewHook={mapViewHook}
|
2021-05-07 16:30:12 +02:00
|
|
|
header={
|
2021-05-18 01:33:08 +02:00
|
|
|
<span>
|
2021-05-18 02:04:06 +02:00
|
|
|
{strings.searchBy}
|
2021-05-18 01:33:08 +02:00
|
|
|
|
2021-05-22 04:57:38 +02:00
|
|
|
<FontAwesomeIcon icon={faLocationArrow}/>
|
2021-05-18 01:33:08 +02:00
|
|
|
|
2021-05-18 02:04:06 +02:00
|
|
|
{strings.byZone}
|
2021-05-18 01:33:08 +02:00
|
|
|
</span>
|
2021-05-07 16:30:12 +02:00
|
|
|
}
|
2021-05-18 16:53:42 +02:00
|
|
|
button={
|
|
|
|
<ButtonIconOnly
|
|
|
|
icon={faPlus}
|
|
|
|
color={"Green"}
|
|
|
|
onClick={onButtonClick}
|
2021-04-30 22:10:00 +02:00
|
|
|
/>
|
2021-05-18 16:53:42 +02:00
|
|
|
}
|
|
|
|
{...props}
|
|
|
|
/>
|
2021-04-30 22:10:00 +02:00
|
|
|
)
|
|
|
|
}
|