- Refactor of workflow and steps types to differentiate between editView and normalView.
- Added side panel with steps details
This commit is contained in:
@@ -34,12 +34,7 @@ export const getServerSideProps = withIronSessionSsr(async ({ req, res }) => {
|
||||
if (shouldRedirectHome(user) || !["admin", "developer", "teacher", "corporate", "mastercorporate"].includes(user.type))
|
||||
return redirect("/")
|
||||
|
||||
/* const entityIDS = mapBy(user.entities, "id");
|
||||
const entities = await getEntitiesWithRoles(isAdmin(user) ? undefined : entityIDS);
|
||||
const allowedEntities = findAllowedEntities(user, entities, "view_approval_workflows"); */
|
||||
|
||||
|
||||
// replace later with await getApprovalWorkflow(id). Don't think a hook is needed here;
|
||||
// replace later with useApprovalWorkflows()
|
||||
const workflows = approvalWorkflowsData as ApprovalWorkflow[];
|
||||
|
||||
const allAssigneeIds: string[] = [
|
||||
@@ -47,8 +42,8 @@ export const getServerSideProps = withIronSessionSsr(async ({ req, res }) => {
|
||||
workflows
|
||||
.map(workflow => workflow.steps
|
||||
.map(step => step.assignees)
|
||||
.flat() as string[] // we are sure assignees coming from a db workflow are all valid strings.
|
||||
).flat() as string[]
|
||||
.flat()
|
||||
).flat()
|
||||
)
|
||||
];
|
||||
|
||||
@@ -166,10 +161,6 @@ export default function ApprovalWorkflows({ user, workflows, workflowsAssignees,
|
||||
};
|
||||
|
||||
const columns = [
|
||||
/* columnHelper.accessor("id", {
|
||||
header: "ID",
|
||||
cell: (info) => info.getValue(),
|
||||
}), */
|
||||
columnHelper.accessor("name", {
|
||||
header: "NAME",
|
||||
cell: (info) => (
|
||||
@@ -216,7 +207,7 @@ export default function ApprovalWorkflows({ user, workflows, workflowsAssignees,
|
||||
const steps = info.row.original.steps;
|
||||
const currentStep = steps.find((step) => !step.completed);
|
||||
|
||||
const assignees = currentStep?.assignees!.map((assigneeId) => {
|
||||
const assignees = currentStep?.assignees.map((assigneeId) => {
|
||||
const assignee = workflowsAssignees.find((user) => user.id === assigneeId);
|
||||
return assignee?.name || "Unknown Assignee";
|
||||
});
|
||||
@@ -245,7 +236,7 @@ export default function ApprovalWorkflows({ user, workflows, workflowsAssignees,
|
||||
return (
|
||||
<span className="font-medium">
|
||||
{currentStep
|
||||
? `Step ${currentStep.stepNumber}: ${StepTypeLabel[currentStep.stepType!]}`
|
||||
? `Step ${currentStep.stepNumber}: ${StepTypeLabel[currentStep.stepType]}`
|
||||
: "Completed"}
|
||||
</span>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user