import { useState } from "react"; import { Wand2 } from "lucide-react"; import Button from "../twui/layout/Button"; import fetchApi from "../twui/utils/fetch/fetchApi"; import type { ApiReqParams } from "@/src/types"; type Props = { onGrab?: (ip: string) => void; }; export default function GrabNextSubnetButton({ onGrab }: Props) { const [grabbing, setGrabbing] = useState(false); function grabNextSubnet() { setGrabbing(true); fetchApi( `/api/admin/grab-next-available-private-ip`, { method: "POST" }, ) .then((res) => { if (res?.success && res.msg) { onGrab?.(res.msg); } }) .finally(() => { setGrabbing(false); }); } return ( ); }