import CloseIcon from "@mui/icons-material/Close"; import { Alert, AppBar, Button, Dialog, Grid, IconButton, Toolbar, Typography, } from "@mui/material"; import React from "react"; import { InboxEntry } from "../api/InboxApi"; import { Movement } from "../api/MovementsApi"; import { AsyncFileViewerWidget } from "../widgets/FileViewerWidget"; import { SelectMovementWidget } from "../widgets/SelectMovementWidget"; import { AmountWidget } from "../widgets/AmountWidget"; import { fmtDateFromTime } from "../utils/DateUtils"; export function AttachInboxEntryToMovementDialog(p: { open: boolean; entry: InboxEntry; onSelected: (m: Movement) => void; onClose: () => void; }): React.ReactElement { const [value, setValue] = React.useState(); const handleSubmit = () => { if (!value) return; p.onSelected(value); }; return ( Attach inbox entry to movement {p.entry.amount !== undefined && ( <> Amount: )} {p.entry.label && <>Label: {p.entry.label}} {p.entry.time && <>Date: {fmtDateFromTime(p.entry.time)}} {Number.isFinite(p.entry.amount) && value !== undefined && p.entry.amount !== value.amount && ( Amount mismatch! )} ); }