From a473719eeeaf234abc60b1709b09d7cc5011a40c Mon Sep 17 00:00:00 2001 From: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com> Date: Wed, 19 Jun 2024 13:49:45 +0530 Subject: [PATCH] feat: XM template filters (#2745) Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com> Co-authored-by: Johannes Co-authored-by: Matti Nannt --- .../components/TemplateContainer.tsx | 11 +- .../surveys/templates/page.tsx | 18 +- .../surveys/components/SurveyStarter.tsx | 33 -- .../[environmentId]/surveys/page.tsx | 34 +- apps/web/playwright/js.spec.ts | 8 +- packages/js/index.html | 2 +- packages/lib/templates.ts | 514 ++++++++++++++---- packages/types/product.ts | 5 +- packages/types/templates.ts | 19 +- packages/ui/SearchBox/index.tsx | 4 +- .../components/StartFromScratchTemplate.tsx | 57 ++ .../ui/TemplateList/components/Template.tsx | 58 ++ .../components/TemplateFilters.tsx | 64 +++ .../TemplateList/components/TemplateTags.tsx | 103 ++++ packages/ui/TemplateList/index.tsx | 246 +++------ packages/ui/TemplateList/lib/utils.ts | 25 +- 16 files changed, 862 insertions(+), 339 deletions(-) delete mode 100644 apps/web/app/(app)/environments/[environmentId]/surveys/components/SurveyStarter.tsx create mode 100644 packages/ui/TemplateList/components/StartFromScratchTemplate.tsx create mode 100644 packages/ui/TemplateList/components/Template.tsx create mode 100644 packages/ui/TemplateList/components/TemplateFilters.tsx create mode 100644 packages/ui/TemplateList/components/TemplateTags.tsx diff --git a/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/templates/components/TemplateContainer.tsx b/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/templates/components/TemplateContainer.tsx index a98cdbbc69..9433e8b2d7 100644 --- a/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/templates/components/TemplateContainer.tsx +++ b/apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/templates/components/TemplateContainer.tsx @@ -4,8 +4,8 @@ import { MenuBar } from "@/app/(app)/(survey-editor)/environments/[environmentId import { useState } from "react"; import { customSurvey } from "@formbricks/lib/templates"; import type { TEnvironment } from "@formbricks/types/environment"; -import type { TProduct } from "@formbricks/types/product"; -import type { TTemplate } from "@formbricks/types/templates"; +import type { TProduct, TProductConfigChannel, TProductConfigIndustry } from "@formbricks/types/product"; +import type { TTemplate, TTemplateRole } from "@formbricks/types/templates"; import { TUser } from "@formbricks/types/user"; import { PreviewSurvey } from "@formbricks/ui/PreviewSurvey"; import { SearchBox } from "@formbricks/ui/SearchBox"; @@ -17,13 +17,14 @@ type TemplateContainerWithPreviewProps = { product: TProduct; environment: TEnvironment; user: TUser; + prefilledFilters: (TProductConfigChannel | TProductConfigIndustry | TTemplateRole | null)[]; }; export const TemplateContainerWithPreview = ({ - environmentId, product, environment, user, + prefilledFilters, }: TemplateContainerWithPreviewProps) => { const initialTemplate = customSurvey; const [activeTemplate, setActiveTemplate] = useState(initialTemplate); @@ -35,7 +36,7 @@ export const TemplateContainerWithPreview = ({
-
+

Create a new survey