import { Button, Modal } from "react-bootstrap"; import React, { useState } from "react"; import { FormattedMessage, useIntl } from "react-intl"; import { ImageInput } from "./ImageInput"; import cx from "classnames"; interface IProps { objectName?: string; isNew: boolean; isEditing: boolean; onToggleEdit: () => void; onSave: () => void; saveDisabled?: boolean; onDelete: () => void; onAutoTag?: () => void; autoTagDisabled?: boolean; onImageChange: (event: React.FormEvent) => void; onBackImageChange?: (event: React.FormEvent) => void; onImageChangeURL?: (url: string) => void; onBackImageChangeURL?: (url: string) => void; onClearImage?: () => void; onClearBackImage?: () => void; acceptSVG?: boolean; customButtons?: JSX.Element; classNames?: string; children?: JSX.Element | JSX.Element[]; } export const DetailsEditNavbar: React.FC = (props: IProps) => { const intl = useIntl(); const [isDeleteAlertOpen, setIsDeleteAlertOpen] = useState(false); function renderEditButton() { if (props.isNew) return; return ( ); } function renderSaveButton() { if (!props.isEditing) return; return ( ); } function renderDeleteButton() { if (props.isNew || props.isEditing) return; return ( ); } function renderBackImageInput() { if (!props.isEditing || !props.onBackImageChange) { return; } return ( ); } function renderAutoTagButton() { if (props.isNew || props.isEditing) return; if (props.onAutoTag) { return (
); } } function renderDeleteAlert() { return ( ); } return (
{renderEditButton()} {props.isEditing && props.onClearImage ? (
) : null} {renderBackImageInput()} {props.isEditing && props.onClearBackImage ? (
) : null} {renderAutoTagButton()} {props.customButtons} {renderSaveButton()} {renderDeleteButton()} {renderDeleteAlert()}
); };