import { FormInstance } from "antd";
import { FormDialog } from "@/components/FormDialog";
import { useDispatch, useSelector } from "react-redux";
import "./index.scss";
import { EllipsisTooltip } from "@/components/Encapsulation";
import NotFailNodeIcon from "@/assets/svg/common/not-fail-node.svg?react";
import NotWarningNodeIcon from "@/assets/svg/common/not-warning-node.svg?react";
import { NODEDIALOGTYPE } from "../../index";
import { cn, getUrl } from "@/lib/utils";
import eventBus, { eventTypes } from "@/utils/eventBus";
import { AppDispatch, RootState } from "@/store";
import { removeMaliciousNodeList, removeNodeDownList } from "@/store/web3Slice";
import { countryCodeMap } from "@/data";
export interface DialogConfig {
title: string;
desc: string;
successText: string;
}
export const ProxyItem: React.FC<{ proxyInfo: any; clasName?: string }> = (
props
) => {
const { code, exit = false } = props.proxyInfo;
return (
);
};
export const ClearNodeDialog = ({
open,
setOpen,
successHandle,
dialogLoading,
form,
type,
canSubmit,
}: {
open: boolean;
setOpen: (open: boolean) => void;
successHandle: () => void;
dialogLoading: boolean;
canSubmit: boolean;
form: FormInstance;
type: DialogConfig;
}) => {
const dispatch = useDispatch();
const { maliciousNodeList, nodeDownList } = useSelector(
(state: RootState) => state.web3Reducer
);
const [isClear, setIsClear] = useState(false);
const showDialog = (open: boolean) => {
setOpen(open);
};
const onSuccessHandle = () => {
successHandle();
setIsClear(true);
if (type.title === NODEDIALOGTYPE.ClearFailNode.title) {
nodeDownList.forEach((item) => {
dispatch(removeNodeDownList(item.name));
eventBus.emit(eventTypes.NODE_REMOVE, item.name);
});
} else if (type.title === NODEDIALOGTYPE.ClearWargingNode.title) {
maliciousNodeList.forEach((item) => {
dispatch(removeMaliciousNodeList(item.name));
eventBus.emit(eventTypes.NODE_REMOVE, item.name);
});
}
// showDialog(false);
};
const proxyList = useMemo(() => {
if (type.title === NODEDIALOGTYPE.ClearFailNode.title) {
return nodeDownList;
} else {
return maliciousNodeList;
}
}, [nodeDownList, maliciousNodeList, type.title]);
useEffect(() => {
if (!open) {
setIsClear(false);
}
}, [open]);
return (
{proxyList.length > 0 ? (
proxyList
.filter((item: any) => item?.name)
.map((item: any) => {
return
;
})
) : (
{type.title === NODEDIALOGTYPE.ClearFailNode.title ? (
) : (
)}
{type.title === NODEDIALOGTYPE.ClearFailNode.title
? "暂无掉线节点"
: "暂无恶意节点"}
)}
);
};