Google Apps Script, print and don’t render my css file?

I’ve un other problem, with my google apps scpript, now html, css, and js files are ok. But when I call a function

function func(){
  var message="";
  try {
   
    );
  }
  catch (error) {
     message="Errors "+ 
      "rnMessage: " + error.message
      + "rnFile: " + error.fileName
      + "rnLine: " + error.lineNumber;
  }
  finally {
    if(message=="") {
      message="Completed Successfully";
    }
    Logger.log(message);
  }
}

with

function onFailure(error){
    console.log("onFailure: " + error);
}

function onSuccess(resp) {
    console.log("onSuccess: "+ resp);
}

google.script.run.withFailureHandler(onFailure).withSuccessHandler(onSuccess).hotelWorkSync();

the console show this logs, and not my

Net state changed from IDLE to BUSY
Net state changed from BUSY to IDLE
null

I just try to follow much video but I can’t see the error.
I don’t understand where I’m wrong, please help me :’(.

JS and Webserver interaction

I want to check with an JS file if a folder with files was created/uploaded in by webserver.
After that I want to search for the .html file in the folder and then set an link to that file in my html file where the JS file is located.
Is this possible with JS, when yes how?

Get variable out from function which is calling export.modules node.js

In the file users.js I want to get code out of randomCode() to assign to the result and use it in whole endpoint '/login'.

randomCode.js

const crypto = require('crypto')

const randomCode = (callback) =>{
    crypto.randomInt(100000, 999999, (err, n) => {
        if (err) throw err;
        callback(n);
    });
}
    
module.exports = randomCode

users.js

require('dotenv').config()
const express = require('express')
const router = express.Router()
const randomCode = require('../controllers/randomCode')


router.get('/login', async (req, res, next)=>{
    try{
//-----------------------------------------------------
        randomCode((code) => {
          console.log(code,'code')
        })
//-----------------------------------------------------
        return res.send('ok')
    }
    catch(error){
        res.send(error)
    }
})

module.exports = router;

I tried to use await but whithout results.

router.get('/login', async (req, res, next)=>{
    try{
//------------------------------------------------------
        const result = await randomCode((code) => {
          console.log(code,'code')
        })
        console.log(result)
//------------------------------------------------------
        return res.send('ok')
    }
    catch(error){
        res.send(error)
    }
})

Putting two divs tags next to each other

so I am trying to put these two s of class= “Col” next to each other with the image in the full left side of the screen.
this is the component code:

import batta from '../../Images/batta.png';
import onlineAuction from '../../Images/onlineAuction.png';
import './LandingScreen.css';
import {useState} from 'react';
import {Link} from 'react-router-dom';
import {Container,Row, Col} from 'react-bootstrap';
const LandingScreen = ()=>{

    const [email, setEmail] = useState("");
    const [password, setPassword] = useState("");

  
    return(
       <Container>
           <Row>
               <Col>
                    <img src ={batta}/>
               </Col>
               <Col>
                    <form style={{marginLeft:300}}>
                        <div className="modal-dialog" role="document" style={{"display":"flex"}}>
                            <div className="modal-content">
                                <div className="modal-header">
                                    <h5 className="modal-title">Sign In</h5>
                                </div>
                                <div className="modal-body">
                                    <form>
                                        <fieldset  style={{maxWidth:500 , marginLeft:20}}> 
                                            <div className="form-group" style={{marginTop :25}}>
                                                <label for="exampleInputEmail1" className="form-label">Email address</label>
                                                <input type="email" className="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email"
                                                value={email} onChange={(e)=> setEmail(e.target.value)}/>
                                            </div>
                                            <div className="form-group" style={{marginTop :1}}>
                                                <label for="exampleInputPassword1" className="form-label mt-4">Password</label>
                                                <input type="password" className="form-control" id="exampleInputPassword1" placeholder="Password"
                                                value={password} onChange={(e)=> setPassword(e.target.value)}/>
                                            </div>
                                        </fieldset>
                                    </form>
                                </div>
                                <div className="modal-footer">
                                    <Link to ="/register" style={{marginRight:175}}>
                                        Don't have an account
                                    </Link>
                                    <button type="submit" className="btn btn-secondary" data-bs-dismiss="modal" >
                                        Log In
                                    </button>

                                </div>
                            </div>
                        </div>  
                    </form>
                </Col>
            </Row>
        
        </Container>
    );
};


export default LandingScreen;

and this is how it looks on the browser:Component rendered in the browser

i thought of using this css code but it didn’t work.

#leftHalf{
    position: absolute;
    left: 0px;
    height: 100%;
    width: 63%

}

.image-container{
    width: 100px;
    display: flex;
    margin-top: 50px;
}

.rightHalf{
    width: 50%;
    position: absolute;
    right: 0px;
    height: 100%;
    
}

please i would be so grateful if you give me a hand in this problem since i still don’t master css very well.

Creating an Isoceles Triangle in Javascript with Methods and For Loops

I am working on a Javascript question from a book to build an Isoceles Triangle from methods and a for loop. The question requires that you build two methods first and then use those to create the triangle. I have the below, but it seems to be ignoring these lines:

spaces = spaces – 1;
stars = stars + 2;
because when I run it, I only get 5 lines of 3 spaces and then one asterisk.

Any help is appreciated. Thank you.

import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int size;
    System.out.print("What size is the triangle? ");
    size = input.nextInt();
    drawIsoTriangle(size);
   }
   public static void displaydrawBar(int length) {
    for (int i = 0; i < length; i++) {
    System.out.print("*");
    }
   }
   public static void displaydrawBar(int length, String mark) {
    for (int i = 0; i < length; i++) {
    System.out.print(mark);
    }
   }
   public static void drawIsoTriangle(int size) {
    for (int i = 0; i < size; i++) {
      int spaces = size - 1;
      int stars = 1;
      displaydrawBar(spaces, " ");
      displaydrawBar(stars);
      System.out.println();
      spaces = spaces - 1;
      stars = stars + 2;
    } 
   } 
}

javascript single-threaded , how asynchronous is implemented

It is acknowledged that JavaScript is single-threaded ,but while i try the code below, when i use setTimeout and Promise, it’s obviously that they runs asynchronously

function testTimer(){
  setTimeout(()=>{console.log(2)},100)
}
function testLoop(){
    for(let i = 0; i < 1e3; i++){}
    console.log(3)
}
function testPromise(){
     return new Promise((resolve)=>{
        for(let i = 0; i < 1e3; i++){}
        resolve();
    })
}
console.log(1)
testTimer();
testLoop();
console.log(4)
testPromise().then(()=>{console.log(5)})
console.log(6)

If javascript is completely single-threaded, the console should print 1, 2, 3, 4, 5, 6 in order. But the single threaded feature can only be seen in testLoop(), we can see that the use of Promise and setTimeout allow the code below run ahead, could someone please tell how’s this achieved?

How reset form values using react bootstrap

My goal after clicking the register button is:

  • Make input fields blank
  • Do not show error tooltips

I’ve already tried using event.target.reset(); however the tooltips are still appearing on the screen.

export default function App() {
  const [showSucessAlert, setshowSucessAlert] = useState(false);
  const [validated, setValidated] = useState(false);
  const [transitionAlert, setTransitionAlert] = useState(false);

  const handleSubmit = (event) => {
    const form = event.currentTarget;
    event.preventDefault();

    if (form.checkValidity() === false) {
      event.stopPropagation();
    } else {
      handleClickTransitionAlert();
      setshowSucessAlert(true);
    }
    setValidated(true);
  };

  const handleClickTransitionAlert = () => {
    setTransitionAlert(true);
    setTimeout(() => {
      setTransitionAlert(false);
    }, 1700);
  };

  return (
    <Form noValidate validated={validated} onSubmit={handleSubmit}>
      <Form.Group className="position-relative" controlId="validationPassword">
        <Form.Label>Password</Form.Label>
        <InputGroup hasValidation id="validationPassword" />
        <Form.Control
          type="password"
          aria-describedby="validationPassword"
          required
        />
        <Form.Control.Feedback tooltip type="invalid">
          Please enter your Password.
        </Form.Control.Feedback>
      </Form.Group>
      <Alert
        className={`mt-1 p-1 position-fixed ${
          transitionAlert ? "alert-shown" : "alert-hidden"
        }`}
        show={showSucessAlert}
        variant="success"
      >
        Registered user!
      </Alert>
      <Button className="mt-5" variant="primary" type="submit">
        Register
      </Button>
    </Form>
  );
}

enter image description here

Here is the link on CodeSandbox

Every help is welcome!

How do I get UI to update in loop using forEach

  Promise.all([
    seperatingDMCM(),
    compileDirectMessage(),
    renderingResult(),
    addResultButtonListener(),
  ]);

I have a progress bar in my UI and I have 4 functions mentioned above each of which returns a Promise. I have a loop inside the first function seperatingDMCM(), that will handle all the my data. I want to increment the progress bar with each increment of the loop. Meaning each loop iteration should be async, so the UI will update and only afterwards the loop will iterate. When the loop has ended I want to return a promise so that the other functions will begin to execute. I am facing an issue that progress bar is not working as it suppose to and is immediately being invoked when seperatingDMCM() returns the promise () and not asynchronously. This progress bar is immediately being updated to 100% on the next page instead of live updates with small increment on the current page.

This is my updateUI function:

function startProgressBar(i, arr) {
  return new Promise((resolve) => {
    setTimeout(() => {
      i = (i * 100) / arr.length;
      console.log(i);
      let elem = document.getElementById("progressBar");
      if (i < 100) {
        elem.innerText = i + "%";
        elem.style.width = i + "%";
        elem.innerHTML = i + "%";
        resolve();
      }
    }, 0);
  });
}

This is my first function where I want to update the UI per loop iteration

function seperatingDMCM() {
  const contentType = "Content type";

  return new Promise((resolve) => {
    rowObject.forEach(async (row, index) => {
      const creatingInts = () => {
        console.log("CreatedInt at", index);
        row["Date created (UTC)"] = ExcelDateToJSDate(
          row["Date created (UTC)"]
        );
        if (
          row[contentType] !== "DM" &&
          row.hasOwnProperty("Falcon user name")
        ) {
          publicCommentsCount++;
          interaction = { row : row};
          compiledInteractions.push(interaction);
          interaction = {};
        } else {
          dmData.push(row);
        }
      };

      startProgressBar(index, rowObject).then(creatingInts());
    });
    quickSort(dmData, "Falcon URL");
    console.log("SORTED", dmData);

    console.log(workbook);
    console.log("Rows", rowObject);
    resolve();
  });
}

Is there a succinct guide to the history and use of all the JavaScript package types?

I keep getting lost in the woods with all the different package types. e.g. CJS, UMD, AMD, ESM (and more?) and their compatibility matrix with varying runtime environments, when they can be used, why they were developed, etc etc. Like, I know Node.js requires CJS, UMD is used mostly in the browser and is a superset of AMD and RequireJS(?), and ESM is the future. I’m interested in diving into the nuance.

Is there a handy cheat sheet to all of the above?

The real problem which sparked that question is making a JS package which works in Node and the browser. I’m really close, but I wish I had a better understanding.

Why is my code to hide a parent div not working?

I tried following the information here, editing it to match my needs, but so far it’s not working.
I’m trying to hide a parent div with two child elements. The parent div is part of a list, all with the same classes, and each div has two child elements: an input, and an image. Each input has a unique “data-wapf-label” that I’m trying to select so that I can hide the parent div. The HTML is as follows:

<div class="has-pricing wapf-swatch wapf-swatch--image">
  <input type="radio" id="wapf-field-61b148f2fc8fe_lzhx7" name="wapf[field_61b148f2fc8fe]" class="wapf-input" data-field-id="61b148f2fc8fe" value="lzhx7" data-wapf-label="Peppermint Mocha" data-is-required data-wapf-pricetype-"fx">
  <img src="...">
</div>

There are several pages where this product shows up, and rather than going in and deleting the product field (because I’ll just have to add it again next season), I’m trying to create a piece of code that will hide all the divs for all the products that have the above code (since each has a unique “id”, I’d have to do it several times for each id using “selectElementById”, and I’d like to avoid doing that, obviously).

I installed Code Snippets, but I’m having a bit of trouble with the Javascript. I’ve tried several things, but this is my latest version. It throws a syntax error “unexpected ‘hideFlavors’ (T_STRING), expecting ‘(‘”.
Here’s my php/Javascript code:

<?php
add_action( 'wp_head', function hideFlavors() { ?>
<script>
    if var peppermintMocha = document.querySelectorAll("[data-wapf-label='Peppermint Mocha']") {
    peppermintMocha.parentNode.style.display = "none"; 
    }
</script>
<?php } );

I’ve also tried it with “document.querySelector” (without the “All”), but with the same or similar problem. When I do get the code to actually go through without any errors, it still doesn’t fix the problem.
At this point, I feel a little like the guy looking through the tank’s periscope on “Independence Day”. No matter what I do, “target remains”.

JSPDF output(‘dataurlnewwindow’) doesn’t work on safari

Greetings I have a project where I generate a DIV to PDF

But it’s not working on iPhone safari browser

the code

let ref_id = $('#print').next().html();
let HTML_Width = $(".report").width();
let HTML_Height = $(".report").height();
let top_left_margin = 1;
let PDF_Width = HTML_Width + (top_left_margin * 2);
let PDF_Height = (PDF_Width * 1.5) + (top_left_margin * 2);
let canvas_image_width = HTML_Width;
let canvas_image_height = HTML_Height;
let totalPDFPages = Math.ceil(HTML_Height / PDF_Height) - 1;
html2canvas($(".report")[0]).then(function (canvas) {
    let imgData = canvas.toDataURL("image/jpeg", 1.0);
    let pdf = new jsPDF('p', 'pt', [PDF_Width, PDF_Height]);
    pdf.addImage(imgData, 'JPG', top_left_margin, top_left_margin, canvas_image_width, canvas_image_height, 'FAST');
    for (let i = 1; i <= totalPDFPages; i++) {
        pdf.addPage(PDF_Width, PDF_Height);
        pdf.addImage(imgData, 'JPG', top_left_margin, -(PDF_Height * i) + (top_left_margin * 4), canvas_image_width, canvas_image_height);
    }
    pdf.output('dataurlnewwindow');
});

Number is not incrementing by 1 in JavaScript

I have this code where if the opacity is less than or equal to 0, the message number is suppose to go up by 1, but when I run the code, the message number increases by 77 or 152 or 66, etc. Could you help me?
My code:

//variables
var x = 0;
var opacity = 0;
var messageNumber = 0;
var talk1 = ["hello", "welcome to idle ball", "potato"];
var lol = 1;


//set opacity to 1
function opacitySet1(speed) {
  document.getElementById("talk").style.opacity = opacity;
  opacity += speed;
}

//set opacity to 0
function opacitySet0(speed) {
  document.getElementById("talk").style.opacity = opacity;
  opacity -= speed;
}


function IntervalManager(flag, animate, time, para1) {
  if (flag) {
    var intervalSet = setTimeout(animate, time, para1)
  }
}


function IntervalManagerII(flag, animate, time, para1) {
  if (flag) {
    var intervalSetII = setTimeout(animate, time, para1)
  }
}

//to delay time
function nothing() {}


function message(startPart) {
  document.getElementById("talk").innerHTML = messageNumber;
  if (opacity >= 0 && lol == 0) {
    setTimeout(nothing, 1);
    IntervalManagerII(true, opacitySet0, 300, 0.005);
    IntervalManager(false)
  }
  if (opacity <= 1 && lol == 1) {
    IntervalManager(true, opacitySet1, 300, 0.005);
    IntervalManagerII(false)
  }
  if (opacity <= 0) {
    lol = 1;
    IntervalManagerII(false);
    messageNumber += 1;
  } //this is the part that is not working
  if (opacity >= 1) {
    lol = 0;
    IntervalManager(false);
  }
};

setInterval(function() {
  message(0)
});

Uncaught TypeError: window.initialize is not a function on older gmaps api

I’ve inherited a site and picking through some of the console errors i see… the “Uncaught TypeError: window.initialize is not a function” is coming from the google maps api, i am not knowledgeable in javascript so im not sure whats going on at all. Here’s the code that calls the map…

    <script> window.mapalldata=<?php echo json_encode($map_data)?>;</script>
<script type="application/javascript">
    iBox = [];

    jQuery(function ($) {
        var image = '<?php echo get_template_directory_uri(); ?>/assets/images/office-pin.png';
        var map = null;
        var markerArray = [];

        window.initialize = function () {
            var bounds = new google.maps.LatLngBounds();
            latitudes = [];
            longitudes = [];
            artBox = window.mapalldata;

            pindata = [];
            points = [];
            jQuery.each(artBox, function (key, val) {
                    if(latitudes.includes(val.lat) && longitudes.includes(val.lng)){
                        val.lat = val.lat + (Math.random() - 0.5) / 1500;// * (Math.random() * (max - min) + min);
                        val.lng = val.lng + (Math.random() - 0.5) / 1500;// * (Math.random() * (max - min) + min);
                    }
                    latitudes.push(val.lat)
                    longitudes.push(val.lng)
                    pindata.push({'title': val.title});
                    points.push(val);
                   

            })
            bounds.extend(new google.maps.LatLng(Math.max.apply(Math, latitudes) + 1, Math.max.apply(Math, longitudes)));
            bounds.extend(new google.maps.LatLng(Math.min.apply(Math, latitudes) - 1, Math.min.apply(Math, longitudes)));
             
            if (map == null) {
                var gmapdiv;
                gmapdiv = document.createElement('div');
                gmapdiv.id = 'level10_gmapid-canvas';
                gmapdiv.style.width = '100%';
                gmapdiv.style.height = '700px';
                document.getElementById('gmap_canvas').appendChild(gmapdiv);
                var mapOptions = {
                    zoom: 10,
                    scrollwheel: false,
                    mapTypeControl: true,
                    scaleControl: true,
                    zoomControlOptions: {style: google.maps.ZoomControlStyle.DEFAULT},
                    overviewMapControl: true,
                    center: bounds.getCenter(),
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };

                var map = new google.maps.Map(document.getElementById('level10_gmapid-canvas'), mapOptions);
            }
            if (markerArray) {
                jQuery.each(markerArray,function(key,value){
                    value.setMap(null);
                })
                markerArray = [];
            }
            var len = latitudes.length;

            jQuery.each(points, function (key, val) {
                var marker = new google.maps.Marker({
                    position: new google.maps.LatLng(parseFloat(val.lat)-0.0014, parseFloat(val.lng)),
                    map: map,
                    icon: image
                });

                markerArray.push(marker);
                window.attachMessege(map, marker, val);


            })
            var clusterStyles = [
              {
                textColor: 'white',
                url: '<?php echo get_stylesheet_directory_uri()?>/assets/images/ico-region-map.png',
                height: 85,
                width: 85
              }
            ];
            var mcOptions = {
            styles: clusterStyles,
            };
            var markerCluster = new MarkerClusterer(map, markerArray, mcOptions);

            if (len > 1) {
                map.fitBounds(bounds);
            } else {
                map.setCenter(markerArray[0].getPosition());
                map.setZoom(15);
            }
            jQuery(document).on("contentUpdate", function (e) {
                jQuery.each(iBox, function () {
                    this.hide();
                });
            });
             var ib;
            var currCenter = bounds.getCenter();
            google.maps.event.addDomListener(window, 'resize', function() {
                map.setCenter(currCenter);
            });
        }

        window.attachMessege = function (map, marker, data) {
           
            myHtml =
                '<div class="b-marker-map" >' +

                '<div class="b-box-marker">' +
                '<div class="holder">' +
                '<div class="block">' +
                '<a href="' + data.link + '" class="image">'+
                data.img +
                '</a>' +
                '<div class="info-content">' +
                '<h5>' + data.client + '</h5>'+
                '<p>' + data.title + '</p>' +
                '<p>' + data.geo + '</p>' +
                '<a href="' + data.link + '" class="link-arrow">View Project</a>' +
                '</div>' +
                '</div>' +
                '</div>' +
                '</div>' +
                '</div>';

            var boxText = document.createElement("div");
            boxText.innerHTML = myHtml;

            var myOptions = {
                content: boxText,
                disableAutoPan: false,
                maxWidth: 0,
                alignBottom: true,
                pixelOffset: new google.maps.Size(-65, -32),
                zIndex: null,
                closeBoxMargin: "0",
                closeBoxURL: "",
                infoBoxClearance: new google.maps.Size(1, 1),
                pane: "floatPane",
                enableEventPropagation: false,
            };

            var ib = new InfoBox(myOptions);
            iBox.push(ib);

            google.maps.event.addListener(map, "click", function (e) {
                var ib_length = iBox.length;
                for (i = 0; i < ib_length; i++) {
                    if (iBox[i].getPosition()) {
                        iBox[i].close();
                    }
                }
            });
            google.maps.event.addListener(marker, "click", function (e) {
                var ib_length = iBox.length, _pp = this.position;
                for (i = 0; i < ib_length; i++) {
                    // var curpoint = iBox[i].getPosition();
                    // if (_pp.k != curpoint.k && _pp.D != curpoint.D) {
                        iBox[i].close();
                    // }
                }
                //map.panTo(this.getPosition());
                ib.open(map, marker);
               

                
            });
            // google.maps.event.addListener(marker, "mouseout", function (e) {
            //      mouseOutsideInfowindow();
            // });



            var styles = [{"featureType":"administrative","elementType":"labels.text","stylers":[{"saturation":"-17"},{"lightness":"21"},{"gamma":"1.16"},{"weight":"2.35"}]},{"featureType":"administrative","elementType":"labels.text.fill","stylers":[{"color":"#444444"}]},{"featureType":"administrative.country","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"administrative.province","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"administrative.locality","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"administrative.neighborhood","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"landscape","elementType":"all","stylers":[{"gamma":"1"},{"lightness":"100"},{"color":"#ffffff"}]},{"featureType":"landscape.natural","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#f2f2f2"},{"visibility":"on"}]}];
            var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"});
            map.mapTypes.set('map_style', styledMap);
            map.setMapTypeId('map_style');
        }

    });

function  mouseOutsideInfowindow(){
    var ib_length = iBox.length, _pp = this.position;
    for (i = 0; i < ib_length; i++) {
        iBox[i].close();
    }
}
jQuery('.buttons a.map').on('click', function (e) {
    if( jQuery('#gmap_canvas').is(':empty') ) {    
        // jQuery('#gmap_canvas').empty();
        window.initialize();
    }
});
</script>

theres also all this code being displayed below the area that i imagine is bc of the javascript error, heres an image of it…
screenshot of code being displayed on front end

Any help would be great the client would like to not completely remove the map, as its used to search for projects, my guess based on other errors i’ve found is that its dated javascript, but like i said i dont know javascript so im not sure… heres the page https://www.level10gc.com/projects/

Thank you.

Search function through an array of objects

I am very new in react and needed a search function which result should return match ‘in category’, ‘in subcategory’, ‘in product’, similar endpoint below.
My code below only return match when user input productname and null if search with categoryname or subcategoryname

My Code

const SearchSection = () => {
  const classes = useStyles();

  const theme = useTheme();

  const [inputData, setInputData] = useState("")

  const handleFilter = e =>{
     const searchWord = e.target.value
     setInputData(searchWord)
     const newFilter = categories.filter((product ) => {
           return product.productname.toLowerCase().includes(searchWord.toLowerCase())
     })

     if(searchWord === "") {
           setFilteredData([])
     }else {
           setFilteredData(newFilter ) 
     }
  }

  console.log(filteredData)
 return (
  <>
     <Navbar />
     <div className={classes.hero}>

        <div className={classes.overlay}></div>

        <div className={classes.heroContentContainer}>

           <div className={classes.heroSection}>
                 <div className={classes.SearchBar} >
                    <SearchField value={inputData} onChange={handleFilter} name="search" />
                 </div>
           </div>

        </div>
        
     </div>

     <Container>
             {filteredData.map(productName =>{
                return(
                   <SearchCard productName={productName}  />
                )
            })} 
     </Container>

  </>);};

endpoints data structures

[
{
    "_id": "61afe234d43c9ad47188bff3",
    "categoryname": "Restaurant",
    "subcategory": [
        {
            "_id": "61b3823901e636b6782375ef",
            "subcategoryname": "Grilled Food",
            "subcategoryimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg",
            "product": [
                {
                    "_id": "61daec0b29f2c8c9337fa593",
                    "productname": "Poultry",
                    "productdescription": "Lorem ipsum dolor sit amet",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                },
                {
                    "_id": "61daec1729f2c8c9337fa59c",
                    "productname": "Fish",
                    "productdescription": "Lorem ipsum dolor sit amet",
                    "productimage": "https://res.cloudinary.com/ajeo/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                },
                {
                    "_id": "61daec2529f2c8c9337fa5a2",
                    "productname": "Vegetarian",
                    "productdescription": "Lorem ipsum dolor sit amet, consectetur ",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                }
            ],
        },
        {
            "_id": "61b3824501e636b6782375f3",
            "subcategoryname": "Traditional delicacies",
            "subcategoryimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg",
            "product": [
                {
                    "_id": "61daee16d94f72b6d15396a8",
                    "productname": "Peppered meat",
                    "productdescription": "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                }
            ],
        },
        {
            "_id": "61b3824e01e636b6782375f7",
            "subcategoryname": "Crustacean",
            "subcategoryimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg",
            "product": [
                {
                    "_id": "61daee55d94f72b6d15396f8",
                    "productname": "Seafood",
                    "productdescription": "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                }
            ],
        },
        {
            "_id": "61b3825601e636b6782375fb",
            "subcategoryname": "Sandwiches",
            "subcategoryimage": "https://res.cloudinary.com/ajeo/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg",
            "product": [
                {
                    "_id": "61b3839d01e636b678237638",
                    "productname": "Pizza",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg",
                    "imageurl": "uploads/placeholder-1639154589069-957455144.jpeg",
                    "productdescription": "undefined"
                },
                {
                    "_id": "61daeee9d94f72b6d1539784",
                    "productname": "Shawarma",
                    "productdescription": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, ",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                },
                {
                    "_id": "61daef43d94f72b6d15397c9",
                    "productname": "Burger",
                    "productdescription": "Lorem ipsum dolor sit amet, consectetur ",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                }
            ],
        },
        {
            "_id": "61daeae829f2c8c9337fa4f0",
            "subcategoryname": "Drinks",
            "imageurl": "",
            "product": [
                {
                    "_id": "61daef69d94f72b6d15397fa",
                    "productname": "Cocktail",
                    "productdescription": "Lorem ipsum dolor sit amet, ",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                },
                {
                    "_id": "61daef72d94f72b6d1539800",
                    "productname": "Alcoholic drinks",
                    "productdescription": "Lorem ipsum dolor sit amet",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                },
                {
                    "_id": "61daef79d94f72b6d1539806",
                    "productname": "Juice",
                    "productdescription": "Lorem ipsum dolor sit amet",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                },
            ],
            "subcategoryimage": "https://res.cloudinary.com/ajeo/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg",
    ],
},
 {
    "_id": "61afe234d43c9ad47188bf",
    "categoryname": "Dining",
    "subcategory": [
        {
            "_id": "61b3823901e636b6782375ef",
            "subcategoryname": "Shawama",
            "subcategoryimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg",
            "product": [
                {
                    "_id": "61daec0b29f2c8c9337fa593",
                    "productname": "Bird",
                    "productdescription": "Lorem ipsum dolor sit amet",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                },
                {
                    "_id": "61daec1729f2c8c9337fa59c",
                    "productname": "Cat",
                    "productdescription": "Lorem ipsum dolor sit amet",
                    "productimage": "https://res.cloudinary.com/ajeo/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                },
                {
                    "_id": "61daec2529f2c8c9337fa5a2",
                    "productname": "Vegans",
                    "productdescription": "Lorem ipsum dolor sit amet, consectetur ",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                }
            ],
        },
        {
            "_id": "61b3824501e636b6782375f3",
            "subcategoryname": "Delicacies",
            "subcategoryimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg",
            "product": [
                {
                    "_id": "61daee16d94f72b6d15396a8",
                    "productname": "Meat",
                    "productdescription": "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                }
            ],
        },
        {
            "_id": "61b3824e01e636b6782375f7",
            "subcategoryname": "Crust",
            "subcategoryimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg",
            "product": [
                {
                    "_id": "61daee55d94f72b6d15396f8",
                    "productname": "food",
                    "productdescription": "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                }
            ],
        },
        {
            "_id": "61b3825601e636b6782375fb",
            "subcategoryname": "Sand",
            "subcategoryimage": "https://res.cloudinary.com/ajeo/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg",
            "product": [
                {
                    "_id": "61b3839d01e636b678237638",
                    "productname": "Pizza",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg",
                    "imageurl": "uploads/placeholder-1639154589069-957455144.jpeg",
                    "productdescription": "undefined"
                },
                {
                    "_id": "61daef43d94f72b6d15397c9",
                    "productname": "Burger",
                    "productdescription": "Lorem ipsum dolor sit amet, consectetur ",
                    "productimage": "https://res.cloudinary.com/image/upload/v1642037819/uploads/placeholder_kmytyw.jpg"
                }
            ],
        },
    ],
},]