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

150
Vistas
React export csv functionality

I am trying to add validations based on the response from api 200 or 400 and want to show message to user using snaqebar but once i download the csv first time browser gets stuck also validation message is not coming when exporting the file for first time.

//api service for exporting csv
function downloadFilteredTicketsCsv(ticketModalData) {
  const link = document.createElement("a");
    link.target = "_blank";
    link.download = "Service Tickets";
    axios
      .post(apiUrl + apiUrlConstant.DOWNLOAD_FILTERED_TICKETS_CSV, ticketModalData)
      .then((response) => {
        link.href = URL.createObjectURL(
          new Blob([response.data], { type: "text/csv" })
        );
        link.click();
        return response
      })
      .catch(err => {
        return err;
      });
      
// function when clicking the event

 const downloadFilteredTicketsCSV = () => {
    let modifiedTicketData = cloneDeep(ticketModalData)
    modifiedTicketData.parameters.pageSize = totalRows;
    if (totalRows > 1000) {
      enqueueSnackbar("The record limit has exceeded. You can download only up to 1000 records at a time.", {
        variant: "warning",
      });
    } else {
      serviceDashboardService.downloadFilteredTicketsCsv(modifiedTicketData)
        .then(response => {
          console.log(response, 'response')
          if (response.status === 200) {
            enqueueSnackbar("Please wait...It may take sometime to download the file.", {
              variant: "success",
            });
          } else {
            console.log(response, 'response2')
             enqueueSnackbar(response.data.message, {
                  variant: "error",
                });
          }
        })
    }
  };

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