multiple snackbars overlapping ,

Iam trying to put 3 classes together in a dashboard.js file , each classes have a snackbar set for 2 sec timeout , the problem is when i load or refresh the dashboard page , the snackbars overlap each other , how do i make it display like a stack ,


import React from 'react';
import { 
Grid, 
IconButton, 
Typography } from '@mui/material';
import Cards from './cards/Cards';
import ServerStatus from './ServerStatus';
import ServerGroupStatus from './ServerGroupStatus';
import DatabaseStatus from './DatabaseStatus';
import WebServiceStatus from './WebserviceStatus';


export default function Dashboard() {
  return (
    <Grid container spacing={2}>
      <Grid item xs={12}>
       <Cards />
      </Grid>
      <Grid item xs={12} style={{ marginBottom: '16px' }}>
     </Grid>
      <ServerStatus />
      <Grid item xs={12} style={{ marginBottom: '16px' }}>
     </Grid>
     <ServerGroupStatus />
     <Grid item xs={12} style={{ marginBottom: '16px' }}>
     </Grid>
     <DatabaseStatus />
     <Grid item xs={12} style={{ marginBottom: '16px' }}>
     </Grid>
     <WebServiceStatus />
    </Grid>
  );
}

below is how ive implemented the snackbar , ive done the same in all 3 classes

import React, { useState, useEffect } from 'react';
import {
  Grid,
  Card,
  CardHeader,
  CardContent,
  Table,
  TableHead,
  TableRow,
  TableCell,
  TableBody,
  Button,
  Snackbar,
  Alert,
  Skeleton
} from '@mui/material';
import { Refresh as RefreshIcon, ZoomIn as ZoomInIcon } from '@mui/icons-material';
import { getServers } from "../api/server-service";
import { useTheme } from '@mui/material/styles';


function ServerStatus() {
  const theme = useTheme();
  const [loading, setLoading] = useState(true);
  const [serverData, setServerData] = useState([]);
  const [snackbarOpen, setSnackbarOpen] = useState(false);
  const [snackbarMessage, setSnackbarMessage] = useState("");
  const [snackbarSeverity, setSnackbarSeverity] = useState("success");

  console.log(theme.palette.primary.main);
  useEffect(() => {
    fetchServers();
  }, []);

  const handleRefresh = () => {
    setLoading(true);
    fetchServers();
  };

  const fetchServers = () => {
    getServers()
      .then((response) => {
        console.log("Server data:", response.data);
        setTimeout(() => {
          setServerData(response.data);
          setLoading(false);
          if (response.data.length > 0) {
            showSnackbar("Successfully fetched all Servers.", "success");
          }
        }, 1000);
      })
      .catch((error) => {
        console.log(error);
        showSnackbar("Error fetching servers: " + error.message, "error");
      });
  };

  const showSnackbar = (message, severity) => {
    setSnackbarMessage(message);
    setSnackbarSeverity(severity);
    setSnackbarOpen(true);
  };

  const handleCloseSnackbar = () => {
    setSnackbarOpen(false);
  };

  const handleZoomInClick = () => {
    console.log('Zoom in clicked');
  };

  return (
    <Grid item xs={12}>
      <Card elevation={3}>
        <CardHeader
          title="Server Status"
          action={
            <Button
              variant="contained"
              color="secondary"
              startIcon={<RefreshIcon />}
              onClick={handleRefresh}
            >
              Refresh
            </Button>
          }
        />
        <CardContent>
          <Table>
            <TableHead>
              <TableRow>
                <TableCell>Server Name</TableCell>
                <TableCell>Host</TableCell>
                <TableCell>Active Status</TableCell>
                <TableCell></TableCell>
              </TableRow>
            </TableHead>
            <TableBody>
              {loading ? (
                <TableRow>
                  <TableCell colSpan={4}>
                    <Skeleton animation="wave" />
                    <Skeleton animation="wave" />
                    <Skeleton animation="wave" />
                    <Skeleton animation="wave" />
                  </TableCell>
                </TableRow>
              ) : serverData.length === 0 ? (
                <TableRow>
                  <TableCell colSpan={4}>Add Monitor Server Request To check status...</TableCell>
                </TableRow>
              ) : (
                serverData.map((server) => (
                  <TableRow key={server.serverName}>
                    <TableCell>{server.name}</TableCell>
                    <TableCell>{server.host}</TableCell>
                    <TableCell>
                    <Button
    variant="contained"
    style={{
        backgroundColor: server.isActive ? theme.palette.success.main : theme.palette.error.main,
        color: 'white',
    }}
    disabled={!server.isActive}
>
    {server.isActive ? "Active" : "InActive"}
</Button>




                    </TableCell>
                    <TableCell>
                      <ZoomInIcon
                        onClick={handleZoomInClick}
                        style={{ cursor: 'pointer' }}
                      />
                    </TableCell>
                  </TableRow>
                ))
              )}
            </TableBody>
          </Table>
        </CardContent>
      </Card>

      <Snackbar
        anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
        open={snackbarOpen}
        autoHideDuration={3000}
        onClose={handleCloseSnackbar}
      >
        <Alert onClose={handleCloseSnackbar} severity={snackbarSeverity}>
          {snackbarMessage}
        </Alert>
      </Snackbar>
    </Grid>
  );
}

export default ServerStatus;

i tried changing the position , still same , it overlaps

how to handle Stale Element Reference Exception while finding element in JMeter

i am trying to find element whose structure something like below

<div>
 <div>
  <div>
    <ul>
     <object id = "obj"
       #document (here is a link )
        <html>
         <head> </head>
          <body>
            <div id = style4 >

i have tried multiple ways to find this element but it always gives exception of stale element here’s what i’ve done

 var table = wait.until(pkg.ExpectedConditions.presenceOfElementLocated(pkg.By.xpath('/html/body/div[8]/div/div/div[2]/div/div[2]/div/div/ul')));
    WDS.browser.executeScript("arguments[0].scrollIntoView(true);", table);
    WDS.log.info("Got Table");

    // Find the <object> element within the table
    var objectElement = table.findElement(pkg.By.tagName('object'));
    WDS.log.info("Found objectElement");

    // Extract the content of the <object> element
    var objectContent = objectElement.getAttribute('data');
    WDS.log.info("Extracted objectContent");

    // Refresh the <object> element to prevent staleness
    WDS.browser.executeScript("arguments[0].scrollIntoView(true);", objectElement);
    WDS.log.info("Refreshed objectElement");

    // Load the content document of the <object> element
    var contentDocument = WDS.browser.executeScript("return arguments[0].contentDocument", objectElement);
    WDS.log.info("Loaded contentDocument");

    // Find the <html> element within the content document
    var htmlElement = contentDocument.querySelector('html');
    WDS.log.info("Found htmlElement: " + htmlElement);

and this is the log

2024-02-21 22:42:12,278 INFO c.g.j.p.w.s.WebDriverSampler: Got Table
2024-02-21 22:42:12,289 INFO c.g.j.p.w.s.WebDriverSampler: Found objectElement
2024-02-21 22:42:12,304 INFO c.g.j.p.w.s.WebDriverSampler: Extracted objectContent
2024-02-21 22:42:12,309 INFO c.g.j.p.w.s.WebDriverSampler: Refreshed objectElement
2024-02-21 22:42:12,317 ERROR c.g.j.p.w.s.WebDriverSampler: Error: org.openqa.selenium.StaleElementReferenceException: stale element reference: stale element not found
  (Session info: chrome=122.0.6261.58)

Incorrect current row count in the pagination table

  1. If both the pagination table page and the search result page are 0, then the left count should be “0 to 0 of 0 entries” and the right “1/1”. Both the left and right arrows should be disabled for clicking.

  2. What if the result table has a lower row count than the pagination limit?

  3. I want to set the pagination limit to 15, and the left count should be 1 to 15 of 17 entries and 16 to 17 of 17 entries.

// Table Pagination Script Starts 
const paginationNumbers = document.getElementById("pagination-numbers");
const pageCount_ele = document.getElementById("pageCount") // Handle the page values
const currentPage_ele = document.getElementById("currentPage")
const paginatedList = document.getElementById("paginated-list");
const listItems = paginatedList.querySelectorAll("tbody tr");
const nextButton = document.getElementById("next-button");
const prevButton = document.getElementById("prev-button");
const currentSearchOfTotal = document.getElementById('currpagecount')
const totalRowsCount = document.getElementById('totalrowscount')
const paginationLimit = 2;
const searchPaginationLimit = 2;
const pageCount = Math.ceil(listItems.length / paginationLimit);
const input = document.getElementById("myInput");
let currentPage = 1;
let searching = false


let searchArray=[]
let searchPageCount
function myFunction() {
  searching = true
  var input, filter, table, tr, td, i, txtValue, pagination;
  input = document.getElementById("myInput");
  filter = input.value.toLowerCase();
  table = document.getElementById("paginated-list");
  tr = table.getElementsByTagName("tr");
  searchArray=[]
    for (i = 1; i < tr.length; i++) {
    alltags = tr[i].getElementsByTagName("td");
    isFound = false;
      for (j = 0; j < alltags.length; j++) {
        td = alltags[j];
          if (td) {
              txtValue = td.textContent || td.innerText;
              if (txtValue.toLowerCase().indexOf(filter) > -1) {
                  tr[i].style.display = "";
                  j = alltags.length;
                  isFound = true;
              }
        }
    }
    if(isFound){searchArray.push(tr[i])}
      if (!isFound && tr[i].className !== "header") {
        tr[i].style.display = "none";
      }
    }
  setCurrentSearchPage(1)
  pageCount_ele.innerText = Math.ceil(searchArray.length/searchPaginationLimit)
}

const disableButton = (button) => {
  button.classList.add("disabled");
  button.disable = true;
};

const enableButton = (button) => {
  button.classList.remove("disabled");
  button.disable = false;
};

const handlePageButtonsStatus = () => {
  if (currentPage === 1) {
  disableButton(prevButton);
} else {
  enableButton(prevButton);
}

if (pageCount === currentPage) {
  disableButton(nextButton);
} else {
  enableButton(nextButton);
}
};

const handleSearchPageButtonsStatus = () => {
if (currentPage === 1) {
  disableButton(prevButton);
} else {
  enableButton(prevButton);
}

if (Math.ceil(searchArray.length/searchPaginationLimit) === currentPage) {
  disableButton(nextButton);
} else {
  enableButton(nextButton);
}
};

const handleActivePageNumber = () => {

  currentPage_ele.innerText = currentPage

  enableButton(prevButton) // Assing them as clickable
  enableButton(nextButton)

  if (currentPage == pageCount){
    disableButton(nextButton) // if last page disable next
  }
  if (currentPage == 1){
    disableButton(prevButton) // if 1st disable prev
  }
};

const handleSearchActivePageNumber = () => {

  currentPage_ele.innerText = currentPage

  enableButton(prevButton) // Assing them as clickable
  enableButton(nextButton)
  console.log(Math.ceil(searchArray.length/searchPaginationLimit))
  if (currentPage == (Math.ceil(searchArray.length/searchPaginationLimit))){
    disableButton(nextButton) // if last page disable next
  }
  if (currentPage == 1){
    disableButton(prevButton) // if 1st disable prev
  }
};

const setCurrentPage = (pageNum) => {
  currentPage = pageNum;

  handleActivePageNumber();
  handlePageButtonsStatus();

  const prevRange = (pageNum - 1) * paginationLimit;
  const currRange = pageNum * paginationLimit;
  currentSearchOfTotal.innerHTML=`Showing ${currRange-1} to ${currRange} of `
  totalRowsCount.innerHTML = `${listItems.length} entries`

  listItems.forEach((item, index) => {
    item.classList.add("hidden");
    if (index >= prevRange && index < currRange) {
      item.classList.remove("hidden");
    }
  });
};

const setCurrentSearchPage = (pageNum) => {
  currentPage = pageNum;

  handleSearchActivePageNumber();
  handleSearchPageButtonsStatus();

  const prevRange = (pageNum - 1) * searchPaginationLimit;
  const currRange = pageNum * searchPaginationLimit;
  currentSearchOfTotal.innerHTML=`Showing search results ${currRange-1} to ${searchArray.length>1 ? currRange : 1} of `
  totalRowsCount.innerHTML = `${searchArray.length} entries`
  searchArray.forEach((item, index) => {
    item.classList.add("hidden");
    if (index >= prevRange && index < currRange) {
      item.classList.remove("hidden");
    }
  });
};

window.addEventListener("load", () => {
  setCurrentPage(1);
  prevButton.addEventListener("click", () => {
    if(!searching){
      setCurrentPage(currentPage - 1)
      pageCount_ele.innerText = pageCount
    }
    else if(searching){
      setCurrentSearchPage(currentPage-1)
      pageCount_ele.innerText = Math.ceil(searchArray.length/searchPaginationLimit)
    }
  });

  nextButton.addEventListener("click", () => {
    if(!searching){
      setCurrentPage(currentPage + 1)
      pageCount_ele.innerText = pageCount
    }
    else{
      setCurrentSearchPage(currentPage+1)
      pageCount_ele.innerText = Math.ceil(searchArray.length/searchPaginationLimit)
    };
  });
  pageCount_ele.innerText = pageCount
});
//Table Search Script Ends
 
.result {
    text-align: center;
    padding-bottom: 20px;
    width: 100%;
}

  .canel-trains-grids {
    float: left;
    width: 100%;
    margin-bottom: 20px;
}

.canel-trains-grids .left-cancel {
    float: left;
    width: 60%;
    margin-top: 10px;
}

.canel-trains-grids .left-cancel span {
    float: left;
    font-size: 16px;
    background: #34A853;
    color: #fff;
    font-weight: 400;
    padding: 8px 8px;
    border-radius: 3px;
    text-align: left;
    line-height: 1.5em;
    width: auto;
}

.canel-trains-grids .right-cancel {
    float: right;
    width: 30%;
    margin-top: 10px;
}

.canel-trains-grids .right-cancel label {
    float: left;
    vertical-align: middle;
    line-height: 39px;
    font-size: 16px;
    color: #000;
    font-weight: 400;
}

.canel-trains-grids .right-cancel input {
    width: 230px;
    height: 22px;
    border: 1px solid #dae9f3;
    border-radius: 5px;
    padding: 8px 8px 8px 16px;
    float: right;
}

.canel-trains-grids .right-cancel input:focus {
    outline: none;
}


/* Responsive Table Start */

.rstable {
    width: 100%;
    margin: 0 auto;
    padding: 16px 0px;
}

.rstable table {
    font-family: calibri, sans-serif;
    border-collapse: collapse;
    font-size: 16px;
    width: 100%;
    font-weight: 400;
}

.rstable tr {
    border-bottom: 1px solid #ccc;
}

.rstable tr td {
    text-align: left;
    padding: 9px;
    color: #333;
}

.rstable th {
    text-align: left;
    padding: 10px 9px;
    background: #004287;
    color: #fff;
    font-weight: 500;
}

.rstable tr:nth-child(even) {
    background: #f9fbfdc4;
}

.rstable tr:nth-child(odd) {
    background: #dae9f3;
}

.rstable tr td a {
    color: #004287;
    font-size: 16px;
}

@media (min-width: 768px) and (max-width: 1023px) {
    .rstable table {
        font-size: 15px;
    }
}

@media screen and (max-width: 767px) {
    .rstable table {
        font-size: 16px;
        font-weight: 400;
    }
    .rstable thead {
        display: none;
    }
    .rstable td:first-child {
        text-align: left;
        display: inline-grid;
        width: 90%;
    }
    .rstable td {
        text-align: left;
        display: inline-grid;
        width: 26%;
        vertical-align: top;
        color: #333;
        font-weight: 400;
    }
    .rstable td:before {
        content: attr(data-title);
        font-weight: 500;
        padding-bottom: 5px;
        font-size: 16px;
        color: #000;
    }
}

@media (min-width: 280px) and (max-width: 319px) {
    .rstable td {
        width: 23%;
    }
}
/* Responsive Table Ends */      
.arrow-right,
    .arrow-left {
        display: block;
        margin: 10px auto;
        width: 8px;
        height: 8px;
        border-top: 2px solid #000;
        border-left: 2px solid #000;
    }
    
    .arrow-right {
        transform: rotate(135deg);
    }
    
    .arrow-left {
        transform: rotate(-45deg);
    }
    
    .hidden {
        display: none;
    }
    
.pagination-container {
    width: calc(100% - 0rem);
    display: flex;
    align-items: center;
    position: relative;
    bottom: 0;
    padding: 0rem 0;
    justify-content: right;
    /* text-align: center; */
}

.pagination-number,
.pagination-button {
    font-family: calibri, sans-serif;
    font-size: 16px;
    background-color: #0085b6;;
    border: none;
    margin: 0.1rem 0.1rem;
    cursor: pointer;
    height: 2rem;
    width: 2rem;
    border-radius: 0.2rem;
}

.newpagination-numbers {
    font-family: calibri, sans-serif;
    font-size: 16px;
    background-color: #333;;
    border: none;
    margin: 0.1rem 0.1rem;
    height: 2rem;
    width: 2rem;
    line-height: 2rem;
    border-radius: 0.2rem;
    color: #fff;
    text-align: center;
}
.newpagination-numbers:hover {
background: #34A853;
}
.pagination-number:hover,
.pagination-button:not(.disabled):hover {
    color: #fff !important;
    background: #FBBC05;
}

button.disabled {
background-color: #c82333; /*Make it whatever color you want*/
}


.disabled { 
    
    color: #333 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
    
}

span.disabled {
    border-color: #333 !important;

}


.pagination-number.active {
    color: #fff;
    background: #0085b6;
}
  
<div class="result">
    <div class='canel-trains-grids'>
        <div class='left-cancel'>
          <span>22 Rajdhani Express Trains Listed</span>
        </div>
        <div class='right-cancel'>
            <input type="text" id="myInput" onkeyup="myFunction()" placeholder='Enter Train Number'>
        </div>
    </div>
</div>
<!-- Result Table Starts -->
<div class="rstable">
  <table id="paginated-list">
    <thead>
      <tr>
      <th>Name</th>
      <th>Position</th>
      <th>Office</th>
      <th>Extn.</th>
      <th>Joined</th>
      <th>Salary</th>
      <th>Company</th>
      <th>Contact</th>
      <th>Country</th>
      <th>Browser</th>
      <th>Platform</th>
      <th>Engine</th>
      <th>Grade</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td data-title="Name">Airi Satou</td>
        <td data-title="Position">Accountant</td>
        <td data-title="Office">No1</td>
        <td data-title="Extn.">1</td>
        <td data-title="Joined">Mar1</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">01</td>
        <td data-title="Country">Germany</td>
        <td data-title="Browser">Chrome1</td>
        <td data-title="Platform">Win 10</td>
        <td data-title="Engine">97</td>
        <td data-title="Grade">A</td>
      </tr>
      <tr>
        <td data-title="Name">Angelica Ramos</td>
        <td data-title="Position">CEO</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">2</td>
        <td data-title="Joined">Mar2</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">02</td>
        <td data-title="Country">India</td>
        <td data-title="Browser">Chrome2</td>
        <td data-title="Platform">Win 10</td>
        <td data-title="Engine">96</td>
        <td data-title="Grade">A</td>
      </tr>
      <tr>
        <td data-title="Name">Ashton Cox</td>
        <td data-title="Position">Technical Author</td>
        <td data-title="Office">Software Engineer</td>
        <td data-title="Extn.">3</td>
        <td data-title="Joined">Mar3</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">03</td>
        <td data-title="Country">Japan</td>
        <td data-title="Browser">Chrome3</td>
        <td data-title="Platform">Win 10</td>
        <td data-title="Engine">95</td>
        <td data-title="Grade">A</td>
      </tr>
      <tr>
        <td data-title="Name">Bradley Greer</td>
        <td data-title="Position">Integration Specialist</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">4</td>
        <td data-title="Joined">Mar4</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">04</td>
        <td data-title="Country">UK</td>
        <td data-title="Browser">Chrome4</td>
        <td data-title="Platform">Win 10</td>
        <td data-title="Engine">94</td>
        <td data-title="Grade">A</td>
      </tr>
      <tr>
        <td data-title="Name">Brenden Wagner</td>
        <td data-title="Position">Software Engineer</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">5</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">05</td>
        <td data-title="Country">USA</td>
        <td data-title="Browser">Chrome5</td>
        <td data-title="Platform">Win 10</td>
        <td data-title="Engine">93</td>
        <td data-title="Grade">A</td>
      </tr>
      <tr>
        <td data-title="Name">Brielle Williamson</td>
        <td data-title="Position">Pre-Sales Support</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">6</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">06</td>
        <td data-title="Country">Canada</td>
        <td data-title="Browser">Chrome6</td>
        <td data-title="Platform">Win 10</td>
        <td data-title="Engine">92</td>
        <td data-title="Grade">A</td>
      </tr>
      <tr>
        <td data-title="Name">Bruno Nash</td>
        <td data-title="Position">Sales Assistant</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">7</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">07</td>
        <td data-title="Country">Italy</td>
        <td data-title="Browser">Chrome7</td>
        <td data-title="Platform">Win 10</td>
        <td data-title="Engine">91</td>
        <td data-title="Grade">A</td>
      </tr>
      <tr>
        <td data-title="Name">Andy</td>
        <td data-title="Position">Javascript Developer</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">8</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">08</td>
        <td data-title="Country">Mexico</td>
        <td data-title="Browser">Chrome8</td>
        <td data-title="Platform">Win 10</td>
        <td data-title="Engine">90</td>
        <td data-title="Grade">A</td>
      </tr>
        <tr>
        <td data-title="Name">Sandy</td>
        <td data-title="Position">ACD</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">9</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">09</td>
        <td data-title="Country">Uganda</td>
        <td data-title="Browser">Chrome9</td>
        <td data-title="Platform">Win 13</td>
        <td data-title="Engine">83</td>
        <td data-title="Grade">A</td>
      </tr>
        <tr>
        <td data-title="Name">Candy</td>
        <td data-title="Position">DEF</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">10</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">10</td>
        <td data-title="Country">Africa</td>
        <td data-title="Browser">Chrome10</td>
        <td data-title="Platform">Win 12</td>
        <td data-title="Engine">86</td>
        <td data-title="Grade">A</td>
        </tr>
        <tr>
        <td data-title="Name">Caesar Vance</td>
        <td data-title="Position">Javascript Developer</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">11</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">11</td>
        <td data-title="Country">Dubai</td>
        <td data-title="Browser">Chrome11</td>
        <td data-title="Platform">Win 11</td>
        <td data-title="Engine">97</td>
        <td data-title="Grade">A</td>
      </tr>
       <tr>
        <td data-title="Name">Caesar Vance</td>
        <td data-title="Position">Javascript Developer</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">12</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">12</td>
        <td data-title="Country">Dubai</td>
        <td data-title="Browser">Chrome11</td>
        <td data-title="Platform">Win 11</td>
        <td data-title="Engine">97</td>
        <td data-title="Grade">A</td>
      </tr>
         <tr>
        <td data-title="Name">Caesar Vance</td>
        <td data-title="Position">Javascript Developer</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">13</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">13</td>
        <td data-title="Country">Dubai</td>
        <td data-title="Browser">Chrome11</td>
        <td data-title="Platform">Win 11</td>
        <td data-title="Engine">97</td>
        <td data-title="Grade">A</td>
      </tr>
        <tr>
        <td data-title="Name">Caesar Vance</td>
        <td data-title="Position">Javascript Developer</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">14</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">14</td>
        <td data-title="Country">Dubai</td>
        <td data-title="Browser">Chrome11</td>
        <td data-title="Platform">Win 11</td>
        <td data-title="Engine">97</td>
        <td data-title="Grade">A</td>
      </tr>
        <tr>
        <td data-title="Name">Caesar Vance</td>
        <td data-title="Position">Javascript Developer</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">15</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">15</td>
        <td data-title="Country">Dubai</td>
        <td data-title="Browser">Chrome11</td>
        <td data-title="Platform">Win 11</td>
        <td data-title="Engine">97</td>
        <td data-title="Grade">A</td>
      </tr>
        <tr>
        <td data-title="Name">Caesar Vance</td>
        <td data-title="Position">Javascript Developer</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">16</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">16</td>
        <td data-title="Country">Dubai</td>
        <td data-title="Browser">Chrome11</td>
        <td data-title="Platform">Win 11</td>
        <td data-title="Engine">97</td>
        <td data-title="Grade">A</td>
      </tr>
            <tr>
        <td data-title="Name">Caesar Vance</td>
        <td data-title="Position">Javascript Developer</td>
        <td data-title="Office">CR</td>
        <td data-title="Extn.">17</td>
        <td data-title="Joined">Mar</td>
        <td data-title="Salary">GKP</td>
        <td data-title="Company">Island Trading</td>
        <td data-title="Contact">17</td>
        <td data-title="Country">Dubai</td>
        <td data-title="Browser">Chrome11</td>
        <td data-title="Platform">Win 11</td>
        <td data-title="Engine">97</td>
        <td data-title="Grade">A</td>
      </tr>
    </tbody>
  </table>
</div>
<div style="width: 100%; display: flex;align-items: center;">
  <div style="text-align: left; width: 50%;">
      <span id="currpagecount"></span><span id="totalrowscount"></span>
  </div>
  <div class="pagination-container">
    <button class="pagination-button" id="prev-button" aria-label="Previous page" title="Previous page">
      <span class="arrow-left"></span>
    </button>
    <div id="pagination-numbers" class="newpagination-numbers">
      <span id="currentPage"></span>/<span id="pageCount"></span>
    </div>
    <button class="pagination-button" id="next-button" aria-label="Next page" title="Next page">
      <span class="arrow-right"></span>
    </button>
  </div>
</div>

How to play audio from socket message as arraybuffer to audiosource in React

I’m sending audio data through audio worklet node and getting response audio as arraybuffer through same socket on socket message event how to play in my device

I’m setting arraybuffer to audiocontext:

function decodeAudioData(audioData) { if (!audioContext) return; audioContext.current.decodeAudioData(audioData, function (decodedData) { const channelData = decodedData.getChannelData(0); audioBuffer.copyToChannel(channelData, 0); }); }

my app,jsx not working and not showing on local host

I was building this project and it was working fine on the local host until i resumed it the other day and it stopped working on the local host and just showing blank screen(http://localhost:5173/) to be specific. I am new to this so i am very confused. Help would be appreciated .

import { CustomerReviews, Footer, SuperQuality, PopularProducts, Services, SpecialOffer, Hero, Subscribe, Nav} from "./sections";
const App = () => (
 
  <main className="relative">
    <Nav />
    <section className='xl:padding-1 wide:padding-r padding-b'>
      <Hero />
    </section>
    <section className="padding">
      <PopularProducts />
    </section>
    <section className="padding">
      <SuperQuality />
    </section>
    <section className="padding-x py-10">
      <Services />
    </section>
    <section className=" bg-pale-blue padding">
      <SpecialOffer />
    </section>
    <section className="padding">
      <CustomerReviews />
    </section>
    <section className="padding-x sm:py-32 py-16 w-full">
      <Subscribe />
    </section>
    <section className='bg-black padding-x padding-t pb-8'>
      <Footer />
    </section>
  </main>
);

I was following a tutorial for this but the result wasn’t the same as the tutorial.

Create img from canvas before render (HTML, JS, JSX)

I was wandrering if it’s possible to use canvas.getContext() before the page is loaded.
The goal is to create multiple image randomly drawn from a canvas.

The problem is that i cant figure out if it is possible to do so

I can randomly create image using canvas
I can turn canvas to img element

but i need to to it before the page load

How to validate spartan-multi-image-picker as a required field (check if image was uploaded)?

I’m in a situation where I HAVE to use jquery multi step form. In this form, the user must upload a photo (required field).

Desired outcome:

  1. If the user uploads an image, it goes to the next screen.
  2. If the user does not choose an image, it show an ERROR message after image upload field.

enter image description here

i need to show error message after the “identity image” upload field, if user not uploaded the image or “identity image” field is not empty.

React Navigation page transition animation is not showing when i render React Native Vision Camera

I am developing a mobile application with React Navigation and React Native Vision Camera.

I am using native-stack and added the animation to each Stack.Screen.

  <Stack.Screen
    ...
    options={{animation: 'slide_from_right',...}}
   />

They are working well until i navigate user back from ScanScreen, which contained a react native vision camera component.

My working flow is Home -> Scan -> Result -> back to Home.

The animation is working when i navigate to ScanScreen, but if i call goBack() in ScanScreen, or call popToTop() in ResultScreen, the animation will be gone and the app looks like stucked little bit.

Here is the code of my ScanScreen

const ScanScreen = ({route, navigation}) => {
  const {locations} = route.params;

  // permission
  const {hasPermission, requestPermission} = useCameraPermission();
  // if camera page is active
  const isFocussed = useIsFocused();
  const isForeground = useIsForeground();
  const isActive = isFocussed && isForeground;

  // camera torch control
  const [torch, setTorch] = useState('off');
  // get device
  const device = useCameraDevice('back');
  // inititalization
  const [isCameraInitialized, setIsCameraInitialized] = useState(false);
  const onInitialized = useCallback(() => {
    console.log('Camera initialized!');
    setIsCameraInitialized(true);
  }, []);

  const codeScanner = useCodeScanner({
    codeTypes: ['qr', 'ean-13'],
    onCodeScanned: codes => {
      onQRCodeScan({codes});
    },
  });

 useFocusEffect(
    useCallback(() => {
      if (!hasPermission) {
        requestPermission();
      }
      return () => {
    //    setIsCameraReady(false);
      };
    }, []),
  );

     {device != null && (
        <Camera
          style={{flex: 1}}
          device={device}
          isActive={isActive}
          onInitialized={onInitialized}
          codeScanner={codeScanner}
          torch={torch}
        />
      )}
})

I am thinking if the vision camera is too heavy? or maybe i am wokring with a wrong lifecycle. I have not try it on IOS yet.

I tried to deactivate the camera before leaving the page, however the transitionStart is not fired after i can goBack()

React.useEffect(() => {
  const unsubscribe = navigation.addListener('transitionStart', (e) => {
    // Do something
  });

  return unsubscribe;
}, [navigation]);

Cannot read properties of undefined (reading ‘toString’) error al usar react dnd kit

I can’t use the toString method to apply the CSS that comes from dnd utilities

import { useSortable } from '@dnd-kit/sortable';
import React from 'react';
import { Button, Card } from 'react-bootstrap';
import { CSS } from '@dnd-kit/utilities';

const Column = ({ colum, onDelete }) => {
  const { setNodeRef, attributes, listeners, transform, transition } = useSortable({
    id: colum.id,
    data: {
      type: 'Column',
      colum
    }
  });

  const style = {
    transition,
    transform: CSS.transform.toString(transform),
  };

  return (
    <Card style={{ ...colum.style, ...style }} ref={setNodeRef}>
      <Card.Header {...attributes} {...listeners} className="d-flex justify-content-between align-items-center">
        <span>{colum.title}</span>
        <Button variant="danger" onClick={onDelete}>
          Delete
        </Button>
      </Card.Header>
      <Card.Body className="d-flex justify-content-center align-items-center">asd</Card.Body>
    </Card>
  );
};

export default Column;

I tried to do it this way but I still receive undefined and therefore the code breaks

  const style = {
    transition,
    transform: transform ? CSS.transform.toString(transform) : ''
  };

Is there is method check the jwt token cookie different localhost port?

In my E-comm web site have admin and client two different project .All the users use to login theri account using client login page.. how I admin redirect to admin dashboard in admin project securly. the client project run on localhost:3000 and admin project run localhost:3001 . I have throbule how passe jwt cooke betwen two different port and method ?

client login page
if (response.data) {  
          localStorage.setItem('token', response.data)
          window.location.href="http://localhost:3001/"
          
        }
//admin dashboard
  useEffect(() => {
    const token = localStorage.getItem('token');
    console.log('Token:', token);
    if (!token) {
        window.location.href = 'http://localhost:3000/login'; 
    }else{
      console.log("no set cookie")
    }

}, []);

when i execute like this imediatly agin load the login page

multiple event listeners using addeventListener to the same event

I type this code to the browser console:

document.body.addEventListener(
    "click",
    () => {
        Promise.resolve().then(() => console.log(1));
        console.log(2);
    },
    false
);

document.body.addEventListener(
    "click",
    () => {
        Promise.resolve().then(() => console.log(3));
        console.log(4);
    },
    false
);

This two event listener listen the click event and print numbers.

then I wrote a line to execute this statement:

document.body.click();

Meets my expectations, the result is:

2
4
1
3

But then,I click the screen, the event callbacks is triggered with this result:

2
1
4
3

why clicking to the scrren and executing the body.click() mannually makes different results?

Dynamically creating a new table based on remaining data from JSON

I have this script that pulls data from a JSON and inserts images into a table, with a maximium numberf of images per row being 5. However, sometimes there are a remainder number of iamges that need to go into the table. This means they’re not center aligned. I’d like to include functionality that dynamically creates a new table and inserts them in there, that way, they’ll be center aligned regardless of how many end up being there (between 1 and 4).

This is my current script:

function populateTable(currentPage, tableName) {
    // Fetch data from the JSON file
    fetch('data.json')
        .then(response => response.json())
        .then(jsonData => {
            const tableBody = document.querySelector(`#${tableName} tbody`);

            // Filter the jsonData array based on criteria
            const filteredData = jsonData.filter(item => {
                const sections = item.Sections || [];
                return sections.some(section => {
                    return section.Page === currentPage && section.Table === tableName;
                });
            });

            // Sort the filteredData array alphabetically by card name
            filteredData.sort((a, b) => {
                const cardA = a.Card.toLowerCase();
                const cardB = b.Card.toLowerCase();
                return cardA.localeCompare(cardB);
            });

            let currentRow;
            let itemsInCurrentRow = 0;

            filteredData.forEach(item => {
               
                if (window.innerWidth > window.innerHeight){
                    if (!currentRow || itemsInCurrentRow >= 5) {
                        currentRow = tableBody.insertRow();
                        itemsInCurrentRow = 0;
                    }
                } else {  
                    if (!currentRow || itemsInCurrentRow >= 3) {
                        currentRow = tableBody.insertRow();
                        itemsInCurrentRow = 0;
                    }
                }
                
                const nameCell = currentRow.insertCell(itemsInCurrentRow);
                // Similar mobile functionality here. If the width is less than the height, don't draw copybuttons.
                nameCell.innerHTML = `
                    <div style="position: relative;">
                        <a href="${item.Link}" target="_blank">
                            <img class='card-image' src="${item.ImageJPG}" alt="${item.Card}"/>
                        </a>
                        ${window.innerWidth > window.innerHeight ? `<p class="copybtn">${item.Card}</p>` : ''} 
                    </div>`;

                itemsInCurrentRow++;
            });
        })
        .catch(error => console.error('Error fetching data:', error));
}

I’ve tried using the likes of

if (remainingImages < 5 && itemsInCurrentRow === 5) {
                    // If there are no remaining images and the current row has less than 5 items, create a new table
                    const newTableBody = document.createElement('tbody');
                    const newTable = document.createElement('table');
                    newTable.id = `${tableName}-extra`; // Create a unique ID for the new table
                    newTable.appendChild(newTableBody);
                    // Append the new table after the original table
                    tableBody.parentNode.insertBefore(newTable, tableBody.nextSibling);
                    tableBody = newTableBody; // Set tableBody to the new table body for further insertion
                    currentRow = null; // Reset currentRow to trigger creation of new rows
                    itemsInCurrentRow = 0; // Reset itemsInCurrentRow for the new table
                }

but I’m not sure why it isn’t actually working. I suspect there’s something with the logic that triggers this, but it’s just a simple check for the number of items in the current row if there aren’t any images to pull.

Element hide and show causing the Largest Contentful Paint 8000ms

I would like to initially hide an image and then display it only on the first page load, as determined by checking a cookie. However, this approach could lead to issues with the Largest Contentful Paint metric. Do you have any suggestions on how to avoid this problem?

Below is the problematic code:

document.addEventListener('DOMContentLoaded', function () {
  if (!document.cookie.split(';').some((item) => item.trim().startsWith('userEntered='))) {
    document.getElementById('c_img').style.display = 'block';
  }
});
<div id="content" style="height: 100vh;">
  <img id="c_img" src='button.png' style="height: 70px; width:70px; display: none" />
</div>

Showing the image by default and then hiding it if a ‘userEntered’ cookie is present avoids LCP issues. However, this approach results in the image briefly appearing and then disappearing.
Example:

document.addEventListener('DOMContentLoaded', function () {
  if (document.cookie.split(';').some((item) => item.trim().startsWith('userEntered='))) {
    document.getElementById('c_img').style.display = 'none';
  }
});
<div id="content" style="height: 100vh;">
  <img id="c_img" src='button.png' style="height: 70px; width:70px;/>
</div>

having problems posting data to the backend

i am developing a MERN website for the first time and i face problem with the signup functionality when i post the data it give me a 400 Bad Request response

this is the signup backend controller:

// handling signup
export const signupControl = async (req, res) => {
  try {
    const { fullname, matric, password, matricImage } = req.body;

    // check if matric already exist
    const user = await User.findOne({ matric });
    if (user) {
      return res.status(400).json({ error: `matric already exist` });
    }

    // check if password length is less than 8
    const passLength = password;
    if (passLength.length < 8) {
      return res.status(400).json({ error: "password is less than 8" });
    }

    // crypt password
    const salt = await bcrypt.genSalt(10);
    const hashedPass = await bcrypt.hash(password, salt);

    // create new user
    const newUser = User.create({
      fullname,
      matric,
      password: hashedPass,
      matricImage,
    });

    if (newUser) {
      generateTokenAndCookie((await newUser)._id, res);
      (await newUser).save();

      res.status(200).json({
        _id: (await newUser)._id,
        fullname: (await newUser).fullname,
        matric: (await newUser).matric,
        password: (await newUser).password,
        matricImage: (await newUser).matricImage,
      });
    } else {
      res.status(400).json({ error: "invalid user data" });
      console.log("error");
    }
  } catch (err) {
    console.log(err);
    res.status(500).json({ error: `${err.message}` });
  }
};

and here is the frontend code where i bring the data and submit them:

const Signup = () => {
const [inputs, setInputs] = useState({
fullname: “”,
matric: “”,
password: “”,
matricImage: “”,
});

const handleSubmit = async (e) => {
e.preventDefault();

const formData = {
  fullname: inputs.fullname,
  matric: inputs.matric.trim(), // Trim whitespace
  password: inputs.password,
  matricImage: inputs.matricImage,
};

console.log(formData);

try {
  const response = await fetch("http://localhost:3000/auth/signup", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(formData),
  });

  const data = await response.json();
} catch (error) {
  toast.error(error.message);
}

};

i assign all the data from the inputs forms inside a variable called formData which formatted according to the backend need, same data format i used when testing on postman and worked for me.
also i tried submitting different values and still no changes

NOTES
when i consloe log the formData it give me same needed data for the backend =
{
“fullname”: “ahmed omar”,
“matric”: “b032219461”,
“password”: “1234567890”,
“matricImage”: “data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaI”
}

also both servers(frontend, backend) are running during the proccess still facing the problem

and when tested on postman it works.
however when i write data in the frontend form and post them via fetch request it give me a 400 bad request response, still dont know where in the frontend is the problem since its a 400 response then it must be from the frontend right ?

Voyager Admin Panel Bulk Update With Old Data

I am using the bulkUpdate library for Voyager Admin Panel. I am currently facing the problem where when choosing the rows to update, I will need to pass a specific status to my formfield for some extra processing at my formfield. However, my problem is when I bulkUpdate, a new modal is created and cannot be updated using the status I grabbed. Any ideas on how to pass my “Status” to my formfield blade?

I tried to call from JS to update the PHP but failed.
AJAX and controller doesn’t seem to work for my case since the formfield.blade is included in my current file