import React, { useState } from "react"; import { Button, ButtonGroup, ButtonProps, Dialog, DialogActions, DialogContent, DialogProps, 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 AcceptSubmissionDialogProps = { onAccept: (comment?: string) => void; label: string; } & DialogProps; export function AcceptSubmissionDialog({ onAccept, label, ...props }: AcceptSubmissionDialogProps) { const { t } = useTranslation(); const [comment, setComment] = useState(""); const classes = useVerticalSpacing(3); return { t(label + ".accept.title") } { t(label + ".accept.info") } setComment(ev.target.value) } fullWidth label={ t("comments") } rows={3}/> } type DiscardSubmissionDialogProps = { onDiscard: (comment: string) => void; label: string; } & DialogProps; export function DiscardSubmissionDialog({ onDiscard, label, ...props }: DiscardSubmissionDialogProps) { const { t } = useTranslation(); const [comment, setComment] = useState(""); const classes = useVerticalSpacing(3); return { t(label + ".accept.title") } { t(label + ".accept.info") } setComment(ev.target.value) } fullWidth label={ t("comments") } rows={3}/> } 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 [menuAnchor, setMenuAnchor] = useState(null); 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(<> , document.getElementById("modals") as Element) } }