import { faAsterisk, faPencil, faSave } from "@fortawesome/free-solid-svg-icons" import { useTranslation } from "next-i18next" import { UsePromise, usePromise, UsePromiseStatus } from "../../generic/loading/promise" import { FestaIcon } from "../../generic/renderers/fontawesome" import { Tool } from "../../generic/toolbar/tool" import cursor from "../../../styles/cursor.module.css" import mood from "../../../styles/mood.module.css" import { Dispatch } from "react" export type ToolToggleEditingProps = { editing: boolean, setEditing: Dispatch, save: UsePromise, } /** * ToolBar {@link Tool} which allows the user to start editing an event and then save their changes. */ export function ToolToggleEditing({ editing, setEditing, save }: ToolToggleEditingProps) { const { t } = useTranslation() if (save.status === UsePromiseStatus.PENDING) { return ( ) } else if (editing) { return ( { save.run() setEditing(false) }} className={mood.positive} > ) } else { return ( { setEditing(true) }} > ) } }