dev #109

Merged
Thibaut merged 4 commits from dev into master 2026-03-09 12:10:47 +00:00
2 changed files with 6 additions and 2 deletions
Showing only changes of commit 812d873d5d - Show all commits

View File

@ -568,7 +568,9 @@ function MatchList({matches, cat, groups, reducer, classement = false}) {
const {active, over} = event; const {active, over} = event;
if (active.id !== over.id) { 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}}); reducer({type: 'REORDER', payload: {id: active.id, pos: newIndex}});
sendRequest('updateMatchOrder', {id: active.id, pos: newIndex}).then(__ => { sendRequest('updateMatchOrder', {id: active.id, pos: newIndex}).then(__ => {
}) })

View File

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