diff --git a/src/components/BacklogCard.jsx b/src/components/BacklogCard.jsx index 8e5f532..b345e9f 100644 --- a/src/components/BacklogCard.jsx +++ b/src/components/BacklogCard.jsx @@ -10,7 +10,7 @@ import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from '@/c import {Textarea} from '@/components/ui/textarea'; import {cn} from '@/lib/utils'; import {STATUS_META} from './GameStatusBadge.jsx'; -import {NO_PRIORITY, saveBacklogEntry, toBacklogRequest} from '../utils/backlog.js'; +import {changedFields, NO_PRIORITY, saveBacklogEntry} from '../utils/backlog.js'; import {GAME_PRIORITIES, GAME_STATUSES, MAX_NOTES_LENGTH} from '../utils/limits.js'; import useUnsavedChanges from '../hooks/useUnsavedChanges.js'; @@ -33,14 +33,15 @@ export default function BacklogCard({game, onSaved}) { }, [game.status]); const [busy, setBusy] = useState(false); - const dirty = JSON.stringify(form) !== JSON.stringify(saved); + const changes = changedFields(saved, form); + const dirty = Object.keys(changes).length > 0; useUnsavedChanges(dirty); const set = (field) => (value) => setForm((f) => ({...f, [field]: value})); const save = async () => { setBusy(true); try { - const response = await saveBacklogEntry(game.appid, toBacklogRequest(form)); + const response = await saveBacklogEntry(game.appid, changes); if (response.status === 401) return; if (!response.ok) { toast.error(t('BACKLOG.SAVE_FAILED')); @@ -67,72 +68,75 @@ export default function BacklogCard({game, onSaved}) { {t('BACKLOG.TITLE')} -
-
- - -
+ {/* Locked while saving: the answer replaces the form, so an edit made meanwhile would be lost. */} +
+
+
+ + +
-
- - + + + {t('BACKLOG.PRIORITY.NONE')} + {GAME_PRIORITIES.map((p) => ( + {t(`BACKLOG.PRIORITY.${p}`)} + ))} + + +
+ +
+ +
+ {[1, 2, 3, 4, 5].map((n) => ( + ))} - - -
- -
- -
- {[1, 2, 3, 4, 5].map((n) => ( - - ))} +
-
-
-
- - {form.notes.length} / {MAX_NOTES_LENGTH} +
+
+ + {form.notes.length} / {MAX_NOTES_LENGTH} +
+