Add rank selection and condition handling to certificate designer and requirements

This commit is contained in:
Nati
2026-08-24 07:39:24 +00:00
parent 1af7e90c21
commit 302c0242dd
7 changed files with 359 additions and 147 deletions

View File

@@ -558,14 +558,25 @@ export function validateSections(
}
/** Evaluates a config condition against the current form answers. */
interface ConditionLike {
field?: string;
equals?: unknown;
notEquals?: unknown;
in?: (string | number)[];
isSet?: boolean;
/** Holds when ANY listed sub-condition holds — see FieldCondition.anyOf. */
anyOf?: ConditionLike[];
}
export function conditionHolds(
condition:
| { field: string; equals?: unknown; notEquals?: unknown; in?: (string | number)[]; isSet?: boolean }
| undefined
| null,
condition: ConditionLike | undefined | null,
formData: Record<string, Record<string, unknown>>,
): boolean {
if (!condition?.field) return true;
if (!condition) return true;
if (condition.anyOf) {
return condition.anyOf.some((sub) => conditionHolds(sub, formData));
}
if (!condition.field) return true;
const value = condition.field
.split('.')
.reduce<unknown>(