Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 committed Dec 23, 2024
1 parent 6b731f9 commit ce9b9d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
};
Expand All @@ -56,14 +56,9 @@ export const EditDeploymentSection: React.FC<EditDeploymentSectionProps> = ({
.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 }>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ import { ReleaseDistributionGraphPopover } from "./ReleaseDistributionPopover";
type Environment = RouterOutputs["environment"]["bySystemId"][number];
type Deployment = NonNullable<RouterOutputs["deployment"]["bySlug"]>;

type EnvHeaderProps = {
environment: Environment;
deployment: Deployment;
};
type EnvHeaderProps = { environment: Environment; deployment: Deployment };

const EnvHeader: React.FC<EnvHeaderProps> = ({ environment, deployment }) => {
const { workspaceSlug } = useParams<{ workspaceSlug: string }>();
Expand Down

0 comments on commit ce9b9d8

Please sign in to comment.