mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-29 10:03:46 +00:00
Fix drag-and-drop multiple reorders and wheel lights pattern
- Allow multiple prize reorders before saving by using current displayed order - Simplify lights pattern calculation using distance-based logic - Fixes: drag only worked once, lights appeared to go through wheel
This commit is contained in:
@@ -427,17 +427,24 @@ export default function AdminWheel() {
|
||||
onTelegramDragEnd();
|
||||
const { active, over } = event;
|
||||
if (over && active.id !== over.id && config) {
|
||||
const oldIndex = config.prizes.findIndex((p) => p.id === active.id);
|
||||
const newIndex = config.prizes.findIndex((p) => p.id === over.id);
|
||||
// Use current displayed order (either local or from config)
|
||||
const currentPrizes = localPrizeOrder
|
||||
? localPrizeOrder
|
||||
.map((id) => config.prizes.find((p) => p.id === id))
|
||||
.filter((p): p is WheelPrizeAdmin => p !== undefined)
|
||||
: config.prizes;
|
||||
|
||||
const oldIndex = currentPrizes.findIndex((p) => p.id === active.id);
|
||||
const newIndex = currentPrizes.findIndex((p) => p.id === over.id);
|
||||
if (oldIndex !== -1 && newIndex !== -1) {
|
||||
const newOrder = arrayMove(config.prizes, oldIndex, newIndex);
|
||||
const newOrder = arrayMove(currentPrizes, oldIndex, newIndex);
|
||||
// Save order locally, don't trigger mutation immediately
|
||||
setLocalPrizeOrder(newOrder.map((p) => p.id));
|
||||
setHasUnsavedOrder(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
[config, onTelegramDragEnd],
|
||||
[config, localPrizeOrder, onTelegramDragEnd],
|
||||
);
|
||||
|
||||
// Save prize order
|
||||
|
||||
Reference in New Issue
Block a user