How to check the similarity of many arrays in javascript? [closed]

Hi im new to JavaScript and i want to check the similarity of many Arrays. So i have an base array [true, false, true, true] and then i have like 24 other arrays with not the same but similar values and then i want to find the array with the most similarity. I don’t know how to do this so im asking. I found some post about this but they where 10 years ago and I didn’t understand a thing and wanted to ask if there is an easy way to do this.
I would be happy if someone can help me.

I tried a bit and researched but I didn’t understand it and could not figure out the math that was explained. Im near to 10st grade and I didn’t had this math in school yet.

Seeking Advice on Progressing as a Full-Stack Developer

Dear Stack Overflow community,

Hope you’re all doing well! I’m a student with a knack for JavaScript, PHP, and CSS, aiming to dive deep into the world of full-stack development. I’ve been on a quest to spice up my skills and gain a broader understanding of the full-stack landscape.

I’d love to tap into your collective wisdom with a couple of questions:

  • Any cool learning hacks or methodologies you swear by for leveling up as a full-stack developer?

  • Curious to hear about those game-changing projects or hands-on experiences that really propelled your growth when you first started out.

Here’s the deal: despite devouring every tutorial in sight, tackling countless challenges, and feeling like I’m making progress, I’ve hit a plateau. It’s a bit disheartening. I find myself constantly seeking solutions online and struggling to implement my own fixes without that crutch.

The frustration is real, and I’m eager to break free from this cycle. If anyone has faced a similar hurdle or has advice on how to overcome this learning plateau, I would be incredibly grateful for your guidance.

Wpdatatables conditional rule in row

I am using the wpdatatables plugin to list a group of apartments.
I had an idea to use a plugin for listing apartments, which would have columns: square footage, number of rooms, floor, status, link to the apartment plan, link to the page with the form. My question was about a situation in which if the status of the apartment changes to “sold”, it will affect another specific cell with a link in a different column in the same row.

Is there no way to hide the contents of a cell in a row with some javascript code? I will be very grateful for tips on solving the problem. Kind regards

I tried


```

document.addEventListener("DOMContentLoaded", function() {
var table = document.getElementById("table_1");
var rows = table.getElementsByTagName("tr");

for (var i = 0; i < rows.length; i++) {
var cells = rows[i].getElementsByTagName("td");

if (cells.length > 1 && cells[0].innerText === "SOLD") {
  cells[1].style.display = "none"; 
}

}
});

</code>

but not working

Matching two path elements using javascript regex to make the right hand side greedy

I am trying to match this.

/1234/5678
/1234

Into A and B, where the B is optional using this regular expression.

/.*/(?<A>d+)(/(?<B>.+?))?$/.exec("/1234/5678").groups;

I want A=1234, and B=5678 when the path contains two parts, and when there’s only one part, then just match A.

How do I make the optional /5678 greedy so that it matches if it’s there, but still matches A if it’s not.

/1234/5678 (A=1234, B=5678)
/1234 (A=1234, B=undefined)

issue with dynamically created elements being draggable in HTML and JS

I’m helping a friend design a class organizer for one of their classes. I have a list of classes that show up on a search bar on the left of the screen and they need to be dragged into boxes on the right side of the screen. the JS I have for the draggable items works just fine if I manually add the element to the HTML, but when I use JS to add the element using data from a CSV file they are unable to be dragged around. The only solution I’ve found is I need to read the listeners for the dragging function in the loop that creates the items but that hasn’t fixed the problem for me. Ive added the html js and css below. I am not using any libraries other than papaparse for the CSV data extraction.

//dynamically add lines to search menu

var data;

Papa.parse('test.csv', {
 header: true,
 download: true,
 dynamicTyping: true,
 complete: function(results) {
   console.log(results);
   data = results.data;
   console.log(data.length);

   // Create and append draggable elements
   for(var i = 0; i < data.length; i++) {
     var opt = data[i].Title;
     var el = document.createElement("p");
     el.setAttribute("class","draggable");
     el.setAttribute("draggable","true");
     el.value = opt;
     el.textContent = opt;
     el.addEventListener('dragstart', () => {
      el.classList.add('dragging')
    })
  
    el.addEventListener('dragend', () => {
      el.classList.remove('dragging')
    })

    classitem.appendChild(el);
   }
 }
});

//allows elements to be draggable
const draggables = document.querySelectorAll('.draggable')
const containers = document.querySelectorAll('.container')

draggables.forEach(draggable => {
  draggable.addEventListener('dragstart', () => {
    draggable.classList.add('dragging')
  })

  draggable.addEventListener('dragend', () => {
    draggable.classList.remove('dragging')
  })
})

containers.forEach(container => {
  container.addEventListener('dragover', e => {
    e.preventDefault()
    const afterElement = getDragAfterElement(container, e.clientY)
    const draggable = document.querySelector('.dragging')
    if (afterElement == null) {
      container.appendChild(draggable)
    } else {
      container.insertBefore(draggable, afterElement)
    }
  })
})

function getDragAfterElement(container, y) {
  const draggableElements = [...container.querySelectorAll('.draggable:not(.dragging)')]

  return draggableElements.reduce((closest, child) => {
    const box = child.getBoundingClientRect()
    const offset = y - box.top - box.height / 2
    if (offset < 0 && offset > closest.offset) {
      return { offset: offset, element: child }
    } else {
      return closest
    }
  }, { offset: Number.NEGATIVE_INFINITY }).element
}


    /* When the user clicks on the button,
    toggle between hiding and showing the dropdown content */
    function myFunction() {
      document.getElementById("myDropdown").classList.toggle("show");
    }
    
    function filterFunction() {
      var input, filter, ul, li, a, i;
      input = document.getElementById("myInput");
      filter = input.value.toUpperCase();
      div = document.getElementById("myDropdown");
      p = div.getElementsByTagName("p");
      for (i = 0; i < p.length; i++) {
        txtValue = p[i].textContent || p[i].innerText;
        if (txtValue.toUpperCase().indexOf(filter) > -1) {
          p[i].style.display = "";
        } else {
          p[i].style.display = "none";
        }
      }
    }

<!DOCTYPE html>
<html lang="en" >
<head> 
  <script  src="papaparse.min.js"></script>

  <meta charset="UTF-8">
  <title></title>
  <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Merriweather|Open+Sans'><link rel="stylesheet" href="./haha.css">
  <style>
header {
  font-family: "Open Sans", sans-serif;
  font-size: 16px;
  font-weight: 100;
}

body {
  font-family: Merriweather, serif;
}
</style>
</head>
<body>
  <div class="header">
    <h1>test</h1>
  </div>
<p id="classdata"></p>
<p id="classdata2"></p>
<p style="height: 100px;"></p>
<h2 style="text-align: centre; position: relative; padding-left: 200px; padding-top: 0px; display:inline-block;">Courses</h2>
<h2 style="text-align: centre; position: relative; padding-left: 200px; padding-top: 0px; display:inline-block;">Four year plan</h2>
<div class="row">
  <div class="column">  
   <!--dropdown-->  
   <div class="dropdown">
    <button onclick="myFunction()" class="dropbtn">Core Classes</button>
    <div id="myDropdown" class="dropdown-content">
      <input type="text" placeholder="Search.." id="myInput" onkeyup="filterFunction()">
      <div id="classitem" class="container" style="width: 70%; background-color: white; border: none;">
        <p class="draggable" draggable="true">CHEM1000</p>
      </div>
    </div>
  </div> 
  </div>
  <div class="column2">   
  <div class="top">
    <div class="container">
    </div>
    <div class="container">
    </div>
    <div class="container">
    </div>
    <div class="container">
    </div>
  </div>
  <div class="bot">
    <div class="container">
    </div>
    <div class="container">
    </div>
    <div class="container">
    </div>
    <div class="container">
    </div>
  </div>       
  </div>
</div> 

<script src="./hehe.js"></script>

</body>
</html>

body {
  margin: 0;
}
.row {
  display: flex;
}
.header {
padding: 10px;
text-align: left;
background: #982828;
color: white;
letter-spacing: 16px;
font-weight: 100;
}

.column {
  flex: 20%;
}
.column2 {
  flex: 80%;
}
.container {
  background-color: white;
  border-radius: 10px;
  width: 20%;
  border: 1px solid black;
  height: 17rem;
  padding: .5rem;
  margin: .1rem;
  float:d left;
  overflow: auto;
}
.top {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}
.bot {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}
.draggable {
  margin-top: .5rem;
  padding: .4rem;
  border-radius: 10px;
  width: auto;
  background-color: white;
  border: 1px solid black;
  cursor: move;
}

/* ===== Scrollbar CSS ===== */
/* Firefox */
* {
  scrollbar-width: auto;
  scrollbar-color: #565252 #ffffff;
}

/* Chrome, Edge, and Safari */
*::-webkit-scrollbar {
  width: 14px;
  
}

*::-webkit-scrollbar-track {
  background: #ffffff;
}

*::-webkit-scrollbar-thumb {
  background-color: #565252;
  border-radius: 10px;
  border: 3px solid #ffffff;
}

.draggable.dragging {
  opacity: .5;
}


#myInput {
  box-sizing: border-box;
  background-image: url('searchicon.png');
  background-position: 14px 12px;
  background-repeat: no-repeat;
  position: relative;
  border-radius: 5px;
  width: 220px;
  font-size: 16px;
  padding: 14px 20px 12px 45px;
  border: 1px solid black;
}

#myInput:focus {outline: 3px solid #ddd;}

.dropdown {
  position: relative;
  left: 50%;
  margin-left: -150px;
  display: inline-block;
}
.dropbtn {
  display: inline-block;
  background-color: white;
  border: 1px solid black;
  color: black;
  padding: 16px;
  position: relative;
  margin-top: .1rem;

  font-size: 16px;
  border-radius: 5px;
  width: 300px;
  cursor: pointer;
}

.dropbtn:hover, .dropbtn:focus {
  background-color: white;
}

.dropdown-content {
  display: none;
  position: absolute;
  border-radius: 5px;
  background-color: white;
  margin: 24px 17px 24px 33px;
  min-width: 250px;
  z-index: 1;
}


.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown a:hover {background-color: #ddd;}

.show {display: block;}

Telegram Webhook is not getting supported

I am trying to setup Webhook in my telegram Bot app but the issue is when I am removing the polling:true value its not working, after any commands no response is coming.

export class UserWorker {
  private bot: TelegramBot;
  private databaseService: DatabaseService;
  private notificationService: TelegramNotificationService;
  private userService: TelegramUserService;

  constructor(telegramBotToken: string, webhookUrl: string) {
    this.bot = new TelegramBot(telegramBotToken, { polling: true});

    this.setUpExpress(telegramBotToken);

    this.setWebHook(webhookUrl, telegramBotToken);

    this.databaseService = DatabaseProvider.createService();
    this.notificationService = NotificationProvider.createService(
      this.bot,
      this.databaseService,
    );
    this.userService = UserServiceProvider.createService(
      this.bot,
      this.databaseService
    );
    this.userService.init();
    this.notificationService.init();
  }

  private setUpExpress(telegramBotToken: string) {
    const app = express();
    app.use(bodyParser.json());
    
    app.listen(port, () => {
      console.log(`Express server is listening on ${port}`);
    });

    app.post(`bot${telegramBotToken}`, (req:any, res:any) => {
      try {
        this.bot.processUpdate(req.body);
        res.sendStatus(200);
      } 
      catch(error) {
        console.log('Error in Processing Request:', error)
      }
    });
  }

  private async setWebHook(webhookUrl: string, telegramBotToken: string) {
    try {
      const webhookInfo = await this.bot.getWebHookInfo();
      if (webhookInfo.url === webhookUrl) {
        console.log('Webhook is already set to the correct URL');
        return;
      }
  
      await this.bot.setWebHook('');
      console.log('Existing webhook removed');
  
      const fullWebhookUrl = encodeURI(`${webhookUrl}/bot${telegramBotToken}`);
      await this.bot.setWebHook(fullWebhookUrl);
      console.log('Webhook is set', fullWebhookUrl);
    } catch (error) {
      console.error('Error in setting webhook:', error);
    }
  }
}

After removing the { polling: true } no command is listen by the Telegram bot and its working along only with { polling: true } command I setup the entire Webhook and webhook url is also active, since the webhook in the telegram bot is more efficient how can I get rid of this polling: true in my code

Understanding Source Map Generation Through Multiple Code Transformations (TypeScript, Hermes, Obfuscator, etc.)

I’m working on a project involving multiple layers of code transformation, and I’m trying to understand how source map generation works in such a complex setup. Our project uses TypeScript, and on top of that, we apply a series of transformations including Hermes for bytecode conversion, a minifier-obfuscator, and various utilities for tasks like log cleaning. Each of these layers affects the final bundle.js file.

My primary concern is about the generation and the accuracy of source maps through these sequential transformations. Specifically, I’m looking to understand:

How does source map generation work when the code undergoes multiple transformations? Is there a standard process that ensures the mapping remains accurate through each stage (TypeScript compilation, Hermes bytecode conversion, obfuscation, etc.)?

If each transformation layer potentially generates its own source map, how can I effectively backtrack to the original TypeScript code? Is there a way to merge or chain these source maps so that debugging reflects the original source accurately?

Thank you for your time and help!

I want to make ai image generator but i have error

enter image description here

what is error

code:
enter image description here

enter image description here

if you want css tell me
what the slove,If something is not clear, you can tell me

God willing, we will find a solution, waiting for solutions

css code:

*{
    padding: 0;
    margin: 0;
    font-family: sans-serif;
}
body{
    background-color: #1d2023;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    height: 100vh;
}

h2 {
    color: #fff;
    font-size: 40px;
}
.prompt{
    background-color: #292c31;
    padding: 5px;
    width: 620px;
    border: 3px solid #36383d;
    border-radius: 10px;
}
input,button{
    padding: 10px;
    border: none;
    font-size: 20px;
    color: #fff;
}
input{
    background-color: #292c31;
    width: 75%;
    outline: none;
}
button{
    background-color: #36383d;
    width: 20%;
    cursor: pointer;
}
button:hover{
    background-color: #45464a;
}
.images{
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 10px;
}
.images div{
    height: 200px;
    width: 200px;
    background-color: #292c31;
    border-radius: 10px;
    border: 3px solid #36383d;
}
.images div img{
    width: 100%;
}

Cakephp 4 Ajax call

In cakephp 4 and in this ajax function the the beforeSend’s alert message has been displayed in the browser but the request is not sent to the server.Both success and error are not working.

Finally this ajax function is not at all working.There is no any error in console or there is no any request sent in the network tab of the browser but beforeSend is working.

What may be the problem ?
Its been couple of months when we got this error but not able to figure out whats the problem is , please let me know if any one has the solution.

$.ajax({
  url: "kalyan/ajaxRequest",
  type: "POST",
  data: postcontent,
  processData: false,
  contentType: false,
  beforeSend: function (xhr) {
    // Set the CSRF token in the request headers
    xhr.setRequestHeader("X-CSRF-Token", csrfToken);
    alert("CSRF Token: " + csrfToken);
  },
  success: function (response, textStatus, jqXHR) {
    alert("Yay!");
    document.getElementById("result").innerHTML = response;
    alert(response);
  },
  error: function (jqXHR, textStatus, errorThrown) {
    alert(textStatus, errorThrown);
    console.error("Error:", errorThrown);
  },
});

I was expecting any error or success message to be shown in the console but nothing has been.

can we create multiple routes with same name in reactjs

<Router>
  <Routes>
    <Route exact path="/" element={<Home />} />
    <Route exact path="*" element={<Navigate to="/dashboard" />} />
    <Route element={<SuperadminRoute />}>
      <Route exact path="/dashboard" element={<Mycomponent />} />
    </Route>
    <Route element={<AdminRoute />}>
      <Route exact path="/dashboard" element={<Mycomponent />} />
    </Route>
    <Route element={<UserRoute />}>
      <Route exact path="/dashboard" element={<Mycomponent />} />
    </Route>
  </Routes>
</Router>

superadmin.js

return (
  <div>
    <Header1 />
    <Outlet />
  </div>
)

admin.js

return (
  <div>
    <Header2 />
    <Outlet />
  </div>
)

user.js

return (
  <div>
    <Header3 />
    <Outlet />
  </div>
)

In all my parent components i.e. SuperadminRoute, Admin, UserRoute we have different headers and that is why I do not want to make a separate container for the common routes because I have to put conditions for the headers. So is it possible to create route with same name and whoever the role logged in should redirect to their route?

ReactJS Problem – Can’t understand the form property [duplicate]

In the below code i am conditionally rendering img if there is form.photo then show photo otherwise show preview but i can’t understand about the form.photo where it’s gonna check what is the meaning of that form.photo.

<form action="" onSubmit={handleSubmit} className="mt-16 max-w-3xl">
  <div className="flex flex-col gap-5">
    <FromField
      labelName="Your Name"
      type="text"
      name="name"
      placeholder="Vaibhav patel"
      value={form.name}
      handleChange={handleChange}
    />
    <FromField
      labelName="Prompt"
      type="text"
      name="prompt"
      placeholder="'A Samurai riding a Horse on Mars, lomography.'"
      value={form.prompt}
      handleChange={handleChange}
      isSurpriceMe
      handleSurpriceMe={handleSurpriceMe}
    />

    <div className="relative  bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blur-500 focus:border-blue-500 w-64 p-3 h-64 flex justify-center items-center">
      {form.photo ? (
        <img
          src={form.photo}
          alt={form.prompt}
          className="w-full h-full object-contain"
        />
      ) : (
        <img
          src={preview}
          alt="preview"
          className="w-9/12 object-contain object-opacity-40"
        />
      )}
    </div>
  </div>
</form>;

HTML input type number that should allowed only number not special character like , . and –

I’m trying to take input from the user as a mobile number, but when the user tries to enter a number keyboard opens with a special character, I just want the special character not seen there. I have an example for you guys

My Keyboard where I’m getting challenged,

enter image description here

I researched but I didn’t get a solution on it and I have also example how I want,

enter image description here

Regex to find whether given text not contain only email string

I want to write a regex (java script) to match if the given text not contain only an email string.

for ex:

I wrote a regex using (?<!…) Negative lookbehind, to check whether given text does contain only email string or not as below. But I cant use + inside lookbehind expression and it gives A quantifier inside a lookbehind makes it non-fixed width error.

regex:

^.+(?<!([a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.com))$

explanation:

  • ([a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.com) – regex to check email address.
  • ^.+(?<!([a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.com))$ – regex to check look behind of all non empty texts (.+)

Please give me an idea to resolve this issue…

Thanks

CORS Error in POST API CALL IN REACT PROJECT

I am developing a react project with backend in python. In production build for POST API getting CORS error and after that in network section getting preflight and in request method getting OPTIONS as a value at place of POST. Same POST api I’m calling above without payload it is working fine but with payload it is giving CORS error. GET API at the same IP is working but POST is not working. I am not able to figure out why POST is not working.

CODE:

import React, { useState, useEffect, useRef, useMemo } from "react";

import Button from "@mui/material/Button";
import "../../src/input.css";
import "bootstrap/dist/css/bootstrap.css";
import { AgGridReact } from "ag-grid-react";
import "@ag-grid-community/all-modules/dist/styles/ag-grid.css";
import "@ag-grid-community/all-modules/dist/styles/ag-theme-alpine.css";
import "ag-grid-enterprise";
import { toast } from "react-toastify";
import IosShareIcon from "@mui/icons-material/IosShare";
import XLSX from "xlsx";
import { read, utils } from "xlsx";
// import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import axios from "axios";
import MockLoaderTable from "./MockLoader";
import DateCellRenderer from "./DateCellRenderer";
import "../App.css";
import { useNavigate, useParams, useLocation } from "react-router-dom";
import configDevelopment from "../config.development";
import configProduction from "../config.production";

function Table() {
  const gridApiRef = useRef(null);
  // const [gridApi, setGridApi] = useState(null);
  const gridStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const ITEMS_PER_PAGE = 10; // Adjust as needed
  const gridRef = useRef(); // Temporary state to hold changes
  const [data, setdata] = useState([
    {
      "@odata.etag": 'W/"JzE5OzUzMDQ1NDYwMzAzNDIzMzY2NDIxOzAwOyc="',
      SystemId: "a999ee0f-2301-ee11-8f6e-000d3af2c8b8",
      DocumentNo: "SOCBFOC23240001",
      DocumentType: "Order",
      LineNo: 10000,
      Type: "G/L Account",
      No: "44-022110",
      PartNo: "",
      Description: "Mounting of AP's",
      RequestedDeliveryDate: "2024-12-28",
      OrderStatus: "Open",
    },
  ]);
  const [loading, setLoading] = useState(false); // State for loading indicator
  const [postloader, setpostloader] = useState(false);
  const [isSubmitDisabled, setIsSubmitDisabled] = useState(true);
  // const { documentNo } = useParams();
  const navigate = useNavigate();
  const location = useLocation();
  const queryParams = new URLSearchParams(location.search);
  const documentNo = queryParams.get("DocumentNo");
  const apiUrl = configProduction.apiUrl;
  const [message, setMessage] = useState("");

  const exportParams = {
    skipHeader: false,
    skipFooters: true,
    skipGroups: true,
    fileName: "data.csv",
  };

  const handleDateChange = (rowIndex, date, changed) => {
    setdata((prevData) => {
      const newData = [...prevData];
      if (newData[rowIndex]) {
        newData[rowIndex].RequestedDeliveryDate = date.format("YYYY-MM-DD");
        newData[rowIndex].dateChanged = changed;
        setIsSubmitDisabled(false); // Enable the Submit button when any date is changed
      }
      return newData;
    });
  };

  const frameworkComponents = {
    dateCellRenderer: (props) => {
      return <DateCellRenderer {...props} onDateChange={handleDateChange} />;
    },
  };

  const getAllData = (documentNo) => {
    setLoading(true);
    axios
      .get(`http://192.168.11.3:8001/v1/api/bcdata?DocumentNo=${documentNo}`)
      .then((response) => {
        setdata(response.data.data);
        setLoading(false);
        // Update URL without triggering a full page reload
        const newUrl = `${window.location.origin}${window.location.pathname}?DocumentNo=${documentNo}`;
        window.history.pushState({ path: newUrl }, "", newUrl);
      })
      .catch((error) => {
        console.error("No data present");
        setLoading(false);
      });
  };

  useEffect(() => {
    getAllData(documentNo);
  }, [documentNo]);

  useEffect(() => {
    axios
      .post(`http://192.168.11.3:8001/v1/api/bcdata`)
      .then((response) => {
        setMessage(response.data.message);
      })
      .catch((error) => {
        console.log(error);
      });
  }, []);

  const handleSubmit = () => {
    const formattedData = data.filter((item) => item.dateChanged === true);

    const selectedKeys = [
      "@odata.etag",
      "SystemId",
      "RequestedDeliveryDate",
      "OrderStatus",
    ];
    const extractedData = formattedData.map((item) => {
      const selectedData = {};
      selectedKeys.forEach((key) => {
        selectedData[key] = item[key];
      });
      return selectedData;
    });

    const modifiedArray = extractedData.map((item) => {
      const { "@odata.etag": _, ...rest } = item; // Extract the key and ignore it
      return { odata: item["@odata.etag"], ...rest };
    });

    console.log(modifiedArray);
    setpostloader(true);
    axios
      .post(
        "http://192.168.11.3:8001/v1/api/bcdata?DocumentNo=${documentNo}",
        modifiedArray,
        {
          method: "POST",
          mode: "cors",
          headers: {
            "Content-Type": "application/json",
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Methods": "*",
            "Access-Control-Allow-Headers": "*",
          },
        }
      )
      .then((res) => {
        console.log("post resp", res);
        getAllData(documentNo);
        setIsSubmitDisabled(true);
        toast.success("Successfully changed the date, LOADING THE DATA!!!");
        setpostloader(false);
      })
      .catch((err) => {
        toast.error("Something went wrong");
        setpostloader(false);
      });
  };

  const headers = [
    {
      headerName: "Document Number",
      field: "DocumentNo",
      filter: true,
    },
    {
      headerName: "Description",
      field: "Description",
      filter: true,
    },
    {
      headerName: "Part Number",
      field: "PartNo",
      filter: true,
    },
    {
      headerName: "Type",
      field: "DocumentType",
      filter: true,
    },
    {
      headerName: "Line Number",
      field: "LineNo",
      filter: true,
    },
    {
      headerName: "Order Status",
      field: "OrderStatus",
      filter: true,
    },
    {
      headerName: "Requested Delivery Dates",
      field: "RequestedDeliveryDate",
      filter: true,
      cellRendererFramework: (params) => (
        <DateCellRenderer
          {...params}
          onDateChange={handleDateChange}
          orderStatus={params.data.OrderStatus} // Make sure to pass the correct field here
        />
      ),
      width: "400%",
    },
  ];

  return (
    <div style={tablestyle.table}>
      {loading || postloader ? (
        <MockLoaderTable postloader={postloader} loading={loading} />
      ) : data.length > 0 ? (
        <>
          <div className="d-flex" style={{ justifyContent: "flex-end" }}>
            <div>
              <Button
                style={tablestyle.btn}
                variant="contained"
                onClick={handleSubmit}
                disabled={isSubmitDisabled}
              >
                Submit
              </Button>
            </div>
            <div style={{ display: "flex", alignItems: "center" }}>
              <div
                style={{
                  cursor: "pointer",
                  marginRight: "-0.5rem",
                }}
                onClick={() => {
                  if (gridApiRef.current) {
                    gridApiRef.current.exportDataAsCsv(exportParams);
                  }
                }}
              >
                <IosShareIcon style={{ color: "0093fb" }} />
              </div>
              <Button
                style={{
                  color: "#0093fb",
                  display: "inline",
                  marginTop: "0.5rem",
                }}
                onClick={() => {
                  if (gridApiRef.current) {
                    gridApiRef.current.exportDataAsCsv(exportParams);
                  }
                }}
              >
                Export to CSV
              </Button>
            </div>
            <div>
              {/* <input
                style={{
                  color: "#0093fb",
                  display: "inline",
                  marginTop: "0.5rem",
                }}
                type="file"
                onChange={handleFileChange}
              /> */}
            </div>
            {/* Dropdown for column selection */}
          </div>
          <div style={containerStyle}>
            <div className="ag-theme-alpine">
              <AgGridReact
                columnDefs={headers}
                rowData={data}
                domLayout="autoHeight"
                suppressMenuHide={true}
                pagination={true}
                frameworkComponents={frameworkComponents}
                paginationPageSize={ITEMS_PER_PAGE}
                onGridReady={(params) => {
                  gridApiRef.current = params.api;
                }}
              />
            </div>
          </div>
        </>
      ) : (
        <h2>No Data Found !!!</h2>
      )}
    </div>
  );
}

export default Table;

const tablestyle = {
  table: {
    overflowX: "auto",
    marginBottom: "3rem",
    margin: "2rem",
  },

  btn: {
    float: "right",
    marginBottom: "0.5rem",
    marginRight: "1rem",
  },

  heading: {
    display: "flex",
    justifyContent: "center",
  },
};

I want solution to avoid CORS error in POST call.