src/features/reviews/types.ts
Linked repository file from this build.
import type { ActorRef, DemoRole } from "@/lib/auth/actor";
export type { Actor, ActorRef, DemoRole } from "@/lib/auth/actor";
export const documentCategories = [
"Financial statements",
"Household Composition",
"Rent Receipts",
"Landlord statements",
"Notices Sent",
"eCIS Case Narrative",
"CIS Prints/Imaging",
"Employer Reported Income information",
"Evidence",
"Finding Memo",
"Other",
] as const;
export const workflowLabels = {
new_active: "Active",
awaiting_review: "Awaiting supervisor",
needs_changes: "Needs Changes",
awaiting_pec_approval: "Awaiting PEC",
awaiting_manager: "Awaiting manager",
awaiting_cao_response: "Awaiting CAO response",
released_to_reporting: "Released to reporting",
dropped: "Dropped",
} as const;
export type WorkflowState = keyof typeof workflowLabels;
export type ReviewOutcome = "" | "clean" | "error" | "drop";
export const roleLabels: Record<DemoRole, string> = {
admin: "Admin",
statistics: "Statistics",
examiner: "Examiner",
supervisor: "Supervisor",
pec: "PEC stakeholder",
program_manager: "Program manager",
};
export type NoteKind = "ordinary" | "pec";
export interface Note {
id: string;
body: string;
actor: ActorRef;
createdAt: string;
kind?: NoteKind;
updatedAt?: string;
fieldLink?: string;
}
export type PolicyDecision = "approve" | "deny" | "conditional";
export interface PecDecision {
decision: PolicyDecision;
policyNote: string;
actor: ActorRef;
createdAt: string;
}
export interface Activity {
id: string;
kind:
| "transition"
| "note"
| "validation"
| "calculation"
| "document"
| "edit"
| "policy_decision";
actor: ActorRef;
createdAt: string;
description: string;
from?: WorkflowState;
to?: WorkflowState;
noteId?: string;
policyNote?: string;
policyDecision?: PolicyDecision;
}
export interface ReviewIdentityPatch {
clientName?: string;
address?: string;
county?: string;
district?: string;
localAgency?: string;
sampleMonth?: string;
caseNumber?: string;
examiner?: string;
supervisor?: string;
}
export interface NegativeActionPatch {
negativeAction?: string;
noticeDate?: string;
actionDate?: string;
}
export interface Finding {
field: string;
message: string;
}
export interface RefusedFinding {
reason: string;
actor: ActorRef;
at: string;
}
export interface StoredFinding {
id: string;
field: string;
code: string;
message: string;
refused?: RefusedFinding;
}
export interface InputBlocker {
field: string;
code: string;
message: string;
}
export interface ValidationRun {
revision: number;
findings: StoredFinding[];
createdAt: string;
}
export interface ReviewDocument {
id: string;
filename: string;
name?: string;
category: (typeof documentCategories)[number];
description: string;
mimeType: string;
size: number;
storageKey: string;
actor: ActorRef;
createdAt: string;
}
export const dropKinds = [
"refusal_to_comply",
"failure_to_comply",
"not_subject_to_review",
] as const;
export type DropKind = (typeof dropKinds)[number];
export const dropKindLabels: Record<DropKind, string> = {
refusal_to_comply: "Refusal to comply",
failure_to_comply: "Failure to comply",
not_subject_to_review: "Not subject to review",
};
export interface Approval {
actor: ActorRef;
at: string;
}
export interface ReviewReceivedSnapshot<TFacts> {
facts: TFacts;
identity: ReviewIdentityPatch;
outcome: ReviewOutcome;
dropKind?: DropKind;
}
export const memoTypeLabels = {
under_threshold: "Error under threshold",
info: "Info memo",
timeliness_info: "Timeliness info memo",
benefit_error: "Positive or negative error finding",
timeliness_finding: "Timeliness finding",
} as const;
export interface ReviewMemo {
id: string;
body: string;
type?: keyof typeof memoTypeLabels;
actor: ActorRef;
createdAt: string;
reviewRevision: number;
outboundAt?: string;
}
export interface CaoResponse {
status: "agree" | "dispute" | "no_response";
rootCause: string;
note: string;
actor: ActorRef;
at: string;
}
export interface ReviewRecord<TFacts> {
id: string;
reviewNumber: string;
caseNumber: string;
program: string;
subtype: string;
sampleMonth: string;
clientName: string;
address: string;
county: string;
district: string;
localAgency: string;
examiner: string;
supervisor: string;
state: WorkflowState;
outcome: ReviewOutcome;
dropKind?: DropKind;
supervisorApproved?: Approval;
pecApproved?: Approval;
memoApproved?: Approval;
errorSummaryReleased?: Approval;
dropApproved?: Approval;
receivedSnapshots?: Partial<
Record<"examiner" | "supervisor" | "program_manager", ReviewReceivedSnapshot<TFacts>>
>;
caoResponse?: CaoResponse;
caoResponseDeadline?: string;
revision: number;
facts: TFacts;
notes: Note[];
documents: ReviewDocument[];
activity: Activity[];
validation?: ValidationRun;
pecDecision?: PecDecision;
conditionalNotes?: string;
appointment?: string;
memos?: ReviewMemo[];
}