mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-28 17:40:45 -05:00
21f393f402
* added intro and surveySelect page * added home page and wrapper component * added spreadsheet select * added data write functionality and added integration schema model * improved UX * reworked UI * added google sheet integration * removed some unused code * added user email * UI tweaks * fixed build issues and made added question to top of spreadsheets * adds refreshSheets and added empty survey/spreadsheets text * restored pnpm-lock * added duplicate sheet warning * move process.env to t3env * move migration * update docs link, add note to show that sheets integration is not configured * Add simple docs page for google-sheets * added session check * restored pnpm-lock * Merge branch 'main' of github.com:formbricks/formbricks into Integration/Google-sheet * added google sheet env variables to runtimeEnv --------- Co-authored-by: Johannes <johannes@formbricks.com> Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import "server-only";
|
|
|
|
import { prisma } from "@formbricks/database";
|
|
import { Prisma } from "@prisma/client";
|
|
import { DatabaseError } from "@formbricks/types/v1/errors";
|
|
import { TIntegration } from "@formbricks/types/v1/integrations";
|
|
import { cache } from "react";
|
|
|
|
export async function createOrUpdateIntegration(
|
|
environmentId: string,
|
|
integrationData: any
|
|
): Promise<TIntegration> {
|
|
try {
|
|
const integration = await prisma.integration.upsert({
|
|
where: {
|
|
type_environmentId: {
|
|
environmentId,
|
|
type: integrationData.type,
|
|
},
|
|
},
|
|
update: {
|
|
...integrationData,
|
|
environment: { connect: { id: environmentId } },
|
|
},
|
|
create: {
|
|
...integrationData,
|
|
environment: { connect: { id: environmentId } },
|
|
},
|
|
});
|
|
return integration;
|
|
} catch (error) {
|
|
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
|
console.log(error);
|
|
throw new DatabaseError("Database operation failed");
|
|
}
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
export const getIntegrations = cache(async (environmentId: string): Promise<TIntegration[]> => {
|
|
try {
|
|
const result = await prisma.integration.findMany({
|
|
where: {
|
|
environmentId,
|
|
},
|
|
});
|
|
return result;
|
|
} catch (error) {
|
|
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
|
throw new DatabaseError("Database operation failed");
|
|
}
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
export const deleteIntegration = async (integrationId: string): Promise<void> => {
|
|
try {
|
|
await prisma.integration.delete({
|
|
where: {
|
|
id: integrationId,
|
|
},
|
|
});
|
|
} catch (error) {
|
|
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
|
throw new DatabaseError("Database operation failed");
|
|
}
|
|
|
|
throw error;
|
|
}
|
|
};
|