fix: Match reorder refresh

This commit is contained in:
Thibaut Valentin 2026-03-08 21:58:57 +01:00
parent d6d9f86254
commit 812d873d5d
2 changed files with 6 additions and 2 deletions

View File

@ -568,7 +568,9 @@ function MatchList({matches, cat, groups, reducer, classement = false}) {
const {active, over} = event;
if (active.id !== over.id) {
const newIndex = marches2.findIndex(m => m.id === over.id);
let newIndex = marches2.findIndex(m => m.id === over.id);
if (newIndex > 0)
newIndex = marches2[newIndex].categorie_ord;
reducer({type: 'REORDER', payload: {id: active.id, pos: newIndex}});
sendRequest('updateMatchOrder', {id: active.id, pos: newIndex}).then(__ => {
})

View File

@ -56,8 +56,10 @@ export function MarchReducer(datas, action) {
return datas.sort(action.payload)
case 'REORDER':
const oldIndex = datas.findIndex(data => data.id === action.payload.id)
if (oldIndex === -1 || datas[oldIndex].categorie_ord === action.payload.pos)
if (oldIndex === -1)
return datas // Do nothing
if (datas[oldIndex].categorie_ord === action.payload.pos)
return [...datas] // Do nothing
const oldPos = datas[oldIndex].categorie_ord
const newPos = action.payload.pos