Improve code quality

This commit is contained in:
2024-01-03 19:23:35 +01:00
parent c880c5e6bb
commit 85dcb06014
3 changed files with 6 additions and 8 deletions

View File

@ -23,10 +23,10 @@ interface DetailsProps {
}
export function NetworkDetails(p: DetailsProps): React.ReactElement {
const [cardsList, setCardsList] = React.useState<string[] | any>();
const [nicsList, setNicsList] = React.useState<string[] | any>();
const load = async () => {
setCardsList(await ServerApi.GetNetworksList());
setNicsList(await ServerApi.GetNetworksList());
};
return (
@ -34,7 +34,7 @@ export function NetworkDetails(p: DetailsProps): React.ReactElement {
loadKey={"1"}
load={load}
errMsg="Failed to load the list of host network cards!"
build={() => <NetworkDetailsInner cardsList={cardsList} {...p} />}
build={() => <NetworkDetailsInner nicsList={nicsList} {...p} />}
/>
);
}
@ -47,7 +47,7 @@ enum NetTab {
Danger,
}
type DetailsInnerProps = DetailsProps & { cardsList: string[] };
type DetailsInnerProps = DetailsProps & { nicsList: string[] };
function NetworkDetailsInner(p: DetailsInnerProps): React.ReactElement {
const [currTab, setCurrTab] = React.useState(NetTab.General);
@ -176,7 +176,7 @@ function NetworkDetailsTabGeneral(p: DetailsInnerProps): React.ReactElement {
value={p.net.device}
options={[
{ label: "Default interface", value: undefined },
...p.cardsList.map((d) => {
...p.nicsList.map((d) => {
return { label: d, value: d };
}),
]}