import { AutocompleteItem, Select, Space, Title } from "@mantine/core" import React, { useEffect, useState } from "react" import { getipinterfaces } from "../js/utils"; import PortInput from "./PortInput"; import { UseFormReturnType } from "@mantine/form/lib/types"; interface ItemProps extends AutocompleteItem { netint: string; } const AutoCompleteItem = React.forwardRef( ({ netint, value, ...props }: ItemProps, ref) =>
( {netint} ) -{">"} {value}
); export default function PortAndInterface({ form, int_name, port_name, label }:{ form:UseFormReturnType, int_name:string, port_name:string, label?:string }) { const [ipInterfaces, setIpInterfaces] = useState([]); useEffect(()=>{ getipinterfaces().then(data => { setIpInterfaces(data.map(item => ({netint:item.name, value:item.addr, label:item.addr}))); }) },[]) return <> {label?<> {label} :null}