import { useTranslations } from "next-intl";
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
import KeyIcon from "@mui/icons-material/Key";
import { useState } from "react";
import ChangePasswordContent from "./ChangePasswordContent";

const ChangePassword = ({ rowId, mutate }) => {
    const t = useTranslations();
    const [openChnagePasswordDialog, setOpenChangePasswordDialog] = useState(false);

    return (
        <>
            <Tooltip title={t("ExpertMangement.change_password_tooltip")}>
                <IconButton
                    color="primary"
                    onClick={() => {
                        setOpenChangePasswordDialog(true);
                    }}
                >
                    <KeyIcon />
                </IconButton>
            </Tooltip>
            <Dialog
                fullWidth
                maxWidth={"xs"}
                open={openChnagePasswordDialog}
                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("ExpertMangement.change_password")}</DialogTitle>
                <ChangePasswordContent
                    rowId={rowId}
                    mutate={mutate}
                    setOpenChangePasswordDialog={setOpenChangePasswordDialog}
                />
            </Dialog>
        </>
    );
};
export default ChangePassword;
