w-funnel/src/components/admin/builder/forms/variants/utils.ts
dev.daminik00 5aea1c8a09 fix
2025-10-01 16:47:04 +02:00

29 lines
650 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { VariantDefinition, VariantCondition } from "./types";
/**
* Гарантирует что у варианта есть condition
*/
export function ensureCondition(
variant: VariantDefinition,
fallbackScreenId: string
): VariantCondition {
const [condition] = variant.conditions;
if (!condition) {
return {
screenId: fallbackScreenId,
operator: "includesAny",
optionIds: [],
};
}
return condition;
}
/**
* Проверяет является ли экран list экраном
*/
export function isListScreen(screen: { template: string }): boolean {
return screen.template === "list";
}