- Made number of approvers dynamic with many select inputs as needed - Tracking approval select input changes with step.assignees - Fetching teachers and corporates from backend - Responsive styling when rendering several select inputs
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import {Module} from ".";
|
|
import Option from "./option";
|
|
import { CorporateUser, MasterCorporateUser, TeacherUser, userTypeLabels } from "./user";
|
|
|
|
export interface ApprovalWorkflow {
|
|
id: string,
|
|
name: string,
|
|
entityId: string,
|
|
modules: Module[],
|
|
status: ApprovalWorkflowStatus,
|
|
steps: WorkflowStep[],
|
|
}
|
|
|
|
export type StepType = "form-intake" | "approval-by";
|
|
export const StepTypeLabel: Record<StepType, string> = {
|
|
"form-intake": "Form Intake",
|
|
"approval-by": "Approval",
|
|
};
|
|
|
|
type AssigneesType = TeacherUser["type"] | CorporateUser["type"] | MasterCorporateUser["type"];
|
|
|
|
export interface WorkflowStep {
|
|
key?: number,
|
|
stepType?: StepType,
|
|
stepNumber: number,
|
|
completed?: boolean,
|
|
completedBy?: string,
|
|
assignees?: (string | null | undefined)[]; // bit of an hack, but allowing null or undefined values allows us to match one to one the select input components with the assignees array. And since select inputs allow undefined or null values, it is allowed here too, but must validate required input before form submission
|
|
assigneesType?: AssigneesType,
|
|
editView?: boolean,
|
|
firstStep?: boolean,
|
|
currentStep?: boolean,
|
|
finalStep?: boolean,
|
|
selected?: boolean,
|
|
requestedBy?: string,
|
|
//requestedBy: TeacherUser | CorporateUser | MasterCorporateUser,
|
|
onDelete?: () => void;
|
|
onClick?: React.MouseEventHandler<HTMLDivElement>
|
|
}
|
|
|
|
export function getUserTypeLabel(type: AssigneesType | undefined): string {
|
|
if (type) return userTypeLabels[type];
|
|
return '';
|
|
}
|
|
|
|
export type ApprovalWorkflowStatus = "approved" | "pending" | "rejected";
|
|
export const ApprovalWorkflowStatusLabel: Record<ApprovalWorkflowStatus, string> = {
|
|
approved: "Approved",
|
|
pending: "Pending",
|
|
rejected: "Rejected",
|
|
}; |