mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-11 10:38:11 -06:00
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>
16 lines
730 B
TypeScript
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) ?? [];
|