fix: zapier integration not able to pull past responses (#1627)

This commit is contained in:
Matti Nannt
2023-11-16 13:07:30 +01:00
committed by GitHub
parent 0a252e5827
commit e9d8de3574
3 changed files with 16 additions and 4 deletions

View File

@@ -1,14 +1,19 @@
import { authenticateRequest } from "@/app/api/v1/auth";
import { responses } from "@/app/lib/api/response";
import { getResponsesByEnvironmentId } from "@formbricks/lib/response/service";
import { authenticateRequest } from "@/app/api/v1/auth";
import { DatabaseError } from "@formbricks/types/errors";
import { NextRequest } from "next/server";
export async function GET(request: Request) {
export async function GET(request: NextRequest) {
const surveyId = request.nextUrl.searchParams.get("surveyId");
try {
const authentication = await authenticateRequest(request);
if (!authentication) return responses.notAuthenticatedResponse();
const responseArray = await getResponsesByEnvironmentId(authentication.environmentId!);
return responses.successResponse(responseArray);
let environmentResponses = await getResponsesByEnvironmentId(authentication.environmentId!);
if (surveyId) {
environmentResponses = environmentResponses.filter((response) => response.surveyId === surveyId);
}
return responses.successResponse(environmentResponses);
} catch (error) {
if (error instanceof DatabaseError) {
return responses.badRequestResponse(error.message);

View File

@@ -47,6 +47,11 @@ const nextConfig = {
destination: "/api/v1/management/surveys",
permanent: true,
},
{
source: "/api/v1/responses",
destination: "/api/v1/management/responses",
permanent: true,
},
{
source: "/api/v1/me",
destination: "/api/v1/management/me",

View File

@@ -1,6 +1,7 @@
import global from "@/styles/global.css?inline";
import preflight from "@/styles/preflight.css?inline";
import editorCss from "../../../ui/Editor/stylesEditorFrontend.css?inline";
import { isLight } from "@/lib/utils";
export const addStylesToDom = () => {
if (document.getElementById("formbricks__css") === null) {
@@ -19,6 +20,7 @@ export const addCustomThemeToDom = ({ brandColor }: { brandColor: string }) => {
styleElement.innerHTML = `
:root {
--fb-brand-color: ${brandColor};
${isLight(brandColor) ? "--fb-brand-text-color: black;" : "--fb-brand-text-color: white;"}
}
`;
document.head.appendChild(styleElement);