29 lines
650 B
TypeScript
29 lines
650 B
TypeScript
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";
|
||
}
|