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

47 lines
1.3 KiB
JavaScript
Raw Normal View History

import React, { useCallback } from "react"
2021-04-29 14:58:31 +00:00
import BoxFull from "../base/BoxFull"
2021-05-11 14:37:15 +00:00
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faAt } from "@fortawesome/free-solid-svg-icons"
2021-04-29 14:58:31 +00:00
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
import FormInlineUser from "./FormInlineUser"
2021-05-23 14:20:53 +00:00
import { ConditionUser } from "../../objects/Condition"
import useStrings from "../../hooks/useStrings"
2021-04-29 14:23:11 +00:00
2021-04-29 14:58:31 +00:00
/**
* A {@link BoxFull} that allows the user to select a Twitter user to search for, and then to add it as a
* {@link ConditionUser} of a RepositoryEditor.
2021-04-29 14:58:31 +00:00
*
* @param props - Additional props to pass to the box.
* @returns {JSX.Element}
* @constructor
*/
2021-04-29 14:23:11 +00:00
export default function BoxConditionUser({ ...props }) {
2021-05-11 14:37:15 +00:00
const { addCondition } = useRepositoryEditor()
const strings = useStrings()
2021-04-29 14:23:11 +00:00
const submit = useCallback(
value => addCondition(new ConditionUser(value)),
2021-05-23 14:20:53 +00:00
[addCondition],
)
2021-04-29 14:23:11 +00:00
return (
2021-05-17 23:33:08 +00:00
<BoxFull
header={
<span>
2021-05-18 00:04:06 +00:00
{strings.searchBy}
2021-05-17 23:33:08 +00:00
&nbsp;
<FontAwesomeIcon icon={faAt}/>
&nbsp;
2021-05-18 00:04:06 +00:00
{strings.byUser}
2021-05-17 23:33:08 +00:00
</span>
}
{...props}
>
<FormInlineUser
submit={submit}
/>
2021-04-29 14:23:11 +00:00
</BoxFull>
)
}