"use client";

import { Dialog, DialogActions, DialogContent } from "@mui/material";
import Form from "./Form";
import SaveIcon from "@mui/icons-material/Save";
import { LoadingButton } from "@mui/lab";
import { useState } from "react";

const ChangePass = ({ open, setOpen }) => {
    const [loading, setLoading] = useState(false);

    const handleCloseForm = () => {
        setOpen(false);
    };

    return (
        <Dialog maxWidth="xs" fullWidth={true} open={open}>
            <DialogContent dividers>
                <Form handleCloseForm={handleCloseForm} setLoading={setLoading} />
            </DialogContent>
            <DialogActions>
                <LoadingButton
                    loading={loading}
                    variant="outlined"
                    color="secondary"
                    size="large"
                    onClick={handleCloseForm}
                >
                    بستن
                </LoadingButton>
                <LoadingButton
                    type="submit"
                    loading={loading}
                    form="ChangePassword"
                    size="large"
                    autoFocus
                    variant="contained"
                    loadingPosition="end"
                    endIcon={<SaveIcon />}
                >
                    تغییر
                </LoadingButton>
            </DialogActions>
        </Dialog>
    );
};
export default ChangePass;
