dev #109
@ -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(__ => {
|
||||
})
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user