The mouse scroll for the main content is not working when I open the side-drawer. How do I go with this?

On opening the sidebar the main content scroll does not work. Also some fields such as select options, search bar do not work when the sidebar is open. I have added the main content in the routes from where it is being loaded. The scroll, above listed functions work fine when the side-drawer is closed. I am relatively new to material ui + react and tried to workaround with some tips from other sources but I am stuck with this for a long time.

  <>
      <Box sx={{ display: "flex" }}>
        <AppBar
          sx={{ backgroundColor: "rgb(19, 71, 129)" }}
          position="fixed"
          className={classes.appBar}
        >
          <Toolbar align="center">
            <IconButton
              color="inherit"
              onClick={handleMenuClick}
              edge="start"
              className={clsx(classes.menuButton)}
            >
              <MenuIcon />
            </IconButton>
          </Toolbar>
        </AppBar>
        <Drawer
          className={classes.drawer}
          variant="temporary"
          open={open}
          transitionDuration={{
            enter: transitionDuration,
            exit: transitionDuration,
          }}
          classes={{
            paper: classes.drawerPaper,
          }}
        >
          <Toolbar>
            <IconButton
              sx={{ marginLeft: "auto" }}
              onClick={handleMenuClick}
              edge="start"
              className={clsx(classes.menuButton)}
            >
              <ChevronLeftIcon />
            </IconButton>
          </Toolbar>
          <div className={classes.drawerContainer}>
            {/* //Drawer Items */}

            <DrawerItems open={open} isAdmin={isAdmin} />
          </div>

          {/* Logout */}

          <LightTooltip title="Logout" placement="top">
            <IconButton
              sx={{ marginTop: "auto" }}
              onClick={handleLogout}
              color="error"
            >
              <ExitToAppIcon />
            </IconButton>
          </LightTooltip>
        </Drawer>
        {/* Routes for drawer components */}
        <main
          className={clsx(classes.content, {
            [classes.contentShift]: open,
          })}
        >
          <Routes>
            <Route path="dashboard" element={<Dashboard />} />
            <Route path="employees" element={<Employees />} />
            <Route path="payroll" element={<Payroll />} />
            <Route path="projects" element={<Projects />} />
            <Route path="leaves" element={<Leaves />} />
            <Route path="leavesemp" element={<LeavesEMP />} />
            <Route path="empattendance" element={<EMPAttendance />} />
            <Route path="hrattendance" element={<HRAttendance />} />
          </Routes>
        </main>
      </Box>
    </>

This is the style

drawerContainer: {
    overflow: "auto",
  },
  content: {
    flexGrow: 1,
    padding: theme.spacing(3),
    transition: theme.transitions.create("margin", {
      easing: theme.transitions.easing.sharp,
      duration: transitionDuration,
    }),
    marginLeft: 0,
  },
  contentShift: {
    transition: theme.transitions.create("margin", {
      easing: theme.transitions.easing.easeOut,
      duration: transitionDuration,
    }),
    marginLeft: drawerWidth,
  },

D3: Bind elements of a matrix to grid cell by cell

I am trying to create an animation where the elements of a grid appear in left-to-right, top-to-bottom order. So the order would be: A_(1,1), A_(1,2),…A_(1,d)A_(n,d) .

My current code displays all elements in one column of the grid, followed by a delay, then all the elements in the second column, delay, and so on. I am sure this is because the index element in line 56, which controls the time delay for each element, resets with each row. I’d like to know if there is a way to get around this, such as having a variable that keeps track of the column number of d.

var data = [[0,1],[2,3]];

function myMatrix2(data) {

    var margin = {top: 50, right: 100, bottom: 50, left: 100},
        width = 250,
        height = 250;

    const svg = d3
        .select('.grid2')
        .append('svg')
        .attr("width", width + margin.left + margin.right)
        .attr("height", height + margin.top + margin.bottom)
        .append("g")
        .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

    numrows = data.length;
    numcols = data[0].length;

    rw=width/numrows;
    hw=height/numcols;

    var x = d3.scaleOrdinal()
        .domain(d3.range(numcols))
        .range(d3.range(0,width,width/numcols));

    var y = d3.scaleOrdinal()
        .domain(d3.range(numrows))
        .range(d3.range(0,height,height/numrows));

    var row = svg.selectAll(".row")
        .data(data)
        .enter().append("g")
        .attr("class", "row")
        .attr("transform", function(d, i) {return "translate(0," + y(i) + ")"; });

    var cell = row.selectAll(".cell")
        .data(function(d) { return d; })
        .enter().append("g")
        .attr("class", "cell")
        .attr("transform", function(d, i) { return "translate(" + x(i) + ", 0)"; });

    cell.append('rect')
        .attr("width", rw)
        .attr("height", hw)
        .style("stroke", "black")
        .style("stroke-width", "2px")
        .style("fill", 'white')

    cell.append("text") //Add matrix elements
        .attr("dy", ".32em")
        .attr("x", rw/2 )
        .attr("y", hw/2 )
        .attr("text-anchor", "middle")
        .style("font-size","14px")
        .transition() //Delay starts here
        .delay(function(d,i) {console.log("D: "+d + " I: "+i); return i*3000;})
        .text(function(d) { return d; })
    return;
};

Why use !== when you can use ===?

I could simply vice versa the code to be executed by the if and else. And === is more easier to use compared to !== so why is the not equal operator used?

function equality( number ){
    if ( number === 7 ){
        return "it's equal"
    } else { return "not equal"}
}
 console.log(equality(7))

function nonEquality( number ){
    if ( number !== 7 ){
        return "it's not equal"
    } else { return "it's equal"}
}
console.log(nonEquality(7));

ion-Range-Slider as video/ Audio timer using javascript

In live audio/video timer last time is always changing, can we do that with Ion-range-slider. i am trying to play last time on range like playing video… I have tried some thing like this Created Range.

$('#ion').ionRangeSlider({
    grid: true,
    type: 'double',
    min: moment("000000", "hhmmss").valueOf(),
    max: moment("100000", "hhmmss").valueOf(),
    to: moment("500000", "hhmmss")
        .valueOf(), // this is not working i want second pointer to be at 5 hour (but coding is working no error)

    force_edges: true,
    drag_interval: true,
    step: 60,
    min_interval: 60,
    prettify: function(num) {
        return moment(num).format('HH:mm:ss');
    }

});

then updated the to value in ion-range-slider but unable to update var to = slider.result.to_pretty; i want to add 1 second, here is the code i tried.

setInterval(function() {

    var slider = $("#ion").data("ionRangeSlider");
    var to = slider.result.to_pretty;
    console.log("to ", to);

    to = moment(to, "HH:mm:ss")
        .add(1, 'second');
    var too2 = to._i;
    console.log("tooooooooooooooo", to._i);

    too2 = moment(too2, "HH:mm:ss")
        .add(1, 'second');

    console.log("too2 2222222222222", too2);


    console.log("second called ");


    slider.update({
        grid: true,
        type: 'double',
        min: moment("000000", "hhmmss").valueOf(),
        max: moment().subtract(to, "hours").format("X"),
        //  moment(to, "HH:mm:ss")
        //     .add(1, 'second').valueOf(),


        force_edges: true,
        drag_interval: true,
        step: 60,
        min_interval: 60,
        prettify: function(num) {
            return moment(num).format('HH:mm:ss');
        }
    });
}, 3000);

return is not ending the for-in loop while looping through object keys JavaScript

I am trying to make a weather app using react js. And I want to render a specific component on the basis of the weather condition value from API. The API returns the value in string format and can have space-separated words( e.g Shower Rain ). I have stored the components in a nested object.

const WeatherConditions = {
    Clear: {"day" : <ClearSkyDay />, "night": <ClearSkyNight />},
    Clouds: {
        "few clouds": {"day": <FewCloudsDay />, "night": <FewCloudsNight />},
        "scattered clouds": {"day": <Cloudy />, "night": <Cloudy />},
        "broken clouds": {"day": <BrokenCloudy />, "night": <BrokenCloudy />},
        "overcast clouds": {"day": <BrokenCloudy />, "night": <BrokenCloudy />}
    },
    Thunderstorm: <Thunder />,
    Drizzle : <VeryHeavyShowerRain />,
    Rain : {
        "light rain": {"day": <LightRainDay />, "night": <LightRainNight />},
        "moderate rain": {"day": <ModerateRainDay />, "night": <ModerateRainNight />},
        "heavy intensity rain": {"day": <HeavyIntensityRainDay />,"night": <HeavyIntensityRainNight />},
        "very heavy rain": {"day": <VeryHeavyRain />,"night": <VeryHeavyRain />},
        "extreme rain": {"day": <VeryHeavyRain />,"night": <VeryHeavyRain />},
        "freezing rain": {"day": <FreezingRain />,"night": <FreezingRain />},
        "light intensity shower rain": {"day": <VeryHeavyShowerRain />,"night": <VeryHeavyShowerRain />},
        "shower rain": {"day": <VeryHeavyShowerRain />,"night": <VeryHeavyShowerRain />},
        "heavy intensity shower rain": {"day": <VeryHeavyShowerRain /> ,"night": <VeryHeavyShowerRain />},
        "ragged shower rain": {"day": <VeryHeavyShowerRain />,"night": <VeryHeavyShowerRain />},
    },
    Snow: {
        "light snow": <LightSnow />, "Snow": <LightSnow />,
        "Heavy snow": <HeavySnow />, "Sleet": <HeavySnow />,
        "Light shower sleet": <HeavyShowerSnow />, "Shower sleet": <HeavyShowerSnow />,
        "Light rain and snow": <FreezingRain />, "Rain and snow": <FreezingRain />,
        "Light shower snow": <HeavyShowerSnow />,"Shower snow": <HeavyShowerSnow />, 
        "Heavy shower snow": <HeavyShowerSnow />
    },
    Mist: <Haze />, Smoke: <Haze />, Haze: <Haze />,
    Dust: <Haze />, Fog: <Haze />, Sand: <Haze />,
    Ash: <Haze />, Squall: <Haze />, Tornado: <Haze />
}

I am using a recursive function to get the value

const getCurrentWeather = (obj) => {
    for (const key in obj) {
        console.log(obj);
        if (key === weather.weather[0].main) {
            console.log(obj);
            if (typeof obj[key][Object.keys(obj[key])[0]] !== 'symbol') {
                console.log(obj);
                getCurrentWeather(obj[key]);
            }else {
                console.log(obj);
                return obj[key];
            }
        } else if (key === weather.weather[0].description) {
            console.log(obj);
            if (typeof obj[key][Object.keys(obj[key])[0]] !== 'symbol') {
                console.log(obj);
                getCurrentWeather(obj[key]);
            }else {
                console.log(obj);
                return obj[key];
            }
        } else if (key === 'day' || key === 'night') {
            console.log(obj);
            if (weather?.weather[0].icon?.includes("d")) {
                console.log(obj);
                return obj["day"];
            } else {
                console.log(obj);
                return obj["night"];
            }
        } else {
            console.log(obj);
            continue
        }
    }
}

I don’t know why the return statement is not ending thee loop. All the conditions are correct. And according to the object this should return the value and end the function but even if going through return statement it just keeps on going through all keys of the object.

WeatherData.js:80 {Clear: {…}, Clouds: {…}, Thunderstorm: {…}, Drizzle: {…}, Rain: {…}, …}
WeatherData.js:109 {Clear: {…}, Clouds: {…}, Thunderstorm: {…}, Drizzle: {…}, Rain: {…}, …}
WeatherData.js:80 {Clear: {…}, Clouds: {…}, Thunderstorm: {…}, Drizzle: {…}, Rain: {…}, …}
WeatherData.js:82 {Clear: {…}, Clouds: {…}, Thunderstorm: {…}, Drizzle: {…}, Rain: {…}, …}
WeatherData.js:84 {Clear: {…}, Clouds: {…}, Thunderstorm: {…}, Drizzle: {…}, Rain: {…}, …}
WeatherData.js:80 {few clouds: {…}, scattered clouds: {…}, broken clouds: {…}, overcast 
clouds: {…}}
WeatherData.js:109 {few clouds: {…}, scattered clouds: {…}, broken clouds: {…}, overcast 
clouds: {…}}
WeatherData.js:80 {few clouds: {…}, scattered clouds: {…}, broken clouds: {…}, overcast 
clouds: {…}}
WeatherData.js:109 {few clouds: {…}, scattered clouds: {…}, broken clouds: {…}, overcast 
clouds: {…}}
WeatherData.js:80 {few clouds: {…}, scattered clouds: {…}, broken clouds: {…}, overcast 
clouds: {…}}
WeatherData.js:109 {few clouds: {…}, scattered clouds: {…}, broken clouds: {…}, overcast 
clouds: {…}}
WeatherData.js:80 {few clouds: {…}, scattered clouds: {…}, broken clouds: {…}, overcast 
clouds: {…}}
WeatherData.js:91 {few clouds: {…}, scattered clouds: {…}, broken clouds: {…}, overcast 
clouds: {…}}
WeatherData.js:93 {few clouds: {…}, scattered clouds: {…}, broken clouds: {…}, overcast 
clouds: {…}}
WeatherData.js:80 {day: {…}, night: {…}}
WeatherData.js:100 {day: {…}, night: {…}}
WeatherData.js:102 {day: {…}, night: {…}}
WeatherData.js:80 {Clear: {…}, Clouds: {…}, Thunderstorm: {…}, Drizzle: {…}, Rain: {…}, …}
WeatherData.js:109 {Clear: {…}, Clouds: {…}, Thunderstorm: {…}, Drizzle: {…}, Rain: {…}, …}
WeatherData.js:80 {Clear: {…}, Clouds: {…}, Thunderstorm: {…}, Drizzle: {…}, Rain: {…}, …}
WeatherData.js:109 {Clear: {…}, Clouds: {…}, Thunderstorm: {…}, Drizzle: {…}, Rain: {…}, …}
WeatherData.js:80 {Clear: {…}, Clouds: {…}, Thunderstorm: {…}, Drizzle: {…}, Rain: {…}, …}
WeatherData.js:109 {Clear: {…}, Clouds: {…}, Thunderstorm: {…}, Drizzle: {…}, Rain: {…}, …}


....keeps going 

then it returns undefined

It should have stopped on line WeatherData.js:102 where it should return the value of obj[“day”]. I know this is not the best practice and its Spaghetti code but I tried with less code and more recursion but no luck!

How to configure Next.JS API timeout

My api returns me a result after 10 minute later because of some limitations of another api. In localhost, i can wait 10 minutes and receive my data successfully but in vercel, my api returns me 504 which means timeout error. How can i disable that?

enter image description here

Getting the monthly balance and overall balance using the daily balance from the child of a data in Firebase

I have a Firebase Realtime Database that stores the public transport vehicle driver’s total balance, monthly balance, and daily balance as shown below:

enter image description here
enter image description here

As you can see, I got the computations wrong. But I want to know how can I be able to add the daily balance of the driver for each day, add it to the monthly balance, then to the total balance of the driver because I’m really at lost right now on what to do.

Thank you in advance for your help!

testing keyboard events with jasmine

I have this directive to handle ctrl+z and ctrl+y
but Im struggling with the jasmine test for it, any ideas?

import { Directive, Output, EventEmitter, HostListener } from '@angular/core';

@Directive({
   selector: '[ctrlKeys]',
})
export class CtrlKeysDirective {
   @Output() ctrlZ = new EventEmitter();
   @Output() ctrlY = new EventEmitter();

   @HostListener('document:keydown.control.z') onCtrlZ() {
       this.ctrlZ.emit();
   }

   @HostListener('document:keydown.control.y') onCtrlY() {
       this.ctrlY.emit();
   }
}

Confusion with mapping another image to one of the faces of my rectangle in WebGL

Im trying to map another image onto my 3d rectangle in WebGL.

As of right now, I have one image mapped to all sides of the rectangle, but I want to replace one of them with a particular image I have.

I specifically want to map it to one of the larger faces of the rectangle, specifically the one that is purple.

Any help would be greatly appreciated

"use strict";

var canvas;
var gl;

var numVertices  = 36;

var texSize = 64;

var program;

var pointsArray = [];
var colorsArray = [];
var texCoordsArray = [];

var texture;

//Dimensions of Dequès Building
var l = .16304 * 2.5
var h = .57 
var w = .12374 * 2.5

var texCoord = [
    vec2(0, 0),
    vec2(0, 1),
    vec2(1, 1),
    vec2(1, 0)
];

var vertices = [
   vec4( -l, -w,  h, 1.0 ),
   vec4( -l,  w,  h, 1.0 ),
   vec4( l,  w,  h, 1.0 ),
   vec4( l, -w,  h, 1.0 ),
   vec4( -l, -w, -h, 1.0 ),
   vec4( -l,  w, -h, 1.0 ),
   vec4( l,  w, -h, 1.0 ),
   vec4( l, -w, -h, 1.0 )


];

var vertexColors = [
    vec4( 0.0, 0.0, 0.0, 1.0 ),  // black
    vec4( 1.0, 0.0, 0.0, 1.0 ),  // red
    vec4( 1.0, 1.0, 0.0, 1.0 ),  // yellow
    vec4( 0.0, 1.0, 0.0, 1.0 ),  // green
    vec4( 0.0, 0.0, 1.0, 1.0 ),  // blue
    vec4( 1.0, 0.0, 1.0, 1.0 ),  // magenta
    vec4( 0.0, 1.0, 1.0, 1.0 ),  // white
    vec4( 0.0, 1.0, 1.0, 1.0 )   // cyan
];

var xAxis = 1;
var yAxis = 1;
var zAxis = 1;
var axis = xAxis;
var theta = [0, 0, 0];

var thetaLoc;

function configureTexture( image ) {
    texture = gl.createTexture();
    gl.bindTexture( gl.TEXTURE_2D, texture );
    gl.pixelStorei(gl.UNPACK_FLIP_X_WEBGL, true);
    gl.texImage2D( gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, image );
    gl.generateMipmap( gl.TEXTURE_2D );
    gl.texParameteri( gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_LINEAR );
    gl.texParameteri( gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST );
    gl.uniform1i(gl.getUniformLocation(program, "texture"), 0);
}


function quad(a, b, c, d) {
     pointsArray.push(vertices[a]);
     colorsArray.push(vertexColors[a]);
     texCoordsArray.push(texCoord[0]);

     pointsArray.push(vertices[b]);
     colorsArray.push(vertexColors[a]);
     texCoordsArray.push(texCoord[1]);

     pointsArray.push(vertices[c]);
     colorsArray.push(vertexColors[a]);
     texCoordsArray.push(texCoord[2]);

     pointsArray.push(vertices[a]);
     colorsArray.push(vertexColors[a]);
     texCoordsArray.push(texCoord[0]);

     pointsArray.push(vertices[c]);
     colorsArray.push(vertexColors[a]);
     texCoordsArray.push(texCoord[2]);

     pointsArray.push(vertices[d]);
     colorsArray.push(vertexColors[a]);
     texCoordsArray.push(texCoord[3]);
}


function colorCube()
{
    quad( 1, 0, 3, 2 );
    quad( 2, 3, 7, 6 );
    quad( 3, 0, 4, 7 );
    quad( 6, 5, 1, 2 );
    quad( 4, 5, 6, 7 );
    quad( 5, 4, 0, 1 );
}


window.onload = function init() {

    canvas = document.getElementById( "gl-canvas" );

    gl = WebGLUtils.setupWebGL( canvas );
    if ( !gl ) { alert( "WebGL isn't available" ); }

    gl.viewport( 0, 0, canvas.width, canvas.height );
    gl.clearColor( 0, 0, 0, 1 );

    gl.enable(gl.DEPTH_TEST);

    //
    //  Load shaders and initialize attribute buffers
    //
    program = initShaders( gl, "vertex-shader", "fragment-shader" );
    gl.useProgram( program );

    colorCube();

    var cBuffer = gl.createBuffer();
    gl.bindBuffer( gl.ARRAY_BUFFER, cBuffer );
    gl.bufferData( gl.ARRAY_BUFFER, flatten(colorsArray), gl.STATIC_DRAW );

    var vColor = gl.getAttribLocation( program, "vColor" );
    gl.vertexAttribPointer( vColor, 4, gl.FLOAT, false, 0, 0 );
    gl.enableVertexAttribArray( vColor );

    var vBuffer = gl.createBuffer();
    gl.bindBuffer( gl.ARRAY_BUFFER, vBuffer );
    gl.bufferData( gl.ARRAY_BUFFER, flatten(pointsArray), gl.STATIC_DRAW );

    var vPosition = gl.getAttribLocation( program, "vPosition" );
    gl.vertexAttribPointer( vPosition, 4, gl.FLOAT, false, 0, 0 );
    gl.enableVertexAttribArray( vPosition );

    var tBuffer = gl.createBuffer();
    gl.bindBuffer( gl.ARRAY_BUFFER, tBuffer );
    gl.bufferData( gl.ARRAY_BUFFER, flatten(texCoordsArray), gl.STATIC_DRAW );

    var vTexCoord = gl.getAttribLocation( program, "vTexCoord" );
    gl.vertexAttribPointer( vTexCoord, 2, gl.FLOAT, false, 0, 0 );
    gl.enableVertexAttribArray( vTexCoord );

    //
    // Initialize a texture
    //

    //var image = new Image();
    //image.onload = function() {
     //   configureTexture( image );
    //}
    //image.src = "SA2011_black.gif"


    var image = document.getElementById("texImage");

    //Loads image of front of building
    
    //var image = document.getElementById("texImage2");
    
    configureTexture( image );


    thetaLoc = gl.getUniformLocation(program, "theta");



    
    /*
    document.getElementById("ButtonX").onclick = function(){axis = xAxis;};
    document.getElementById("ButtonY").onclick = function(){axis = yAxis;};
    document.getElementById("ButtonZ").onclick = function(){axis = zAxis;};
    */

    render();

}

var render = function(){
    gl.clear( gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
    theta[axis] += 1;
    gl.uniform3fv(thetaLoc, flatten(theta));
    gl.drawArrays( gl.TRIANGLES, 0, numVertices );
    requestAnimFrame(render);
}
<!DOCTYPE html>
<html>
<style type="text/css">
    canvas { background: rgb(0, 0, 0); }
</style>

<script id="vertex-shader" type="x-shader/x-vertex">

attribute  vec4 vPosition;
attribute  vec4 vColor;
attribute  vec2 vTexCoord;

varying vec4 fColor;
varying vec2 fTexCoord;

uniform vec3 theta;

void main()
{
    // Compute the sines and cosines of theta for each of
    //   the three axes in one computation.
    vec3 angles = radians( theta );
    vec3 c = cos( angles );
    vec3 s = sin( angles );

    // Remeber: thse matrices are column-major
    mat4 rx = mat4( 1.0,  0.0,  0.0, 0.0,
            0.0,  c.x,  s.x, 0.0,
            0.0, -s.x,  c.x, 0.0,
            0.0,  0.0,  0.0, 1.0 );

    mat4 ry = mat4( c.y, 0.0, -s.y, 0.0,
            0.0, 1.0,  0.0, 0.0,
            s.y, 0.0,  c.y, 0.0,
            0.0, 0.0,  0.0, 1.0 );

    mat4 rz = mat4( c.z, s.z, 0.0, 0.0,
            -s.z,  c.z, 0.0, 0.0,
            0.0,  0.0, 1.0, 0.0,
            0.0,  0.0, 0.0, 1.0 );

    fColor = vColor;
    fTexCoord = vTexCoord;
    gl_Position = rz * ry * rx * vPosition;
    gl_Position.z = -gl_Position.z;
}
</script>

<script id="fragment-shader" type="x-shader/x-fragment">

precision mediump float;

varying vec4 fColor;
varying  vec2 fTexCoord;

uniform sampler2D texture;

void
main()
{
    gl_FragColor = fColor * texture2D( texture, fTexCoord );
}
</script>

<script type="text/javascript" src="../Common/webgl-utils.js"></script>
<script type="text/javascript" src="../Common/initShaders.js"></script>
<script type="text/javascript" src="../Common/MV.js"></script>
<script type="text/javascript" src="textureCube1.js"></script>


<body>
<canvas id="gl-canvas" width="512" height="512">
Oops ... your browser doesn't support the HTML5 canvas element
</canvas>
<img id = "texImage" src = "wall.png" hidden></img>
<img id = "texImage2" src = "building.jpeg" hidden></img>
</body>
</html>

JS map + filter un-understand

1

2

I can’t understand how 11, 12, 13 is tranformed to J Q K by map func in the last line.
The key problem that im having is values that is described in cardToString().
How does it?
Could anybody help me?

Show browser popup when user tries to leave the page while ajax post request is active

I have a text input field and on focusout I send a post request to the backend using $.ajax();. How do I show the browser popup which asks people if they are sure to leave the page when the $.ajax() request is still going on in the background?

We can use the beforeunload event to ask the user if they are sure to leave the page, but I want to show that popup only when the post request from $.ajax() is still going on and not complete. How can I do that?

Thank you

React router v6 routing issue

I am trying to create a spring boot application with react code inside it.I have my App.js like this.Only the default route is working and other routes are not working.

import './App.css';
import React from 'react';

import 'ag-grid-community/dist/styles/ag-grid.css';
import 'ag-grid-community/dist/styles/ag-theme-balham.css';
import "react-datepicker/dist/react-datepicker.css";
import 'react-js-dialog-box/dist/index.css';
import {BrowserRouter, BrowserRouter as Router, Route, Routes} from 'react-router-dom';
import UploadData from './UploadData';
import RoutesOfApplication from './RoutesOfApplication';
import '@szhsin/react-menu/dist/index.css';
import '@szhsin/react-menu/dist/transitions/slide.css';
//const rootElement = document.getElementById("root");

class App extends React.Component {
    render(){
    console.log('In App');
        return(
            
    <BrowserRouter>
      <Routes>
      
        <Route path="/" element={<RoutesOfApplication/>} />
        <Route path="/*" element={<RoutesOfApplication/>} />
        <Route path="/UploadData" element={<UploadData/>}/>
        <Route path="/:id" element={<UploadData/>}/>
      </Routes>
    </BrowserRouter>
        );
    }   

}
export default App;


package.json : "react-dom": "^17.0.2",
    "react": "^17.0.2",
    "react-router-dom": "^6.3.0"

Am i missing something.