generated from Luis/nextjs-python-web-template
clean up unused js parts
This commit is contained in:
@@ -3,30 +3,23 @@ import React, { useEffect, useState } from "react";
|
||||
import { VmConfig } from "@/api/model";
|
||||
import { useVms } from "@/components/hooks/useVms";
|
||||
|
||||
import { Alert, AlertTitle, Button } from "@mui/material";
|
||||
|
||||
import { useSearchParams } from "next/navigation";
|
||||
|
||||
import { createVm, inspectVm, useGetVmLogs } from "@/api/default/default";
|
||||
|
||||
import { LoadingOverlay } from "./loadingOverlay";
|
||||
import { FlakeBadge } from "../flakeBadge/flakeBadge";
|
||||
import { Log } from "./log";
|
||||
import { SubmitHandler, useForm } from "react-hook-form";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { ConfigureVM } from "./configureVM";
|
||||
import { VmBuildLogs } from "./vmBuildLogs";
|
||||
|
||||
interface ConfirmVMProps {
|
||||
url: string;
|
||||
handleBack: () => void;
|
||||
defaultFlakeAttr: string;
|
||||
}
|
||||
|
||||
export function ConfirmVM(props: ConfirmVMProps) {
|
||||
const { url, handleBack } = props;
|
||||
const { url, defaultFlakeAttr } = props;
|
||||
const formHooks = useForm<VmConfig>({
|
||||
defaultValues: {
|
||||
flake_url: url,
|
||||
flake_attr: "default",
|
||||
flake_attr: defaultFlakeAttr,
|
||||
cores: 4,
|
||||
graphics: true,
|
||||
memory_size: 2048,
|
||||
@@ -34,11 +27,12 @@ export function ConfirmVM(props: ConfirmVMProps) {
|
||||
});
|
||||
const [vmUuid, setVmUuid] = useState<string | null>(null);
|
||||
|
||||
const { setValue, watch, formState, handleSubmit } = formHooks;
|
||||
const { config, error, isLoading } = useVms({
|
||||
const { setValue, watch, formState } = formHooks;
|
||||
const { config, isLoading } = useVms({
|
||||
url,
|
||||
attr: watch("flake_attr"),
|
||||
attr: watch("flake_attr") || defaultFlakeAttr,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (config) {
|
||||
setValue("cores", config?.cores);
|
||||
@@ -51,44 +45,12 @@ export function ConfirmVM(props: ConfirmVMProps) {
|
||||
<div className="mb-2 flex w-full max-w-2xl flex-col items-center justify-self-center pb-2">
|
||||
{!formState.isSubmitted && (
|
||||
<>
|
||||
{/* {error && (
|
||||
<Alert severity="error" className="w-full max-w-2xl">
|
||||
<AlertTitle>Error</AlertTitle>
|
||||
An Error occurred - See details below
|
||||
</Alert>
|
||||
)} */}
|
||||
<div className="mb-2 w-full max-w-2xl">
|
||||
{isLoading && (
|
||||
<LoadingOverlay
|
||||
title={"Loading VM Configuration"}
|
||||
subtitle={<FlakeBadge flakeUrl={url} flakeAttr={url} />}
|
||||
/>
|
||||
<LoadingOverlay title={"Loading VM Configuration"} subtitle="" />
|
||||
)}
|
||||
|
||||
<ConfigureVM formHooks={formHooks} setVmUuid={setVmUuid} />
|
||||
|
||||
{/* {error && (
|
||||
<>
|
||||
<Button
|
||||
color="error"
|
||||
fullWidth
|
||||
variant="contained"
|
||||
onClick={handleBack}
|
||||
className="my-2"
|
||||
>
|
||||
Back
|
||||
</Button>
|
||||
<Log
|
||||
title="Log"
|
||||
lines={
|
||||
error?.response?.data?.detail
|
||||
?.map((err, idx) => err.msg.split("\n"))
|
||||
?.flat()
|
||||
.filter(Boolean) || []
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)} */}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user