diff --git a/frontend/src/components/PostEditForm.tsx b/frontend/src/components/PostEditForm.tsx index 99039d9..5990c92 100644 --- a/frontend/src/components/PostEditForm.tsx +++ b/frontend/src/components/PostEditForm.tsx @@ -150,9 +150,52 @@ const PostEditForm: FC = ({ post, onSave }) => { const handleSubmit = async (e: FormEvent) => { e.preventDefault () + if (disabled) return + setDisabled (true) try { + const differences = [ + { name: label ('shared:labels.title'), + prev: post.title ?? '', current: title ?? '' }, + { name: label ('shared:labels.parentPosts'), + prev: (post.parentPosts ?? []).map (parent => parent.id).join (' '), + current: parentPostIds }, + { name: label ('tags:title'), + prev: tagsToStr (post.tags), current: tags }, + { name: label ('shared:labels.duration'), + prev: videoMsToDurationValue (post.videoMs), + current: videoFlg ? duration : '' }, + { name: <>{label ('shared:labels.originalCreatedAt')}{' '} + {label ('shared:labels.since')}, + prev: post.originalCreatedFrom ?? '', current: originalCreatedFrom ?? '' }, + { name: <>{label ('shared:labels.originalCreatedAt')}{' '} + {label ('shared:labels.before')}, + prev: post.originalCreatedBefore ?? '', current: originalCreatedBefore ?? '' }] + .filter (row => row.prev !== row.current) + + if (!(await dialogue.confirm ({ + title: label ('shared:actions.diff'), + confirmText: label ('shared:actions.update'), + description: ( +
+ {differences.map ((row, index) => ( +
+
{row.name}
+
+ {row.prev && ( + + {row.prev} + )} + {row.current && ( + + {row.current} + )} +
+
))} +
) }))) + return + await update ({ id: post.id, title, tags, parentPostIds, duration: videoFlg ? duration : null, originalCreatedFrom, originalCreatedBefore },