diff --git a/src/components/workflow/ResumeModal.tsx b/src/components/workflow/ResumeModal.tsx new file mode 100644 index 0000000..d73ae97 --- /dev/null +++ b/src/components/workflow/ResumeModal.tsx @@ -0,0 +1,114 @@ +import { useState } from 'react'; +import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog'; +import { Button } from '@/components/ui/button'; +import { Label } from '@/components/ui/label'; +import { Textarea } from '@/components/ui/textarea'; +import { Loader2, Play } from 'lucide-react'; +import { toast } from 'sonner'; +import { resumeWorkflow } from '@/services/workflowApi'; + +interface ResumeModalProps { + isOpen: boolean; + onClose: () => void; + requestId: string; + onSuccess?: () => void | Promise; +} + +export function ResumeModal({ isOpen, onClose, requestId, onSuccess }: ResumeModalProps) { + const [notes, setNotes] = useState(''); + const [submitting, setSubmitting] = useState(false); + + const handleSubmit = async () => { + try { + setSubmitting(true); + await resumeWorkflow(requestId, notes.trim() || undefined); + toast.success('Workflow resumed successfully'); + + // Wait for parent to refresh data before closing modal + if (onSuccess) { + await onSuccess(); + } + + setNotes(''); + onClose(); + } catch (error: any) { + console.error('Failed to resume workflow:', error); + toast.error(error?.response?.data?.error || error?.response?.data?.message || 'Failed to resume workflow'); + } finally { + setSubmitting(false); + } + }; + + const handleClose = () => { + if (!submitting) { + setNotes(''); + onClose(); + } + }; + + return ( + + + + + + Resume Workflow + + + +
+
+

+ Note: Resuming will restart TAT calculations and notifications. The workflow will continue from where it was paused. +

+
+ +
+ +