Skip to content

Commit

Permalink
resolve merge conflicts dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
ShubhamPalriwala committed Jul 17, 2023
1 parent b4eeffb commit 599f26c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import ActionClassesTable from "@/app/environments/[environmentId]/(actionsAndAt
import ActionClassDataRow from "@/app/environments/[environmentId]/(actionsAndAttributes)/actions/ActionRowData";
import ActionTableHeading from "@/app/environments/[environmentId]/(actionsAndAttributes)/actions/ActionTableHeading";
import { getActionClasses } from "@formbricks/lib/services/action";
import { Metadata } from "next";

export const metadata: Metadata = {
title: "Actions",
};

export default async function ActionClassesComponent({ params }) {
let actionClasses = await getActionClasses(params.environmentId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export default function AttributeDetailModal({
children: (
<AttributeSettingsTab
attributeClass={attributeClass}
environmentId={environmentId}
setOpen={setOpen}
/>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import { updatetAttributeClass } from "@formbricks/lib/services/attribute";
import { useState } from "react";

interface AttributeSettingsTabProps {
environmentId: string;
attributeClass: AttributeClass;
setOpen: (v: boolean) => void;
}

export default async function AttributeSettingsTab({
environmentId,
attributeClass,
setOpen,
}: AttributeSettingsTabProps) {
Expand All @@ -26,15 +24,15 @@ export default async function AttributeSettingsTab({
const onSubmit = async (data) => {
setisAttributeBeingSubmitted(true);
setOpen(false);
await updatetAttributeClass(environmentId, attributeClass.id, data);
await updatetAttributeClass(attributeClass.id, data);
router.refresh();
setisAttributeBeingSubmitted(false);
};

const handleArchiveToggle = async () => {
setisAttributeBeingSubmitted(true);
const data = { archived: !attributeClass.archived };
await updatetAttributeClass(environmentId, attributeClass.id, data);
await updatetAttributeClass(attributeClass.id, data);
setisAttributeBeingSubmitted(false);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import AttributeClassDataRow from "@/app/environments/[environmentId]/(actionsAn
import AttributeTableHeading from "@/app/environments/[environmentId]/(actionsAndAttributes)/attributes/AttributeTableHeading";
import HowToAddAttributesButton from "@/app/environments/[environmentId]/(actionsAndAttributes)/attributes/HowToAddAttributesButton";
import { getAttributeClasses } from "@formbricks/lib/services/attribute";
import { Metadata } from "next";

export const metadata: Metadata = {
title: "Attributes",
};

export default async function AttributesPage({ params }) {
let attributeClasses = await getAttributeClasses(params.environmentId);
Expand Down
4 changes: 1 addition & 3 deletions packages/lib/services/attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ export const getAttributeClasses = async (environmentId: string): Promise<TAttri
};

export const updatetAttributeClass = async (
environmentId: string,
attributeClassId: string,
data: { description?: string; archived?: boolean }
): Promise<TAttributeClass | null> => {
try {
let attributeClass = await prisma.attributeClass.update({
where: {
environmentId: environmentId,
id: attributeClassId,
},
data: {
Expand All @@ -58,7 +56,7 @@ export const updatetAttributeClass = async (
return transformedAttributeClass;
} catch (error) {
throw new DatabaseError(
`Database error when updating attribute class with id ${attributeClassId} for environment ${environmentId}`
`Database error when updating attribute class with id ${attributeClassId}`
);
}
};
6 changes: 3 additions & 3 deletions packages/types/v1/actions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import z from "zod";
import { ZEventClassNoCodeConfig } from "./eventClasses";
import { ZActionClassNoCodeConfig } from "./actionClasses";

export const ZAction = z.object({
id: z.string().cuid2(),
name: z.string(),
description: z.string(),
type: z.enum(["code", "noCode", "automatic"]),
noCodeConfig: z.union([ZEventClassNoCodeConfig, z.null()]),
noCodeConfig: z.union([ZActionClassNoCodeConfig, z.null()]),
environmentId: z.string(),
actionCount: z.number(),
createdAt: z.date(),
Expand All @@ -18,7 +18,7 @@ export type TAction = z.infer<typeof ZAction>;
export const ZActionInput = z.object({
name: z.string(),
description: z.union([z.string(), z.null()]),
noCodeConfig: z.union([ZEventClassNoCodeConfig, z.null()]),
noCodeConfig: z.union([ZActionClassNoCodeConfig, z.null()]),
type: z.enum(["code", "noCode", "automatic"]),
});

Expand Down

0 comments on commit 599f26c

Please sign in to comment.