Show the whole Rule on one review card, with quiet flags for missing cards and Continue once each question has one.
This commit is contained in:
1 parent
cc878e3c19
commit
6e2e1915ae
30 files changed
+571
-218
No files matched your search
@@ -0,0 +1,90 @@
|
||||
import type {
|
||||
CommunicationMethodDetailEntry,
|
||||
ConflictManagementDetailEntry,
|
||||
CreateFlowState,
|
||||
DecisionApproachDetailEntry,
|
||||
MembershipMethodDetailEntry,
|
||||
} from "../../app/(app)/create/types";
|
||||
import type { TemplateFacetGroupKey } from "./templateReviewMapping";
|
||||
|
||||
function missingText(...values: readonly (string | undefined)[]): boolean {
|
||||
return values.some((value) => (value ?? "").trim().length === 0);
|
||||
}
|
||||
|
||||
function communicationMissingWords(
|
||||
saved: CommunicationMethodDetailEntry | undefined,
|
||||
): boolean {
|
||||
if (!saved) return true;
|
||||
return missingText(
|
||||
saved.corePrinciple,
|
||||
saved.logisticsAdmin,
|
||||
saved.codeOfConduct,
|
||||
);
|
||||
}
|
||||
|
||||
function membershipMissingWords(
|
||||
saved: MembershipMethodDetailEntry | undefined,
|
||||
): boolean {
|
||||
if (!saved) return true;
|
||||
return missingText(
|
||||
saved.eligibility,
|
||||
saved.joiningProcess,
|
||||
saved.expectations,
|
||||
);
|
||||
}
|
||||
|
||||
function decisionMissingWords(
|
||||
saved: DecisionApproachDetailEntry | undefined,
|
||||
): boolean {
|
||||
if (!saved) return true;
|
||||
return missingText(
|
||||
saved.corePrinciple,
|
||||
saved.stepByStepInstructions,
|
||||
saved.objectionsDeadlocks,
|
||||
);
|
||||
}
|
||||
|
||||
function conflictMissingWords(
|
||||
saved: ConflictManagementDetailEntry | undefined,
|
||||
): boolean {
|
||||
if (!saved) return true;
|
||||
return missingText(
|
||||
saved.corePrinciple,
|
||||
saved.processProtocol,
|
||||
saved.restorationFallbacks,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A review chip shows a warning when its value is missing meaning or signals,
|
||||
* or a card is missing its words.
|
||||
*/
|
||||
export function finalReviewChipHasWarning(
|
||||
state: CreateFlowState,
|
||||
groupKey: TemplateFacetGroupKey | null,
|
||||
overrideKey: string | null,
|
||||
): boolean {
|
||||
if (!groupKey || !overrideKey) return true;
|
||||
switch (groupKey) {
|
||||
case "coreValues": {
|
||||
const saved = state.coreValueDetailsByChipId?.[overrideKey];
|
||||
return missingText(saved?.meaning, saved?.signals);
|
||||
}
|
||||
case "communication":
|
||||
return communicationMissingWords(
|
||||
state.communicationMethodDetailsById?.[overrideKey],
|
||||
);
|
||||
case "membership":
|
||||
return membershipMissingWords(
|
||||
state.membershipMethodDetailsById?.[overrideKey],
|
||||
);
|
||||
case "decisionApproaches":
|
||||
return decisionMissingWords(
|
||||
state.decisionApproachDetailsById?.[overrideKey],
|
||||
);
|
||||
case "conflictManagement":
|
||||
return conflictMissingWords(
|
||||
state.conflictManagementDetailsById?.[overrideKey],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user