Files
formbricks/apps/web/modules/survey/lib/client-utils.ts
Anshuman Pandey f888aa8a19 feat: MQP (#6901)
Co-authored-by: Matti Nannt <matti@formbricks.com>
Co-authored-by: Johannes <johannes@formbricks.com>
Co-authored-by: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com>
Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com>
2025-11-28 12:36:17 +00:00

16 lines
730 B
TypeScript

import { TSurveyBlock } from "@formbricks/types/surveys/blocks";
import { TSurveyElement } from "@formbricks/types/surveys/elements";
export const copySurveyLink = (surveyUrl: string, singleUseId?: string): string => {
return singleUseId ? `${surveyUrl}?suId=${singleUseId}` : surveyUrl;
};
/**
* Derives a flat array of elements from the survey's blocks structure.
* This is the client-side equivalent of the server-side getElementsFromBlocks.
* @param blocks - Array of survey blocks
* @returns An array of TSurveyElement (pure elements without block-level properties)
*/
export const getElementsFromBlocks = (blocks: TSurveyBlock[] | undefined): TSurveyElement[] =>
blocks?.flatMap((block) => block.elements) ?? [];