import { Button, InputAdornment, LinearProgress, ListSubheader, MenuItem, Select, Switch, TextField, } from "@mui/material"; import { Controller, SubmitHandler, UseFormReturn } from "react-hook-form"; import { FlakeBadge } from "../flakeBadge/flakeBadge"; import { createVm, useGetVmLogs } from "@/api/default/default"; import { VmConfig } from "@/api/model"; import { Dispatch, SetStateAction, useState } from "react"; import { toast } from "react-hot-toast"; interface VmPropLabelProps { children: React.ReactNode; } const VmPropLabel = (props: VmPropLabelProps) => (
{props.children}
); interface VmPropContentProps { children: React.ReactNode; } const VmPropContent = (props: VmPropContentProps) => (
{props.children}
); interface VmDetailsProps { vmConfig: VmConfig; formHooks: UseFormReturn; setVmUuid: Dispatch>; } export const ConfigureVM = (props: VmDetailsProps) => { const { vmConfig, formHooks, setVmUuid } = props; const { control, handleSubmit } = formHooks; const { cores, flake_attr, flake_url, graphics, memory_size } = vmConfig; const [isStarting, setStarting] = useState(false); const onSubmit: SubmitHandler = async (data) => { setStarting(true); console.log(data); const response = await createVm(data); const { uuid } = response?.data || null; setVmUuid(() => uuid); setStarting(false); if (response.statusText === "OK") { toast.success(("Joined @ " + uuid) as string); } else { toast.error("Could not join"); } }; return (
General
Flake Machine ( )} />
VM
CPU Cores } /> Graphics ( )} /> Memory Size ( MiB ), }} /> )} />
{isStarting && }
); };