From ce9b9d8f3c060eceafd9378456f27d75fe3619ba Mon Sep 17 00:00:00 2001 From: Aditya Choudhari Date: Mon, 23 Dec 2024 13:28:10 -0500 Subject: [PATCH] code cleanup --- .../[deploymentSlug]/EditDeploymentSection.tsx | 17 ++++++----------- .../releases/DeploymentPageContent.tsx | 5 +---- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/EditDeploymentSection.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/EditDeploymentSection.tsx index c43e14ec..fdb2f26a 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/EditDeploymentSection.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/EditDeploymentSection.tsx @@ -4,7 +4,7 @@ import type { RouterOutputs } from "@ctrlplane/api"; import { useParams, useRouter } from "next/navigation"; import { z } from "zod"; -import * as schema from "@ctrlplane/db/schema"; +import * as SCHEMA from "@ctrlplane/db/schema"; import { Button } from "@ctrlplane/ui/button"; import { Form, @@ -34,12 +34,12 @@ import { ResourceConditionRender } from "~/app/[workspaceSlug]/(app)/_components import { api } from "~/trpc/react"; import { DeploymentResourcesDialog } from "./DeploymentResourcesDialog"; -const deploymentForm = z.object(schema.deploymentSchema.shape); +const schema = z.object(SCHEMA.deploymentSchema.shape); type System = RouterOutputs["system"]["list"]["items"][number]; type EditDeploymentSectionProps = { - deployment: schema.Deployment; + deployment: SCHEMA.Deployment; systems: System[]; workspaceId: string; }; @@ -56,14 +56,9 @@ export const EditDeploymentSection: React.FC = ({ .filter((e) => e.resourceFilter != null) .map((e) => ({ ...e, resourceFilter: e.resourceFilter! })) ?? []; - const form = useForm({ - schema: deploymentForm, - defaultValues: { - ...deployment, - resourceFilter: deployment.resourceFilter ?? undefined, - }, - mode: "onSubmit", - }); + const resourceFilter = deployment.resourceFilter ?? undefined; + const defaultValues = { ...deployment, resourceFilter }; + const form = useForm({ schema, defaultValues, mode: "onSubmit" }); const { handleSubmit, setError } = form; const { workspaceSlug } = useParams<{ workspaceSlug: string }>(); diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/DeploymentPageContent.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/DeploymentPageContent.tsx index 65d7a0d3..0f0f79d5 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/DeploymentPageContent.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/DeploymentPageContent.tsx @@ -47,10 +47,7 @@ import { ReleaseDistributionGraphPopover } from "./ReleaseDistributionPopover"; type Environment = RouterOutputs["environment"]["bySystemId"][number]; type Deployment = NonNullable; -type EnvHeaderProps = { - environment: Environment; - deployment: Deployment; -}; +type EnvHeaderProps = { environment: Environment; deployment: Deployment }; const EnvHeader: React.FC = ({ environment, deployment }) => { const { workspaceSlug } = useParams<{ workspaceSlug: string }>();