diff --git a/src/components/shared/WorkflowDefinitionModal.tsx b/src/components/shared/WorkflowDefinitionModal.tsx index c8597d2..d928665 100644 --- a/src/components/shared/WorkflowDefinitionModal.tsx +++ b/src/components/shared/WorkflowDefinitionModal.tsx @@ -37,6 +37,8 @@ const stepSchema = z requires_comment: z.boolean().default(false), requires_attachment: z.boolean().default(false), sla_hours: z.number().optional().nullable(), + sla_warning_hours: z.number().optional().nullable(), + sla_escalation_hours: z.number().optional().nullable(), }) .superRefine((data, ctx) => { // Skip all assignee/action validation for terminal steps @@ -339,6 +341,8 @@ export const WorkflowDefinitionModal = ({ requires_comment: s.requires_comment || false, requires_attachment: s.requires_attachment || false, sla_hours: s.sla?.hours, + sla_warning_hours: s.sla?.warning_hours, + sla_escalation_hours: s.sla?.escalation_hours, })), transitions: (definition.transitions || []).map((t) => ({ from_step_code: t.from_step_code, @@ -393,13 +397,43 @@ export const WorkflowDefinitionModal = ({ ...data, source_module: selectedModuleNames, tenantId: tenantId || undefined, - // Strip terminal-step-only-hidden fields from the payload + // Strip fields based on step type and assignee type to prevent backend validation errors steps: data.steps?.map((step: any) => { if (step.step_type === "terminal") { - const { assignee_type, assignee_role, assignee_id, available_actions, ...rest } = step; + const { + assignee_type, + assignee_role, + assignee_id, + available_actions, + ...rest + } = step; return rest; } - return step; + + const cleanedStep = { ...step }; + + // Clean up assignee fields based on assignee_type + if (step.assignee_type === "originator") { + delete cleanedStep.assignee_role; + delete cleanedStep.assignee_id; + } else if (step.assignee_type === "role") { + delete cleanedStep.assignee_id; + } else if (step.assignee_type === "user") { + delete cleanedStep.assignee_role; + // Ensure ID is not an empty string which fails UUID validation + if (cleanedStep.assignee_id === "") { + delete cleanedStep.assignee_id; + } + } + + // Clean up SLA fields + ['sla_hours', 'sla_warning_hours', 'sla_escalation_hours'].forEach(field => { + if (cleanedStep[field] === 0 || cleanedStep[field] === null || cleanedStep[field] === "") { + delete cleanedStep[field]; + } + }); + + return cleanedStep; }), }; @@ -933,6 +967,41 @@ export const WorkflowDefinitionModal = ({ + + {watchedSteps[index]?.step_type !== "terminal" && ( +
diff --git a/src/pages/tenant/Documents.tsx b/src/pages/tenant/Documents.tsx
index 1b8f183..4e2b932 100644
--- a/src/pages/tenant/Documents.tsx
+++ b/src/pages/tenant/Documents.tsx
@@ -9,7 +9,9 @@ import {
type Column,
} from "@/components/shared";
import { documentService } from "@/services/document-service";
+import { moduleService } from "@/services/module-service";
import type { DocumentCategory, DocumentSummary } from "@/types/document";
+import type { MyModule } from "@/types/module";
import { Plus, Search } from "lucide-react";
const formatDate = (value?: string | null): string => {
@@ -39,6 +41,8 @@ const Documents = (): ReactElement => {
const [statusFilter, setStatusFilter] = useState
- Select a file to extract and auto-fill content below. -
-- File:{" "} - {versionFileName} -
-- Type:{" "} - {versionMimeType} -
-- Size:{" "} - {versionFileSize - ? `${(versionFileSize / 1024 / 1024).toFixed(2)} MB` - : "-"} -
-- Hash:{" "} - {versionFileHash - ? versionFileHash.substring(0, 16) + "..." - : "-"} +
+ Modify the document content or load it from an existing file attachment.
+ Extract text directly from an uploaded PDF or Word document. +
++ Select a reason category such as minor_edit, correction, etc. +
++ {isMajorVersion + ? "Incrementing to a major version indicates significant changes or a full document overhaul." + : `Turn on major versioning to increment to v${(parseInt((document?.current_version || "0.0").split(".")[0]) || 0) + 1}.0 instead of a minor revision.` + } +
+Reference information for current revision.
++ Creating a new draft revision will automatically trigger the following system actions: +
+