"use client";

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

const ChangePassword = ({ 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>
        <Button
          disabled={loading}
          variant="outlined"
          color="secondary"
          size="large"
          onClick={handleCloseForm}
        >
          بستن
        </Button>
        <Button
          type="submit"
          disabled={loading}
          form="ChangePassword"
          size="large"
          autoFocus
          variant="contained"
          endIcon={<SaveIcon />}
        >
          تغییر
        </Button>
      </DialogActions>
    </Dialog>
  );
};
export default ChangePassword;
