mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
fix(work-orders): preserve comment draft until mutation succeeds
This commit is contained in:
parent
1b5b4014d1
commit
0682b47678
3 changed files with 11 additions and 7 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue