This commit is contained in:
2026-09-20 10:49:14 +01:00
parent 3d122036ce
commit 6e3319b21c
23 changed files with 1331 additions and 223 deletions
@@ -0,0 +1,43 @@
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<ApiReqParams, { success: boolean; msg?: string }>(
`/api/admin/grab-next-available-private-ip`,
{ method: "POST" },
)
.then((res) => {
if (res?.success && res.msg) {
onGrab?.(res.msg);
}
})
.finally(() => {
setGrabbing(false);
});
}
return (
<Button
title="Grab Next Available Subnet"
variant="outlined"
color="primary"
beforeIcon={<Wand2 size={16} />}
loading={grabbing}
onClick={grabNextSubnet}
>
Grab Next Subnet
</Button>
);
}