diff --git a/src/app/(protected)/workorders/_components/detail/tabs/slide-over-comments-tab.tsx b/src/app/(protected)/workorders/_components/detail/tabs/slide-over-comments-tab.tsx index 22c5e6a1..1d13f890 100644 --- a/src/app/(protected)/workorders/_components/detail/tabs/slide-over-comments-tab.tsx +++ b/src/app/(protected)/workorders/_components/detail/tabs/slide-over-comments-tab.tsx @@ -141,7 +141,7 @@ type SlideOverCommentsTabProps = { isPending: boolean; currentUserId?: string | number; isUpdatePending?: boolean; - onSubmit: (text: string) => void; + onSubmit: (text: string, options?: { onSuccess?: () => void }) => void; onUpdateComment?: ( commentId: string | number, text: string, @@ -165,8 +165,7 @@ export function SlideOverCommentsTab({ const handlePost = () => { const text = commentText.trim(); if (!text || isReadOnly || isPending) return; - onSubmit(text); - setCommentText(""); + onSubmit(text, { onSuccess: () => setCommentText("") }); }; const startEdit = (comment: WorkOrderComment) => { diff --git a/src/app/(protected)/workorders/_components/detail/work-order-detail-sections.tsx b/src/app/(protected)/workorders/_components/detail/work-order-detail-sections.tsx index 2ca5217c..ccfbd520 100644 --- a/src/app/(protected)/workorders/_components/detail/work-order-detail-sections.tsx +++ b/src/app/(protected)/workorders/_components/detail/work-order-detail-sections.tsx @@ -34,7 +34,11 @@ type WorkOrderDetailsSectionProps = { onAssign: (userId: string | number, userName: string) => void; isAssignPending?: boolean; onDispatchClick: (dispatchId: string | number) => void; - onCommentSubmit: (text: string, commentType: "customer" | "internal") => void; + onCommentSubmit: ( + text: string, + commentType: "customer" | "internal", + options?: { onSuccess?: () => void }, + ) => void; isCommentPending: boolean; }; @@ -65,8 +69,9 @@ export function WorkOrderDetailsSection({ if (!commentText.trim()) { return; } - onCommentSubmit(commentText.trim(), activeTab === "customer" ? "customer" : "internal"); - setCommentText(""); + onCommentSubmit(commentText.trim(), activeTab === "customer" ? "customer" : "internal", { + onSuccess: () => setCommentText(""), + }); }; return ( diff --git a/src/app/(protected)/workorders/_components/detail/work-order-slide-over.tsx b/src/app/(protected)/workorders/_components/detail/work-order-slide-over.tsx index 7e2ecbbb..05f2ca41 100644 --- a/src/app/(protected)/workorders/_components/detail/work-order-slide-over.tsx +++ b/src/app/(protected)/workorders/_components/detail/work-order-slide-over.tsx @@ -271,7 +271,7 @@ export function WorkOrderSlideOver({ isPending={commentMutation.isPending} currentUserId={user?.id} isUpdatePending={updateCommentMutation.isPending} - onSubmit={(text) => commentMutation.mutate({ text })} + onSubmit={(text, options) => commentMutation.mutate({ text }, options)} onUpdateComment={(commentId, text, options) => updateCommentMutation.mutate({ commentId, text }, options) }