blob: 02be282ff4b553ee418a341e3aa08b21a2f14e97 [file] [log] [blame]
gio48679462025-05-21 04:27:27 +00001import { accessSchema, NodeType } from "@/lib/state";
gioa2a845c2025-05-08 11:27:14 +00002import { ReactElement } from "react";
3import { SiGithub, SiMongodb, SiPostgresql } from "react-icons/si";
4import { GrServices } from "react-icons/gr";
5import { GoFileDirectoryFill } from "react-icons/go";
6import { TbWorldWww } from "react-icons/tb";
7import { PiNetwork } from "react-icons/pi";
8import { AiOutlineGlobal } from "react-icons/ai";
gio48679462025-05-21 04:27:27 +00009import { Terminal } from "lucide-react";
10import { z } from "zod";
gio5f2f1002025-03-20 18:38:48 +040011
gio0b4002c2025-05-11 15:48:51 +000012type Props = {
13 type: NodeType | undefined;
14 className?: string;
15};
16
17export function Icon({ type, className }: Props): ReactElement {
giod0026612025-05-08 13:00:36 +000018 switch (type) {
19 case "app":
gio0b4002c2025-05-11 15:48:51 +000020 return <GrServices className={className} />;
giod0026612025-05-08 13:00:36 +000021 case "github":
gio0b4002c2025-05-11 15:48:51 +000022 return <SiGithub className={className} />;
giod0026612025-05-08 13:00:36 +000023 case "gateway-https":
gio0b4002c2025-05-11 15:48:51 +000024 return <TbWorldWww className={className} />;
giod0026612025-05-08 13:00:36 +000025 case "gateway-tcp":
gio0b4002c2025-05-11 15:48:51 +000026 return <PiNetwork className={className} />;
giod0026612025-05-08 13:00:36 +000027 case "mongodb":
gio0b4002c2025-05-11 15:48:51 +000028 return <SiMongodb className={className} />;
giod0026612025-05-08 13:00:36 +000029 case "postgresql":
gio0b4002c2025-05-11 15:48:51 +000030 return <SiPostgresql className={className} />;
giod0026612025-05-08 13:00:36 +000031 case "volume":
gio0b4002c2025-05-11 15:48:51 +000032 return <GoFileDirectoryFill className={className} />;
giod0026612025-05-08 13:00:36 +000033 case "network":
gio0b4002c2025-05-11 15:48:51 +000034 return <AiOutlineGlobal className={className} />;
giod0026612025-05-08 13:00:36 +000035 default:
36 throw new Error(`MUST NOT REACH! ${type}`);
37 }
38}
gio48679462025-05-21 04:27:27 +000039
40export function AccessType({ type, className }: { type: z.infer<typeof accessSchema>["type"]; className?: string }) {
41 switch (type) {
42 case "https":
43 return <TbWorldWww className={className} />;
44 case "ssh":
45 return <Terminal className={className} />;
46 case "tcp":
47 case "udp":
48 return <PiNetwork className={className} />;
49 case "postgresql":
50 return <SiPostgresql className={className} />;
51 case "mongodb":
52 return <SiMongodb className={className} />;
53 }
54}