Refactor InterFaces component to use updated Script type and streamline interface/port handling for better clarity

This commit is contained in:
Bram Suurd 2024-11-06 17:29:10 +01:00
parent 76cf85293c
commit 5a633a145a

View File

@ -2,11 +2,7 @@ import { Button, buttonVariants } from "@/components/ui/button";
import handleCopy from "@/components/handleCopy";
import { cn } from "@/lib/utils";
import { ClipboardIcon } from "lucide-react";
interface Item {
interface?: string;
port?: number;
}
import { Script } from "@/lib/types";
const CopyButton = ({
label,
@ -24,19 +20,18 @@ const CopyButton = ({
</span>
);
export default function InterFaces({ item }: { item: Item }) {
const { interface: iface, port } = item;
export default function InterFaces({item} : {item : Script}) {
return (
<div className="flex flex-col gap-2">
{iface || (port && port !== 0) ? (
{item.interface_port != null ? (
<div className="flex items-center justify-end">
<h2 className="mr-2 text-end text-lg font-semibold">
{iface ? "Interface:" : "Default Port:"}
{"Default Interface:"}
</h2>{" "}
<CopyButton
label={iface ? "interface" : "port"}
value={iface || port!}
label={"default interface"}
value={item.interface_port}
/>
</div>
) : null}