import React, { useState } from "react"; import { Button, ButtonGroup, Dialog, DialogActions, DialogContent, DialogTitle, Menu, MenuItem, TextField, Typography } from "@material-ui/core"; import { MenuDown, StickerCheckOutline, StickerRemoveOutline } from "mdi-material-ui"; import { useTranslation } from "react-i18next"; import { useVerticalSpacing } from "@/styles"; import { createPortal } from "react-dom"; type AcceptanceActionsProps = { onAccept: (comment?: string) => void; onDiscard: (comment: string) => void; label: string; } export function AcceptanceActions({ onAccept, onDiscard, label }: AcceptanceActionsProps) { const { t } = useTranslation(); const [isDiscardModalOpen, setDiscardModelOpen] = useState(false); const [isAcceptModalOpen, setAcceptModelOpen] = useState(false); const [comment, setComment] = useState(""); const [menuAnchor, setMenuAnchor] = useState(null); const classes = useVerticalSpacing(3); const handleAccept = () => { onAccept(comment); } const handleDiscard = () => { onDiscard(comment); } const handleAcceptModalClose = () => { setAcceptModelOpen(false); } const handleDiscardModalClose = () => { setDiscardModelOpen(false); } const handleDiscardAction = () => { setDiscardModelOpen(true); } const handleAcceptMenuOpen = (ev: React.MouseEvent) => { setMenuAnchor(ev.currentTarget); } const handleAcceptMenuClose = () => { setMenuAnchor(null); } const handleAcceptWithComment = () => { setAcceptModelOpen(true); setMenuAnchor(null); } const handleAcceptWithoutComment = () => { onAccept(); } return <> { t("accept-without-comments") } { t("accept-with-comments") } { createPortal(<> { t(label + ".discard.title") } { t(label + ".discard.info") } setComment(ev.target.value) } fullWidth label={ t("comments") } rows={3}/> { t(label + ".accept.title") } { t(label + ".accept.info") } setComment(ev.target.value) } fullWidth label={ t("comments") } rows={3}/> , document.getElementById("modals") as Element) } }