Merge branch 'approval-workflows' into develop
This commit is contained in:
71
src/interfaces/approval.workflow.ts
Normal file
71
src/interfaces/approval.workflow.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { ObjectId } from "mongodb";
|
||||
import { Module } from ".";
|
||||
import { Type, User, userTypeLabels, userTypeLabelsShort } from "./user";
|
||||
|
||||
export interface ApprovalWorkflow {
|
||||
_id?: ObjectId,
|
||||
name: string,
|
||||
entityId: string,
|
||||
requester: User["id"],
|
||||
startDate: number,
|
||||
modules: Module[],
|
||||
examId?: string,
|
||||
status: ApprovalWorkflowStatus,
|
||||
steps: WorkflowStep[],
|
||||
}
|
||||
|
||||
export interface EditableApprovalWorkflow extends Omit<ApprovalWorkflow, "_id" | "steps"> {
|
||||
id: string,
|
||||
steps: EditableWorkflowStep[],
|
||||
}
|
||||
|
||||
export type StepType = "form-intake" | "approval-by";
|
||||
export const StepTypeLabel: Record<StepType, string> = {
|
||||
"form-intake": "Form Intake",
|
||||
"approval-by": "Approval",
|
||||
};
|
||||
|
||||
export interface WorkflowStep {
|
||||
stepType: StepType,
|
||||
stepNumber: number,
|
||||
completed: boolean,
|
||||
rejected?: boolean,
|
||||
completedBy?: User["id"],
|
||||
completedDate?: number,
|
||||
assignees: (User["id"])[];
|
||||
firstStep?: boolean,
|
||||
finalStep?: boolean,
|
||||
selected?: boolean,
|
||||
comments?: string,
|
||||
onClick?: React.MouseEventHandler<HTMLDivElement>
|
||||
}
|
||||
|
||||
export interface EditableWorkflowStep {
|
||||
key: number,
|
||||
stepType: StepType,
|
||||
stepNumber: number,
|
||||
completed: boolean,
|
||||
rejected?: boolean,
|
||||
completedBy?: User["id"],
|
||||
completedDate?: number,
|
||||
assignees: (User["id"] | 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
|
||||
firstStep: boolean,
|
||||
finalStep?: boolean,
|
||||
onDelete?: () => void;
|
||||
}
|
||||
|
||||
export function getUserTypeLabel(type: Type | undefined): string {
|
||||
if (type) return userTypeLabels[type];
|
||||
return '';
|
||||
}
|
||||
export function getUserTypeLabelShort(type: Type | undefined): string {
|
||||
if (type) return userTypeLabelsShort[type];
|
||||
return '';
|
||||
}
|
||||
|
||||
export type ApprovalWorkflowStatus = "approved" | "pending" | "rejected";
|
||||
export const ApprovalWorkflowStatusLabel: Record<ApprovalWorkflowStatus, string> = {
|
||||
approved: "Approved",
|
||||
pending: "Pending",
|
||||
rejected: "Rejected",
|
||||
};
|
||||
@@ -1,4 +1,11 @@
|
||||
export type Module = "reading" | "listening" | "writing" | "speaking" | "level";
|
||||
export const ModuleTypeLabels: Record<Module, string> = {
|
||||
reading: "Reading",
|
||||
listening: "Listening",
|
||||
writing: "Writing",
|
||||
speaking: "Speaking",
|
||||
level: "Level",
|
||||
};
|
||||
|
||||
export interface Step {
|
||||
min: number;
|
||||
|
||||
@@ -170,4 +170,24 @@ export interface Code {
|
||||
export type Type = "student" | "teacher" | "corporate" | "admin" | "developer" | "agent" | "mastercorporate";
|
||||
export const userTypes: Type[] = ["student", "teacher", "corporate", "admin", "developer", "agent", "mastercorporate"];
|
||||
|
||||
export const userTypeLabels: Record<Type, string> = {
|
||||
student: "Student",
|
||||
teacher: "Teacher",
|
||||
corporate: "Corporate",
|
||||
admin: "Admin",
|
||||
developer: "Developer",
|
||||
agent: "Agent",
|
||||
mastercorporate: "Master Corporate",
|
||||
};
|
||||
|
||||
export const userTypeLabelsShort: Record<Type, string> = {
|
||||
student: "",
|
||||
teacher: "Prof.",
|
||||
corporate: "Dir.",
|
||||
admin: "Admin",
|
||||
developer: "Dev.",
|
||||
agent: "Agent",
|
||||
mastercorporate: "Dir.",
|
||||
};
|
||||
|
||||
export type WithUser<T> = T extends { participants: string[] } ? Omit<T, "participants"> & { participants: User[] } : T;
|
||||
|
||||
Reference in New Issue
Block a user