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