Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
React Drag and Drop 2 fields with the same values

To contextualize, I have a trip that has for attributes points of interest that are assigned to it and are sorted by a rank field that allows us to display them in a desired order.

I have a problem, I set up a drag and drop system on my table of points of interest but when I move a cell it can have the same rank as the cell to which it is moved. This is not possible for us, I would like to know if there is a solution to make it impossible that two cells have the same rank or that 2 ranks with the same value are updated.

See the screen for the table :

table

My code to update a rank :

const { mutate: changeRank, isSuccess: changeRankSuccess } = useMutation(
async ({ pointTrip, rank }) => {
  let url = `http://localhost:443/api/pointTrip/${pointTrip}`;
  await axios
    .put(url, { rank })
    .then((res) => {})
    .catch((err) => {
      console.log(err);
    });
},
{
  onSuccess: () => {
    queryClient.invalidateQueries(queryKey);
  },
}

My code for change the rank on drag end :

const handleDragEnd = (result) => {

if(!result.destination) {
  return;
}
let tempPoi = [...trip.pointsOfInterest];
let [selectedRow] = tempPoi.splice(result.source.index, 1);
changeRank({pointTrip: selectedRow.PointTrip.id, rank: result.destination.index + 1});

Can you help me ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda