feat : add toast too
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user