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>(

View File

@@ -67,11 +67,18 @@ export type FormFieldType =
| "TIN";
export interface FieldCondition {
field: string;
/** Omitted when `anyOf` is used instead — see below. */
field?: string;
equals?: string | number | boolean;
notEquals?: string | number | boolean;
in?: (string | number)[];
isSet?: boolean;
/**
* Holds when ANY listed condition holds — for a value that can live on one
* of several mutually-exclusive fields (e.g. a rank split by department).
* `field`/`equals`/etc are ignored when this is present.
*/
anyOf?: FieldCondition[];
}
export interface FormFieldConfig {