1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-26 23:14:19 +00:00
pds-2021-g2-nest/nest_frontend/components/interactive/BoxConditionLocation.js

53 lines
1.7 KiB
JavaScript
Raw Normal View History

import React, { useCallback } from "react"
2021-05-11 14:37:15 +00:00
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faLocationArrow, faPlus } from "@fortawesome/free-solid-svg-icons"
2021-04-30 20:10:00 +00:00
import ButtonIconOnly from "../base/ButtonIconOnly"
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
import BoxMap from "../base/BoxMap"
2021-05-22 02:44:08 +00:00
import useMapAreaState from "../../hooks/useMapAreaState"
import { ConditionLocation } from "../../objects/Condition"
import useStrings from "../../hooks/useStrings"
2021-05-07 14:30:12 +00:00
2021-05-01 00:33:46 +00:00
2021-04-30 20:10:00 +00: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 20:10:00 +00:00
*
* @param props - Additional props to pass to the box.
* @returns {JSX.Element}
* @constructor
*/
export default function BoxConditionLocation({ ...props }) {
2021-05-22 02:44:08 +00:00
const mapViewHook = useMapAreaState()
2021-05-11 14:37:15 +00:00
const { addCondition } = useRepositoryEditor()
const strings = useStrings()
2021-04-30 20:10:00 +00:00
const onButtonClick = useCallback(
() => addCondition(new ConditionLocation(mapViewHook.mapArea)),
2021-05-23 14:20:53 +00:00
[mapViewHook, addCondition],
2021-05-07 03:02:20 +00:00
)
2021-04-30 20:10:00 +00:00
return (
<BoxMap
mapViewHook={mapViewHook}
2021-05-07 14:30:12 +00:00
header={
2021-05-17 23:33:08 +00:00
<span>
2021-05-18 00:04:06 +00:00
{strings.searchBy}
2021-05-17 23:33:08 +00:00
&nbsp;
<FontAwesomeIcon icon={faLocationArrow}/>
2021-05-17 23:33:08 +00:00
&nbsp;
2021-05-18 00:04:06 +00:00
{strings.byZone}
2021-05-17 23:33:08 +00:00
</span>
2021-05-07 14:30:12 +00:00
}
button={
<ButtonIconOnly
icon={faPlus}
color={"Green"}
onClick={onButtonClick}
2021-04-30 20:10:00 +00:00
/>
}
{...props}
/>
2021-04-30 20:10:00 +00:00
)
}