import { useEffect } from "react"; import { showDialog } from "./Dialog"; import useLoading from "../hooks/useLoading"; import toastHelper from "./Toast"; import { userService } from "../services"; import "../less/confirm-reset-openid-dialog.less"; interface Props extends DialogProps {} const ConfirmResetOpenIdDialog: React.FC = ({ destroy }: Props) => { const resetBtnClickLoadingState = useLoading(false); useEffect(() => { // do nth }, []); const handleCloseBtnClick = () => { destroy(); }; const handleConfirmBtnClick = async () => { if (resetBtnClickLoadingState.isLoading) { return; } resetBtnClickLoadingState.setLoading(); try { await userService.patchUser({ resetOpenId: true, }); } catch (error) { toastHelper.error("Request reset open API failed."); return; } toastHelper.success("Reset open API succeeded."); handleCloseBtnClick(); }; return ( <>

Reset Open API

❗️The existing API will be invalidated and a new one will be generated, are you sure you want to reset?

Cancel Reset!
); }; function showConfirmResetOpenIdDialog() { showDialog( { className: "confirm-reset-openid-dialog", }, ConfirmResetOpenIdDialog ); } export default showConfirmResetOpenIdDialog;