import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material";
import {useTranslations} from "next-intl";
import {useState} from "react";
import HistoryIcon from '@mui/icons-material/History';
import HistoryContent from "@/components/dashboard/loan-history/Form/HistoryForm/HistoryContent";

const History = ({rowId, mutate}) => {
    const t = useTranslations();
    const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
    return (
        <>
            <Tooltip title={t("LoanHistory.history")}>
                <IconButton
                    color="primary"
                    onClick={() => {
                        setOpenConfirmDialog(true)
                    }}
                >
                    <HistoryIcon/>
                </IconButton>
            </Tooltip>
            <Dialog scroll={'paper'} fullWidth maxWidth="xl" open={openConfirmDialog}
                    PaperProps={{sx: {boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'}}}>
                <DialogTitle>{t("LoanHistory.history")}</DialogTitle>
                <HistoryContent mutate={mutate} rowId={rowId} setOpenConfirmDialog={setOpenConfirmDialog}/>
            </Dialog>
        </>
    )

}
export default History;