How to create checkbox automatic from ajax call

Hi I needed some help on making it to auto create a checkbox to my ajax name how can i do it ?

<input type="checkbox" id="checkbox"><label id="checkbox" style="padding-left: 10px;">test</label>

Ajax call sample for options

 $.ajax({
                            // The url that you're going to post 
                            /* 
                                                    
                                                    This is the url that you're going to put to call the
                                                    backend api,
                                                    in this case, it's 
                                                    https://ecoexchange.dscloud.me:8090/api/get (production env)
                                                
                            */
                            url: "https://ecoexchange.dscloud.me:8090/api/get",
                            // The HTTP method that you're planning to use
                            // i.e. GET, POST, PUT, DELETE 
                            // In this case it's a get method, so we'll use GET
                            method: "GET",
                            // In this case, we are going to use headers as 
                            headers: {
                                // The query you're planning to call
                                // i.e. <query> can be UserGet(0), RecyclableGet(0), etc.
                                query: "RecyclableTypeGet()",
                                // Gets the apikey from the sessionStorage
                                apikey: sessionStorage.getItem("apikey")
                            },
                            success: function (data, textStatus, xhr) {
                                // console.log(data);
                                for (let option of data) {
                                                        $('#select-recyclable-type').append($('<option>', {
                                                            value: option.RecyclableType,
                                                            text: option.RecyclableType
                                                        }));
                                                     
                                                    }


                            },
                            error: function (xhr, textStatus, err) {
                                console.log(err);
                               
                            }
                        });

this is my json response that i am going to use for the name only

[
    {
        "RecyclableID": 1,
        "Name": "recyclable",
        "RecyclableType": "test recyclable type"
    },
    {
        "RecyclableID": 3,
        "Name": "test recyclable 2",
        "RecyclableType": "WASTE"
    },
    {
        "RecyclableID": 129,
        "Name": "test recyclable 4",
        "RecyclableType": "test recyclable type"
    },
    {
        "RecyclableID": 131,
        "Name": "test recyclable 6",
        "RecyclableType": "test recyclable type"
    },
    {
        "RecyclableID": 132,
        "Name": "test recyclable 7",
        "RecyclableType": "test recyclable type"
    },
    {
        "RecyclableID": 133,
        "Name": "test recyclable 8",
        "RecyclableType": "test recyclable type"
    },
    {
        "RecyclableID": 134,
        "Name": "test recyclable 34",
        "RecyclableType": "WASTE"
    },
    {
        "RecyclableID": 138,
        "Name": "recyclable thing",
        "RecyclableType": "WASTE"
    },
    {
        "RecyclableID": 139,
        "Name": "recyclable thing 2",
        "RecyclableType": "Ewaste"
    },
    {
        "RecyclableID": 153,
        "Name": "test recyclable 10",
        "RecyclableType": "Other"
    },
    {
        "RecyclableID": 154,
        "Name": "test recyclable 11",
        "RecyclableType": "Ewaste"
    },
    {
        "RecyclableID": 155,
        "Name": "test recyclable 123",
        "RecyclableType": "test recyclable type 2"
    },
    {
        "RecyclableID": 159,
        "Name": "some recyclable name",
        "RecyclableType": "CC"
    },
    {
        "RecyclableID": 161,
        "Name": "some recyclable name 2",
        "RecyclableType": "Ewaste"
    },
    {
        "RecyclableID": 162,
        "Name": "recyclable 2",
        "RecyclableType": "test recyclable type 2"
    },
    {
        "RecyclableID": 165,
        "Name": "test recyclable 15",
        "RecyclableType": "WASTE"
    },
    {
        "RecyclableID": 166,
        "Name": "test recyclable 18",
        "RecyclableType": "testing type"
    },
    {
        "RecyclableID": 167,
        "Name": "some recyclable name 23",
        "RecyclableType": "Ewaster"
    }
]

I have try to write a weird ajax option but it dont seem to working
with changing my option to checkbox
is it possible to create multiple checkbox automatic without me have to create 1 by 1 ?

Transforming a complex object into an array

I am creating a React app using data from an API. the response data is a long complicated object that looks something like this:

{
    "Frozen Products": [
        {
            "_id": "6181849285e8d8f86be2d9df",
            "name": "Peas (800g)",
            "category_id": "6181841060c425f76e57b603",
            "slug": "vegetables",
            "quantity": 16,
            "price": {
                "amount": 3.00
            },
            "thumbnail":"URI ...",,
            "images": [
                "URI ...",
            ],
            "synonyms": [
                "Veggies"
            ],
        },

//etc for many key/values inside this object ..
        
}

I need to access the information do display a category (“Frozen Products” in this case) and all the product names and images under it.

But I think I need to access each Key/Value pair by loopin through their index (example data[0]) not the Key name since they keys are dynamically created by an API. So how can I change this to:

{
   [ "Frozen Products": [
        {
            "_id": "6181849285e8d8f86be2d9df",
            "name": "Peas (800g)",
            "category_id": "6181841060c425f76e57b603",
            "slug": "vegetables",
            "quantity": 16,
            "price": {
                "amount": 3.00
            },
            "thumbnail":"URI ...",,
            "images": [
                "URI ...",
            ],
            "synonyms": [
                "Veggies"
            ],
        },
   ]

Product images are not saving to database

i am try to store the product data in database but except images everthing is storing in database but images are coming to my local folder for ref please find the below code.

How can i solve this issue ?
images are storing in my local folder but not stoting in the database.

productSchema.js

const mongoose = require("mongoose");

const productSchema = new mongoose.Schema(
  {
    name: { type: String, required: true, trim: true },
    slug: { type: String, required: true, unique: true },
    price: { type: Number, required: true },
    description: { type: String, required: true, trim: true },
    quantity: { type: Number, required: true },
    offer: { type: Number },
    productPictures: [{ img: { type: String } }],
    reviews: [
      {
        userId: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
        review: String,
      },
    ],
    category: { type: mongoose.Schema.Types.ObjectId, ref: "Category" },
    createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
    updatedAt: Date,
  },

  { timestamps: true }
);

module.exports = mongoose.model("Product", productSchema);

productRoute.js

const router = require("express").Router();
const { requireSignin, adminMiddleware } = require("../common-middleware");
const { addProduct } = require("../controller/product");
const multer = require("multer");
const shortid = require("shortid");
const path = require("path");
const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, path.join(path.dirname(__dirname), "uploads"));
  },
  filename: function (req, file, cb) {
    cb(null, shortid.generate() + "-" + file.originalname);
  },
});

const upload = multer({ storage });

router.post(
  "/create",
  requireSignin,
  adminMiddleware,
  upload.array("productPicture"),
  addProduct
);
router.get("/getallproducts");

module.exports = router;

productController.js

const Product = require("../models/product");
const slugify = require("slugify");
const shortid = require("shortid");

exports.addProduct = async (req, res) => {
  //   res.status(200).json({ file: req.files, body: req.body });

  const { name, price, description, category, createdBy, quantity } = req.body;
  let productPictures = [];
  if (req.files.lenght > 0) {
    productPictures = req.files.map((file) => {
      return { img: file.filename };
    });
  }

  const product = new Product({
    name: name,
    slug: slugify(name),
    price,
    quantity,
    description,
    productPictures,
    category,
    createdBy: req.user._id,
  });

  await product.save((error, product) => {
    if (error) return res.status(400).json({ error });
    if (product) {
      res.status(201).json({ product });
    }
  });
};

For ref please find the attached images also

enter image description here

Chrome extension close causes file not being upload

I’m devoloping a chrome extension that uses an <input type="file"> inside the popup.html.

The problem is:

  • When is tested inside chrome-extension://ID_EXTENSION/popup.htmlit works as inteded.

    • Note: I don’t know why this method of debuging the extension is not the first thing mentioned in the Getting Started guide.
  • When is tested in normal envoriment (clicking the extension) the file is not upload correctly. Maybe is because, when the file selector dialog is opened, the chrome extensions closes.

Sample code of how this is implimented:

popup.html
<div id="footer" class="popup_footer">
  <label for="upload" class="badge upload"> &#11014; </label>
  <input type="file" id="upload" href="#" title="&#128190;" />
</div>
popup.js
document
  .getElementById("upload")
  .addEventListener("change", function(e) {
            var file = e.target.files[0];
            var reader = new FileReader();
            reader.onload = function(e) {
                var data = JSON.parse(e.target.result);
                chrome.storage.sync.set({data: data})
            };
            reader.readAsText(file)

As a workaround I tested:

  1. Upload it in the chrome-extension url mentioned before.
  2. Using an auxiliary options.html page

There is a way to achieve this without a workaround? Thanks in advance

Why gulp task suddenly stopped execution at watch task?

I’m figuring out how gulp is working, so many gulp task are working fine but suddenly stopped the gulp execution. My gulpfile.js

Environment:

node version v14.17.0

gulp:

CLI version: 2.3.0
Local version: 4.0.2


const babel = require("gulp-babel");

task("js",()=>{
    return src("src/*.js").pipe(babel()).pipe(dest("dist/js"));
})
task("moveHTML",()=>{
    return src("src/*.html").pipe(dest("dist"));
});
task("watch",()=>{
    watch("src/*.js",series("js"));
});
task("default",series('moveHTML','js','watch'));

Well, here doesn’t show any error but execution is hanging. below are the node terminal message:


[10:30:29] Starting 'default'...

[10:30:29] Starting 'moveHTML'...

[10:30:29] Finished 'moveHTML' after 85 ms

[10:30:29] Starting 'js'...

[10:30:32] Finished 'js' after 3.22 s

[10:30:32] Starting 'watch'... 

Load elements in array dynamically in Angular

I have created a custom slider where i’m trying to load element one by one as user clicks on next and previous buttons.

Links:
https://stackblitz.com/edit/angular-ivy-rwuxjd?file=src%2Fapp%2Fapp.component.ts

Initially i’m loading only first value of an array in question array

  ngOnInit(): void {
    var formData=new FormData();
    formData.append("test",'test');
    this.http.post(this.baseUrl+'api/auth/fetch', formData).subscribe(result  => {
    this.questions_lists = result;
    this.temp_questions_lists.push(this.questions_lists[0]);

questions_lists contains all the result from database but temp_questions_lists contains only first element of an array, Now on next and previous buttons i’m trying to clear array and load next value from question_lists array into temp_questions_lists array.

onNext() {
    if (this.counter != this.questions_lists.length - 1) {
      this.counter++;
      this.temp_questions_lists=[];
      this.temp_questions_lists=this.questions_lists[this.counter];
    }
  }



 onPrevious() {
    if (this.counter > 0) {
      this.counter--;
      this.temp_questions_lists=[];
      this.temp_questions_lists.push(this.questions_lists[this.counter]);
    }
  }

First time data is loaded in the slider but next time when i click on next button then i get this error :

Error: Error trying to diff ‘[object Object]’. Only arrays and
iterables are allowed

Any solution is highly appreciated Thanks.

How can I conditionally render a container that’s been outputted by PHP with Vue.js?

I’ve encountered a problem in which I get data from a database with PHP I then store the data into a PHP array like so :

$query = mysqli_query($db, "SELECT id, name, description, experience, focus, fileformat, file, edit FROM trainers;");
$i = 0;
while($query_run = mysqli_fetch_assoc($query)){
    $id = $query_run['id'];
    $name = $query_run['name'];
    $description = $query_run['description'];
    $experience = $query_run['experience'];
    $focus = $query_run['focus'];
    $format = $query_run['fileformat'];
    $file = $query_run['file'];
    $edit = $query_run['edit'];
    $edit = explode(' ', $edit);
    $trainers_meta[$i] = array('Id' => $id, 'Name' => $name, 'Description' => $description, 'Experience' => $experience, 'Focus' => $focus, 'Fileformat' => $format, 'File' => $file, 'Edit' => $edit);
    $i++;
}

Afterwards I display the data from the array in the HTML code using a PHP foreach loop like so :

<div class="container-lg px-lg-4 px-0 pt-3 border-right border-left border-bottom border-radius-bottom mb-5">
    <?php foreach ($services_meta as $service):?>
        <div class="container-lg bg-dark-white py-3 px-3 my-3 border-radius">
            <form action="admin.php" method="post" enctype="multipart/form-data">
                <div class="row no-gutters">
                    <div class="col-lg-5 col-12 d-flex align-items-center">
                        <i class="fas fa-code-branch mr-3 ml-2 text-brand-primary" style="font-size: 1.9em"></i>
                        <h5 class="font-bolder text-truncate"><?php echo $service['Name']?></h5>
                    </div>
                    <div class="col-lg-5 col-8 d-flex align-items-center pt-lg-0 pt-md-3 pt-sm-2 pt-1">
                        <h6 class="font-normal text-brand-primary pr-1">Úprava :</h6>
                        <h6 class="text-truncate"><?php echo $service['Edit'][0]?> <?php echo $service['Edit'][1]?></h6>
                    </div>
                    <div class="col-lg-2 col-4 d-flex align-items-center justify-content-end">
                        <button class="btn btn-brand-secondary font-bold px-22 py-2 mx-1" type="submit" name="services-submit-<?php echo $service['Id']?>"><i class="fas fa-edit"></i></button>
                        <button class="btn btn-brand-primary font-bold px-3 py-2 mx-1" type="submit" name="services-delete-<?php echo $service['Id']?>"><i class="fas fa-trash-alt"></i></button>
                    </div>
                    <div class="col-12"><hr></div>
                    <div class="col-lg-4 col-md-6 col-12 justify-content-md-start justify-content-center pb-md-2 d-flex align-items-center pb-lg-3">
                        <div class="d-flex flex-column pt-3">
                            <h6 class="font-normal text-brand-primary pb-1">Popis :</h6>
                            <textarea type="text" name="services-description-<?php echo $service['Id']?>" class="border-radius" cols="18" rows="4"><?php echo $service['Description']?></textarea>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-6 col-12 justify-content-md-start justify-content-center pb-md-2 d-flex pb-lg-3">
                        <div class="d-flex flex-column pt-3">
                            <h6 class="font-normal text-brand-primary pb-1">Místo :</h6>
                            <input type="text" name="services-place-<?php echo $service['Id']?>" class="border-radius" value="<?php echo $service['Place']?>">
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-6 col-12 justify-content-md-start justify-content-center pb-md-2 d-flex pb-lg-3">
                        <div class="d-flex flex-column pt-3">
                            <h6 class="font-normal text-brand-primary pb-1">Termíny :</h6>
                            <input type="text" name="services-terms-<?php echo $service['Id']?>" class="border-radius" value="<?php echo implode($service['Terms'])?>">
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-6 col-12 justify-content-md-start justify-content-center pb-md-2 d-flex align-items-center pb-lg-3">
                        <div class="d-flex flex-column py-3">
                            <h6 class="font-normal text-brand-primary pb-1">Název :</h6>
                            <input type="text" name="services-name-<?php echo $service['Id']?>" class="border-radius" value="<?php echo $service['Name']?>">
                        </div>
                    </div>
                </div>
            </form>
        </div>
    <?php endforeach;?>
</div>

As you may’ve noticed I use the Id of the data row from the MySQLi database which it originates from to provide a unique name attribute which I can then use to filter through the $_POST of each of the containers so that I can provide functions like deleting from the database on a press of the button which is contained within each container. Here’s an example of the delete function for a specific container :

if($_SERVER['REQUEST_METHOD'] == 'POST'){
    $id = $trainer['Id'];
    foreach ($trainers_meta as $trainer){
        if(isset($_POST["trainers-delete-$id"])){
            $stmt = $db -> prepare("DELETE FROM trainers WHERE id = ?;");
            $stmt -> bind_param("i", $id);
            $stmt -> execute();
        }
    }
}

I simply loop through each of the IDs from the database with $_POST and check which one has been set. This is important because the user also has the ability to add a new container and fill it with new data after they do so I have to check dynamically for the results from the database since they change overtime and I cannot simply hardcore a specific name attribute for use with $_POST.

My actual problem is that I am looking for a way to implement AJAX like functionality to the webpage so that immediatelly upon clicking delete for instance that specific containers disappears without the requirement for the user to refresh the page. I am trying to use Vue.js as my JavaScript library for the entire project.

Vue.js provides an option for conditional rendering with the v-if attribute that’s provided in the page’s HTML but my problem is that I seem to have no way of determining the variable that sets the visibility of the element to false because if I would simply add a v-if and then set the trainersVisibility variable in Vue.js JavaScript to false like :

let app = Vue.createApp({
    data: function(){
        return{
            vue_init: 'Vue initialization success',
            trainersVisibility: true //This would be set to false on the button click
        }
    }
})
app.mount('#app')

all the containers disappear instead of a specific one. I got an idea of simply echoing the Id from the results array with v-if="trainersVisibility-<?php echo $trainer['Id']?>" directly into the v-if attribute but that should throw an error because the base variable was never defined in the Vue.js JavaScript file at all and it’s only occured in the PHP file within it’s HTML code. I cannot simply define multiple v-if boolean variables for each container because I have no way of knowing how much containers with adequate data exist on the page since the number of them changes overtime. What can I do to use conditional rendering for each container sepparately for it to allow me to properly setup AJAX like functionality? I am very new to Vue.js so I’m very sorry if this is obvious to You but it’s a little messy for me still. Huge thanks for any help with this issue from anybody!

Invalid hook call when using useCallback to a function with hooks [duplicate]

I am trying to call a function that contains hooks from a button’s event handler. I thought that using useCallback would work well for this, but I seem to be getting an error with this.

Below is a rough version of what I am attempting and have verified this to also cause my issue:

component.jsx

import React, { useCallback } from 'react';
import { testCall } from "./hooks"


const content = () => {
  const callOtherFunc = useCallback(async () => {testCall("test")},[],)

  return (
    <div>
      <button onClick={callOtherFunc()}>Click me</button>
    </div>
  )

}


hooks.jsx

import React from 'react';


export function testCall(props){
    const [value, setValue] = React.useState("");
    setValue(props)

    console.log(value)
}

Error:

Unhandled Rejection (Error): Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app

Leaflet map tilelayer does not load in correctly

I’m trying to add a leaflet map to a website I am making for an assignment, but the tilelayer loads in in different pieces, cutting certain pieces off.
snippet of the confused map

I’ve tried to change some of the variables to make it fit better, and the closest I’ve come is by putting the tilesize on 800. But when I change the tilesize, the coordinates no longer match up to the map.

Javascript of the map (copied from the tutorial with minor changes)


L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
    attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
    maxZoom: 18,
    id: 'mapbox/streets-v11',
    tileSize: 512,
    zoomOffset: -1,
    accessToken: 'pk.eyJ1IjoibGVjdG9yd291dGVyIiwiYSI6ImNrM25qZWs1dTB4NHgza240bW0zOG1qZngifQ.1uF5JjJA8l5SpTW3NVQJJQ'
}).addTo(map); 

html:

    <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
    integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
    crossorigin=""/>
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js"
    integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
    crossorigin="" defer ></script>
    <script src="js/cafmmap.js" defer></script>
<!-- unrelated html stuff -->
        <section class="detailItem">
            <div id="map"></div>
        </section>

My css just has a “height: 100%;” applied to the map

How to cancel a payment that awaits confirmation in Metamask using web3?

I’m working on a crypto payment system using ethers Web3Provider

web3.eth.sendTransaction(transactionObject)

After the user calls this method, this dialog is shown:
enter image description here

In the app the user is able to close the payment dialog leaving this pending. Is there a way to reject this payment using JS when closing the dialog inside the app? Clearing all payments would also be a solution but in the documentation I can’t find anything about this case.

Supplied options is not an object. (ban command discord.js)

const member = message.mentions.members.first()
if (!member) return message.reply('Please specify a member for me to ban them')

const reason = args.slice(1).join(" ");
if (!reason) reason = 'No Reason';

if (!member.bannable) return message.reply('This member is not bannable')

member.ban(reason).then(() => {
  message.channel.send(member + " banned by " + message.author.id)
}).catch(err => console.log(err))

I’m trying to build a Ban Command in discord.js v13, however, when I run this code, I always get this error: Supplied options is not an object.

Unfortunately, the error doesn’t tell me anything else, like which line or something.

How do I use fetched API data in another component as described below?

I am fetching company logos using react redux in a one component from [clearbit][1], and slicing to display 4 logos like this Results.slice(0, 4).map((item) => ( <Logo /> in a different component.

Now I want to create focus on the first logo to the right and navigate using left/right keys. This is what I have done. I am not getting any errors but am also not getting what I want

import styles from "./styles.module.scss";
import React, { useEffect, useReducer } from "react";
import { useSelector } from "react-redux";
import Logo from "./components/Logo/Logo";
import useKeyPress from "./usePressKey";

const initialState = { selectedIndex: 0 };
const bingResults = []

function NavigationReducer(state, action) {
  switch (action.type) {
    case "arrowLeft":
      return {
        selectedIndex:
          state.selectedIndex !== 0 ? state.selectedIndex - 1 : bingResults.length - 1
      };
    case "arrowRight":
      return {
        selectedIndex:
          state.selectedIndex !== bingResults.length - 1 ? state.selectedIndex + 1 : 0
      };
    case "select":
      return { selectedIndex: action.payload };
    default:
      throw new Error();
  }
}
const DislayLogos = () => {
  const { bingResults } = useSelector((state) => state.search);
  const [state, dispatch] = useReducer(NavigationReducer, initialState);
  const arrowLeftPressed = useKeyPress("ArrowLeft");
  const arrowRightPressed = useKeyPress("ArrowRight");

  useEffect(() => {
    if (arrowLeftPressed) {
      dispatch({ type: "arrowLeft" });
    }
  }, [arrowLeftPressed]);

  useEffect(() => {
    if (arrowRightPressed) {
      dispatch({ type: "arrowRight" });
    }
  }, [arrowRightPressed]);

  return (
    <main>
      <div className={styles.mainHeader}>
        <header className={styles.logoHeader}>
          {bingResults.slice(0, 4).map((item) => (
            <Logo
            key={item.id}
            name={item.name || item.title}
            imgSrc={item.logo}
            onClick={() => {
              dispatch({ type: "select", payload: 1 });
            }}
            style={{
              cursor: "pointer",
              color: 1 === state.selectedIndex ? "grey" : "black"
            }}
            role="button"
            aria-pressed={1 === state.selectedIndex}
            tabIndex={0}
            onKeyPress={(e) => {
              if (e.key === "Enter") {
                dispatch({ type: "select", payload: 1 });
                e.target.blur();
              }
            }}
            />
          ))}
        </header>
      </div>
    </main>
  );
};

export default DisplayLogos;

Does anyone has a way around this?
[1]: https://clearbit.com/docs#autocomplete-api

How to drag and drop in between divs in reactjs?

I tried implementing drag and drop functionality in reactjs using vanilla HTML/js APIs. I almost completed it, but I cannot drop it between the existing divs. I want to add the functionality of dragging and dropping in both the divs (i.e., I should be able to drag any of the divs in the first column and drop anywhere in the second column and vice versa). So far, I am able to drag and drop only at the last index, not in between

Here is what I have tried so far. Please include the code. I am not that strong to follow if you are suggesting something

 <div id="app"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel">
      const App = () => {
        const drop = (e) => {
          e.preventDefault();
          const div_id = e.dataTransfer.getData("div_id");
          const block = document.getElementById(div_id);
          e.target.appendChild(block);
        };
        const dragOver1 = (e) => {
          e.preventDefault();
        };

        const dragStart = (e) => {
          const target = e.target;
          e.dataTransfer.setData("div_id", target.id);
        };

        const dragOver = (e) => {
          e.stopPropagation();
        };

        return (
          <div
            style={{
              display: "flex",
              justifyContent: "space-between",
              padding: "50px",
            }}
          >
            <div
              onDrop={drop}
              onDragOver={dragOver1}
              id="board-1"
              style={{
                border: "1px solid #222",
                padding: 20,
              }}
            >
              <div
                id="firstfirst"
                draggable
                onDragStart={dragStart}
                onDragOver={dragOver}
              >
                <div>
                  <h1>First Column First Row</h1>
                </div>
              </div>
              <div
                id="firstsecond"
                draggable
                onDragStart={dragStart}
                onDragOver={dragOver}
              >
                <div>
                  <h1>First Column Second Row</h1>
                </div>
              </div>
              {Array.from(Array(2)).map((_, index) => {
                return (
                  <div
                    key={index}
                    id={`first${index}`}
                    draggable
                    onDragStart={dragStart}
                    onDragOver={dragOver}
                  >
                    <h1>First Column Row {index}</h1>
                  </div>
                );
              })}
            </div>
            <div
              id="board-2"
              onDrop={drop}
              onDragOver={dragOver1}
              style={{
                border: "1px solid #222",
                padding: 20,
              }}
            >
              <div
                id="secondfirst"
                draggable
                onDragStart={dragStart}
                onDragOver={dragOver}
              >
                <h1>Second Column First Row</h1>
              </div>
              <div
                id="secondsecond"
                draggable
                onDragStart={dragStart}
                onDragOver={dragOver}
              >
                <h1>Second Column Second Row</h1>
              </div>

              {Array.from(Array(2)).map((c, index) => {
                return (
                  <div
                    key={index}
                    id={`second${index}`}
                    draggable
                    onDragStart={dragStart}
                    onDragOver={dragOver}
                  >
                    <h1> Second Column Row {index} </h1>
                  </div>
                );
              })}
            </div>
          </div>
        );
      };
      ReactDOM.render(<App />, document.getElementById("app"));
    </script>

No routes matched location “/rewards-store”

I have a problem with the router V6. The routes are not being rendered. The homepage use to have all the products and now I cannot see any of the products shown, also I have my code to the links that go to every part of the website but is not appearing. The error that appears is:

react_devtools_backend.js:4045 No routes matched location "/rewards-store-andrea-lopez-bravo"  
    at Routes (http://localhost:3000/rewards-store-andrea-lopez-bravo/static/js/vendors~main.chunk.js:32538:5)
    at Router
    at div
    at App (http://localhost:3000/rewards-store-andrea-lopez-bravo/static/js/main.chunk.js:423:63)
    at Router (http://localhost:3000/rewards-store-andrea-lopez-bravo/static/js/vendors~main.chunk.js:32471:15)
    at BrowserRouter (http://localhost:3000/rewards-store-andrea-lopez-bravo/static/js/vendors~main.chunk.js:31958:5)
    at AppProvider (http://localhost:3000/rewards-store-andrea-lopez-bravo/static/js/main.chunk.js:4188:5)
index.tsx:25 No routes matched location "/rewards-store" 

This my router:

import { Routes, Route } from "react-router-dom";
import { Home } from "../pages/Home";
import { History } from "../pages/History";
import { Points } from "../pages/Points";
import { NotFound } from "../components/notification/NotFound";

 
 export const Router  = () => {
  return (
    <Routes>
      <Route path="/" element={<Home />} />
      <Route path="/history" element={<History/>}/>
      <Route path="points" element={<Points/>}/>
      <Route path="NotFound" element={<NotFound/>} />
    </Routes>
  );
};

This is index:

import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import AppProvider from "./context/AppContext";
import { BrowserRouter } from "react-router-dom";

ReactDOM.render(
  <React.StrictMode>
    <AppProvider>
      <BrowserRouter>
        <App />
      </BrowserRouter>
    </AppProvider>
  </React.StrictMode>,
  document.getElementById("root")
);

AppContext:

import React,{ useState } from "react";
 import { usePagination } from "../components/utils/pagination.jsx";


export const AppContext = React.createContext();


export default function AppProvider({ children }) {
    const [user,setUser] = useState({})
    const [points, setPoints] = useState(0)
    const [products, setProducts] = useState([])
    const [reedemStatus, setReedemStatus] = useState({})
    const [history, setHistory] = useState([])

    const paginationList = usePagination(products, 16)
    const paginationHistoryList = usePagination(history, 16)

    const totalProducts = products.length
    const totalHistory = history.length

    const handlerAddPoint =(value)=>{
        const newUser = {...user}
        newUser.points = user.points + value
        setUser(newUser)
      }
    
      const handlerSubtractPoint =(points)=>{
        const newUser = {...user}
        newUser.points = user.points - points
        setUser(newUser)
      }
    return(
        <AppContext.Provider value={{user,
            setUser,  
            handlerAddPoint, 
            handlerSubtractPoint, 
            points,
            setPoints,  
            products, 
            setProducts, 
            totalProducts,
            paginationList,
            reedemStatus, 
            setReedemStatus,
            history,
             setHistory, 
             paginationHistoryList,
             totalHistory}}>
             {children}
        </AppContext.Provider>
    );
}

App.js

import React, { useEffect, useContext } from "react";
import "./App.css";
import { Header } from "./components/header/Header";
import { Nav } from "./components/nav/Nav.jsx";
import { getUser } from "./services/users";
import { AppContext } from "./context/AppContext";
import { Notification } from "./components/notification/Notification";
import { Router } from "./routers/Router";

function App() {
  const { setUser } = useContext(AppContext);
  useEffect(() => {
    getUser().then((user) => {
      setUser(user);
    });
  }, [setUser]);
  return (
    <div className="App">
      <Notification />
      <Nav />
      <Header />
      <Router />
    </div>
  );
}

export default App;