Give finished Rules a print path, folded launch counts, and a two-day follow-up.
Export is PDF, RULE.md, and Print on US Letter, with every shared term, no member names, and a takeaway that points at Ask an organizer. Finished Rules keep type and place so the team can read folded counts without a database, Umami can sit beside the app with no cookies, and the person who holds the pen gets working PDF and RULE.md links 48 hours later.
This commit is contained in:
1 parent
0efc907633
commit
d9c475a967
74 files changed
+2401
-630
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import type { CreateFlowState } from "../../app/(app)/create/types";
|
||||
import { KINDS, type Kind } from "./deckTypes";
|
||||
import { groupAnswersFromCreateFlowState } from "./groupAnswers";
|
||||
|
||||
const LOCATION_MAX = 200;
|
||||
|
||||
function isKind(value: string): value is Kind {
|
||||
return (KINDS as readonly string[]).includes(value);
|
||||
}
|
||||
|
||||
function trimmedLocation(raw: unknown): string | undefined {
|
||||
if (typeof raw !== "string") return undefined;
|
||||
const trimmed = raw.trim().replace(/\s+/g, " ");
|
||||
if (trimmed.length === 0) return undefined;
|
||||
return trimmed.slice(0, LOCATION_MAX);
|
||||
}
|
||||
|
||||
/** Place and main group type stored on a finished Rule for launch counts. */
|
||||
export function publishedRuleAnalyticsFromState(state: CreateFlowState): {
|
||||
communityLocation?: string;
|
||||
orgType?: Kind;
|
||||
} {
|
||||
const communityLocation = trimmedLocation(state.communityLocation);
|
||||
const orgType = groupAnswersFromCreateFlowState(state).mainKind ?? undefined;
|
||||
return {
|
||||
...(communityLocation ? { communityLocation } : {}),
|
||||
...(orgType ? { orgType } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
export function publishedRuleAnalyticsFromDocument(document: unknown): {
|
||||
communityLocation: string | null;
|
||||
orgType: string | null;
|
||||
} {
|
||||
if (!document || typeof document !== "object" || Array.isArray(document)) {
|
||||
return { communityLocation: null, orgType: null };
|
||||
}
|
||||
const row = document as Record<string, unknown>;
|
||||
const communityLocation = trimmedLocation(row.communityLocation) ?? null;
|
||||
const orgTypeRaw =
|
||||
typeof row.orgType === "string" ? row.orgType.trim() : "";
|
||||
const orgType = isKind(orgTypeRaw) ? orgTypeRaw : null;
|
||||
return { communityLocation, orgType };
|
||||
}
|
||||
Reference in new issue
Block a user