fix(dashboard): persist widget drag-drop order (validator was dropping it)
Some checks failed
Build & Push Docker Images / build-and-push (push) Has been cancelled
Build & Push Docker Images / lint (push) Has been cancelled

N46 (a147cbc) shipped the drag-drop UI + optimistic mutation, but the
PATCH body was being silently stripped by the user-preferences Zod
validator — `dashboardWidgetOrder` wasn't in the schema, so Zod's
default strip-unknown-keys behaviour dropped it before the DB write.

Symptom: drop the widget in a new position → UI reflects the order
optimistically → onSettled invalidates + refetches → GET returns the
unchanged-on-disk order → dashboard snaps back to the original
layout.

Added the field to updateUserPreferencesSchema with the same loose
shape (array-of-string) the schema declared 100+ lines earlier.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-22 14:26:39 +02:00
parent 355f242b8f
commit ee4d5c8610

View File

@@ -21,6 +21,12 @@ export const updateUserPreferencesSchema = z.object({
* update.
*/
dashboardWidgets: z.record(z.string(), z.boolean()).optional(),
/**
* Rep-chosen dashboard widget order (drag-drop). Missing ids fall
* through to registry order so newly-added widgets always surface.
* Kept loose (array-of-string) for the same reason as above.
*/
dashboardWidgetOrder: z.array(z.string()).optional(),
});
export type UpdateUserPreferencesInput = z.infer<typeof updateUserPreferencesSchema>;