import { Button, Group, Modal, Notification, PasswordInput, Space, Switch } from "@mantine/core"; import { useForm } from "@mantine/form"; import { useState } from "react" import { ImCross } from "react-icons/im"; import { ChangePassword } from "../../js/models"; import { changepassword, okNotify } from "../../js/utils"; function ResetPasswordModal({ opened, onClose }:{ opened: boolean, onClose: () => void }) { const form = useForm({ initialValues: { password:"", expire:true }, validate:{ password: (value) => value !== ""? null : "Password is required" } }) const [loadingBtn, setLoadingBtn] = useState(false) const [error, setError] = useState(null) const submitRequest = async (values:ChangePassword) => { setLoadingBtn(true) await changepassword(values).then(res => { if(!res){ okNotify("Password change done!","The password of the firewall has been changed!") onClose() form.reset() }else{ setError(res) } }).catch( err => setError(err.toString())) setLoadingBtn(false) } return
{error?<> } color="red" onClose={()=>{setError(null)}}> Error: {error} :null}
} export default ResetPasswordModal;