import React from "react"; import { toast } from "sonner"; import { AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "src/components/ui/alert-dialog"; import { Label } from "src/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "src/components/ui/select"; import { useInfo } from "src/hooks/useInfo"; import { request } from "src/utils/request"; const RESET_KEY_OPTIONS = [ { value: "ALL", label: "All", description: "Clears both the scorer, network graph data, and node metrics", }, { value: "Scorer", label: "Scorer", description: "Clears the scores/penalties applied to nodes from past payment attempts.", }, { value: "NetworkGraph", label: "Network Graph", description: "Clears the cache of nodes on the network", }, { value: "NodeMetrics", label: "Node Metrics", description: "Clears last sync timestamps to do a full wallet or network graph re-scan when RGS is enabled", }, ]; export function ResetRoutingDataDialogContent() { const { mutate: reloadInfo } = useInfo(); const [resetKey, setResetKey] = React.useState(); async function resetRouter() { try { await request("/api/reset-router", { method: "POST", body: JSON.stringify({ key: resetKey }), headers: { "Content-Type": "application/json", }, }); await reloadInfo(); toast("🎉 Router reset"); } catch (error) { console.error(error); toast.error("Something went wrong", { description: "" + error, }); } } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); await resetRouter(); }; return ( Clear Routing Data

Are you sure you want to clear your routing data?

Clear Data Options

{RESET_KEY_OPTIONS.map((resetKey) => (

{resetKey.label} {" - "} {resetKey.description}

))}

After clearing, you'll need to login again to restart your node.

setResetKey(undefined)}> Cancel Confirm
); }