Make data dynamic in workflow view. Add requester and startDate to workflows.

This commit is contained in:
Joao Correia
2025-01-24 14:14:07 +00:00
parent f6b0c96b3b
commit 41d09eaad8
10 changed files with 207 additions and 107 deletions

View File

@@ -1,11 +1,12 @@
import {Module} from ".";
import Option from "./option";
import { CorporateUser, MasterCorporateUser, TeacherUser, userTypeLabels } from "./user";
import { Module } from ".";
import { Type, User, userTypeLabels, userTypeLabelsShort } from "./user";
export interface ApprovalWorkflow {
id: string,
name: string,
entityId: string,
requester: User["id"],
startDate: number,
modules: Module[],
status: ApprovalWorkflowStatus,
steps: WorkflowStep[],
@@ -17,35 +18,34 @@ export const StepTypeLabel: Record<StepType, string> = {
"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,
completedBy?: User["id"],
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
assigneesType?: Type,
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 {
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",
};
};