feat : add toast too
CI / Verify (push) Successful in 1m24s
CI / Build immutable images and deploy (push) Successful in 1m57s

This commit is contained in:
2026-09-15 19:37:43 +07:00 Unverified
parent 860de2dc5d
commit fb152c12fe
2 changed files with 21 additions and 1 deletions
+20
View File
@@ -179,6 +179,26 @@ export function useAutosave<Value, Draft = Value>({
};
}, []);
useEffect(() => {
const toastId = `autosave-conflict:${guideId}:${scope}`;
if (conflictVersion === null) {
toast.dismiss(toastId);
return;
}
toast.error("Autosave ถูกหยุดชั่วคราว", {
id: toastId,
description: "มีผู้แก้ไขคนอื่นบันทึกข้อมูลส่วนนี้ กรุณาเลือกโหลดข้อมูลล่าสุดหรือเขียนทับด้วย Draft นี้",
duration: Infinity,
action: {
label: "ดูตัวเลือก",
onClick: () => document.getElementById("autosave-conflict")?.scrollIntoView({ behavior: "smooth", block: "center" }),
},
});
return () => {
toast.dismiss(toastId);
};
}, [conflictVersion, guideId, scope]);
useEffect(() => {
if (!hydrated || !valid || saving || conflictVersion !== null) return;
const manual = manualRequest !== handledManualRequest.current;