Change icon when the text is clicked

I’m new to coding and I’m experimenting with hamburger-style menu.

What I’ve achieved: when the user clicks on the hamburger menu icon, it changes into the close icon.

I’ve added a text label in front of the hamburger menu icon, but the problem is that I don’t know how to make this text change the icon when it’s clicked.

If you can please advise on this matter.

Many thanks

Best regards,
Veaceslav

HTML

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Title</title>

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="Bootstrap/css/bootstrap.min.css">

    <!-- Font Awesome -->

    <link href="Fontawesome/css/all.css" type="text/css" rel="stylesheet">

    <!-- Styles -->
    <link href="CSS/stylesheet.css" rel="stylesheet">

</head>

<body>

<!-- Header -->
    <header id="header" class="header d-flex align-items-center fixed-top">

    <div class="container-fluid container-xl d-flex align-items-center justify-content-between">

        <a href="index.html" class="logo d-flex align-items-center"><h1>Logo</h1></a>
 
        <div class="topnav" id="myTopnav">

            <ul class="nav-links">

            <input type="checkbox" id="checkbox_toggle"/>
            <label for="checkbox_toggle" class="hamburger"><span class="menu_text" onclick="changeIcon(fa-bars)">Menu</span> <i class="fa-solid fa-bars" onclick="changeIcon(this)"></i></label>
    
            <div class="menu">
    
                <li><a href="#">First</a></li>
                <li><a href="#">Second</a></li>
            </div>
        </ul>
        </div>
    </div>

    </header>

<footer></footer>

</body>

<script src="Bootstrap/js/bootstrap.js"></script>
<script src="JS/menu_icon_toggle.js"></script>

</html>

JS

 let changeIcon = function(icon) {
        icon.classList.toggle('fa-xmark')
    }

How to insert a value into a editable element present in a page through JS?

Am developing a chrome extension in which i use context menu on editable elements in a page. I fetch the element on which right click has been performed and now i want to insert a value into that input element.

I tried using the simple :
document.activeElement.value="value"; .

In this case, value will be inserted but it doesn’t exactly replicate the typing action of user.

For example : Save button will be enabled when user types a minimum of single character. But when we use document.activeElement.value to insert, save button wont be enabled. It requires an additional manual click outside the input element or requires pressing some other key manually inside the input area.

I tried using KeyboardEvent to simulate a right arrow key press but still it didn’t work.

Is there any other way to achieve this ?

TypeScript icon missing on packages on npm website

Hi wrote a package and published it on npm repository and showed icon “ts” on the site

enter image description here

This is package.json with “ts” icon “- https://unpkg.com/[email protected]/package.json

I wrote another package but missing “ts” icon

This is package.json mssing “ts” icon – https://unpkg.com/@salsan/[email protected]/package.json

Th

The different from these two packages

d.ts file is generated from tsconfig.json

  "declaration": true,                            
  "declarationMap": true,   

Any idea for resolve this issue ?

Is there a way to personalise collectors to a user? Discord.js

To put it simply, my bot is reading off another bot to see if a drop has been dropped, however, there are some problems occurring.

Current Scenario:
User 1 drops
User 2 drops
The bot my bot is reading off (ID:733122859932712980, hence the filter) sends the first drop
My bot pings the role twice before the second drop has dropped.
The bot my bot is reading off sends the second drop
No ping from my bot

What I want is for the second ping to happen after the second drop happens

Current code:

const Discord = require('discord.js');

module.exports = {
    name: "drop",
    aliases:["d"],
    async execute(client, msg, args) {

const filter = m => m.author.id === "733122859932712980";



const collector = msg.channel.createMessageCollector({
filter
});

collector.on("collect", m => {
  if (m.embeds[0]){
        const embed = m.embeds[0]

        if(embed.author?.name.includes("K-DROP")){

 for (var i=0; i<embed.fields.length ; i++){
            if(embed.fields[i].name) {
              if(embed.fields[i].value.includes("Winner")){
               return;
              }
              else
              {
                m.channel.send("<@&980128851495641101>")
                break;
              } 
        }
    }
}
  collector.stop();
  }
  })}};

How to copy text and send it to a HTML file using sendMessage?

What I want to do:

I am trying to build a chrome-extension. The extension will-

  1. By clicking the icon once, it will keep running.
  2. After that, on any page/tab,
    the user would be able to select some text
    and use a key combination (e.g. Shift+a)
    to send that text to an HTML page, say text.html.
  3. If I click the icon again, the extension will stop working.

Note that text.html is a fixed page, all text will be accumulated on text.html.

My Attempt:

  1. Run a JavaScript on background to collect text, then send it by using sendMessage, something like :

content.js

function getSelectionText() {
    var text = "";
    if (window.getSelection) {
        text = window.getSelection().toString();
    } else if (document.selection && document.selection.type != "Control") {
        text = document.selection.createRange().text;
    }
    return text;
}
function doc_keyUp(e) {
    // this would test for whichever key is 40 (down arrow) and the ctrl key at the same time
    if (e.key === 'a') {
       tx_s=getSelectionText();
       //console.log(tx_s);
       chrome.runtime.sendMessage({greeting:tx_s},function(response) {console.log(response.farewell);}); 

                 
                      }// if (e.key === 'q')
                     } // doc_keyUp(e)
// register the handler 
document.addEventListener('keyup', doc_keyUp, false);

it receives text by the below code:

background.js

chrome.runtime.onMessage.addListener(
                              function(request,sender,sendResponse){
                              
                              console.log(sender.tab?
                              "from a content script"+sender.tab.url :
                              "from the extension");
                              //if (request.greeting==="hello")
                               sendResponse({farewell:request.greeting});   
                               console.log(request.greeting);                             
                               //window.greeting[0] = request.greeting;
                              })
                              
chrome.action.onClicked.addListener(function (tab) {
  chrome.tabs.create({url: 'popup.html'})
})
  1. Then get the textto the HTML file, I got the idea from “How To Make Chrome Extensions”, Kyle Robinson Young (click here), but the code is not working due to manifes version problem, also the code gets error window.bears={}; (does not allow window option).

How can I transfer the text from various page to a accumlate and view on a html?
Thanks.

Clicking cookie button with Selenium 4 error: object[] has no size and location

I’ve been attempting to click a button in a pop-up with selenium, but I’m getting the following error:

object [HTMLDivElement] has no size and location

I have tried the normal way, with just click, since it is in the viewport and I am waiting for the page to fully load:

let pressCookieButton = await driver.findElement(By.xpath('//a[@class="btn-actiune btn-actiune--principal"]/..'))
await pressCookieButton.click();

But this does not work. It says

Element not interactible

Then, i tried to click using actions:

let pressCookieButton = await driver.findElement(By.xpath('//a[@class="btn-actiune btn-actiune--principal"]/..'))
const actions = driver.actions({ async: true });
await actions.click(pressCookieButton).perform();

But i get:

object [HTMLDivElement] has no size and location

The HTML that I am attempting to click is the following:

<div class="col-md-4 col-sm-4 col-xs-12"> 
    <a href="javascript:;" onclick="modCookies.updatePermisiuniCookies('toate');" class="btn-actiune btn-actiune--principal">Accept toate cookie-urile</a>  
</div>

Below is the full code:

const {Builder} = require('selenium-webdriver');
const {By} = require('selenium-webdriver');

(async function helloSelenium() {

    let driver = await new Builder().forBrowser('chrome').build();

    try{

        await driver.get('https://www.imobiliare.ro/vanzare-apartamente/timisoara/matei-basarab/apartament-de-vanzare-3-camere-XCB61020C');
    
        await driver.sleep(7000);
        console.log("clicking")
    
        
        let pressCookieButton = await driver.findElement(By.xpath('//a[@class="btn-actiune btn-actiune--principal"]/..'))

        
        const actions = driver.actions({ async: true });
        await actions.click(pressCookieButton).perform();
    
        //findElement(By.className('btn-actiune btn-actiune--principal'));
        await driver.sleep(10000);
    
        await pressCookieButton.click();
    
    }catch(error){
        console.log(error)

        await driver.sleep(5000);

        // await driver.quit()
    }
    
})();

SQL query in Apps Script (to combine multiple google sheets into one)

I am using this apps script to combine multiple gsheets into 1.

  function Import_Data_From_Multi_Sources(){
  
// Input  
var spreadsheetId='19hT5qOy-1y-29DutFIGA1mIKC1ZWm4rLe19mvHpHN1Y' // current sheet id
var destination_range= "tiering_B22_master!A2:W"
var sources = [
    {source_fileID: '1xAsqdozO-2GqP8JEX2nwfZbWslSmL8NMhzbiGaZ19PM', source_sheetName: "Contact Leads",source_range:"A2:AN", source_select_columns: [1,4,6,11,12,18,19,21,22,24,26,27,28,29,30,31,32,33]},
    {source_fileID: '1txFgswaIINK60-K5lyC6W6_JnFAV8gJBj1HT80fc-fg', source_sheetName: "Contact Leads",source_range:"A2:AN", source_select_columns: [1,4,6,11,12,18,19,21,22,24,26,27,28,29,30,31,32,33]},
    {source_fileID: '1xAsqdozO-2GqP8JEX2nwfZbWslSmL8NMhzbiGaZ19PM', source_sheetName: "LZD template new",source_range:"A2:AN", source_select_columns: [1,4,6,11,12,18,19,21,22,24,26,27,28,29,30,31,32,33]}
    ]


var combine_data=[]
for (x in sources){
  try{
  var s_file = SpreadsheetApp.openById(sources[x].source_fileID)
  var s_sheet = s_file.getSheetByName(sources[x].source_sheetName)
  var s_selRange = s_sheet.getRange(sources[x].source_range);
  var s_selCol = sources[x].source_select_columns;
  var s_selValue = s_selRange.getDisplayValues();
  //filter skip blank rows
  s_selValue = s_selValue.filter(function (xRow) {return xRow.join('').length >0});

  var s_values= [];
    for (let i = 0, length = s_selValue.length; i < length; i++) {
      s_values[i] = [];
      for (let j = 0, width  = s_selCol.length; j < width; j++) {
        // assign source value to a variable
            let col_value = s_selValue[i][s_selCol[j]-1];
            let actual_col = s_selCol[j];

// format phone value before copying
            let phone_cols = [6, 11];
            if ( phone_cols.includes(actual_col) ) {
col_value = col_value.trim();
           }
            s_values[i][j] = col_value;
      };
    };
}catch (error) {
    var mess ='nURL: ' + SpreadsheetApp.getActiveSpreadsheet().getUrl() +  'nSheet '+sources[x].source_sheetName + ' Range ' + sources[x].source_range + ' ' + error
    console.log(mess)
    var subject = 'Errors' + SpreadsheetApp.getActiveSpreadsheet().getName();//Change to subject
    var emailUser = '[email protected]';//Change to email you want to send to
    MailApp.sendEmail(emailUser,subject,mess)
    continue}
  combine_data=combine_data.concat(s_values);
  //console.log(combine_data)

}

  
  var data = 
  {
    'range':destination_range,
    'majorDimension': 'ROWS',
    'values':combine_data
  }
  var clearRange=
  {
    "ranges":destination_range
  }


var update = {
    valueInputOption: "USER_ENTERED",
    data: data
  };
  Sheets.Spreadsheets.Values.batchClear(clearRange, spreadsheetId);
  Sheets.Spreadsheets.Values.batchUpdate(update, spreadsheetId);
}

As you can see this script is used to combine and select certain columns from the source data that I want to combine

I wonder if anyone can help me to modify this code so that I can write SQL statement in this script to get data with conditions that I want.
I mean now the code will get columns with all data from that column, but what if i only want to get conditions like where and so on. So I would love to write SQL to get data before I can combine them. I know there is a work around way that uses query in the source URL before running this script but I want to write SQL statement directly in this script

I tried very hard to look up on Google but no one gives me an answer

Love to see any reply and help

Best

exploit the JSONP get parameter

I have a URL that returns a JSON with a GET parameter “cb”

https://jsonp.c00kie.ninja/public/jsonp.php?cb

The Get parameter cb takes a value as the name of the function so its like a JSONP.

This URL is sanitized but the parameter can be exploited by passing “alert” function as a parameter

example.

https://jsonp.c00kie.ninja/public/jsonp.php?cb=alert

this URL will return a JSON wrapped by alert.
Is there a way to be able to execute a custom defined function.

What I have noticed that it removes brackets and the eval method which is the sensitization process.

How to select multiple rows and sub rows in React?

I’m looking for some help to implement row select functionality in my React app.

I have the following data that I provide to the table(react-data-table-component):

const data = useMemo(
  () =>
    [...Array(87)].map((_, outer) => ({
      id: `o-${outer}`,
      name: randFullName(),
      age: randNumber({ max: 100 }),
      price: randNumber({ max: 5000 }),
      description: randProductDescription(),
      active: randBoolean(),
      date: randFutureDate().toLocaleString(),
      items: [...Array(randNumber({ max: 10 }))].map((__, inner) => ({
        id: `o-${outer}--i-${inner}`,
        name: randFullName(),
        age: randNumber({ max: 100 }),
        price: randNumber({ max: 5000 }),
        description: randProductDescription(),
        active: randBoolean(),
        date: randFutureDate().toLocaleString(),
      })),
    })),
  [],
);

I display this data in a table.

There is a parent row and each parent row can be expanded which contains the child rows.

enter image description here

Now, I want to be able to select rows. I use a three-state checkbox where three states are:

  • checked: when all the child rows are checked
  • empty: when no children row is selected
  • intermediate: when some of the child rows are selected

I want to render the checkbox states and also be able to access the selected rows.

I am using a custom selector cell like this:

const SelectorCell = ({
  rowId,
  parentId,
  siblingIds,
  childrenIds,
}: {
  rowId: string;
  parentId: string;
  siblingIds: string[];
  childrenIds: string[];
}) => {
  const { toggleRow, rowSelectionStatus } = useContext(
    NewTableSelectedRowsContext,
  ) as NewTableSelectedRowsType;

  const handleToggle = useCallback(() => {
    // todo
  }, []);

  const status = rowSelectionStatus(rowId);

  return <ThreeStateCheckbox checked={status} onChange={handleToggle} />;
};

I have tried to achieve this using a context provider but haven’t got any success:

import { createContext, useCallback, useMemo, useState } from "react";
import {
  NewTableSelectedRowsType,
} from "./types";

const statusTypes = {
  checked: true,
  intermediate: null,
  unchecked: false,
};

export const NewTableSelectedRowsContext = createContext<NewTableSelectedRowsType | null>(null);

interface Props {
  children: JSX.Element;
}

export const NewTableSelectedRowsContextProvider = ({ children }: Props): JSX.Element => {
  const rowSelectionStatus = useCallback((rowId: string) => // todo, []);

  const toggleRow = useCallback(() => {
      // todo
    },
    [],
  );

  const value: NewTableSelectedRowsType = useMemo(
    () => ({
      toggleRow,
      rowSelectionStatus,
    }),
    [rowSelectionStatus, toggleRow],
  );

  return (
    <NewTableSelectedRowsContext.Provider value={value}>
      {children}
    </NewTableSelectedRowsContext.Provider>
  );
};

How can I achieve that in React?

How to copy/paste data objects within an app, but allow copy/pasting the formatted text to Excel, from JavaScript?

Kind of hard to put into a title, but basically I want to allow copy/paste and cutting of text in an HTML table to an Excel spreadsheet, but at the same time keep track of the underlying data models during these operations, so if you cut then paste all within the app, in pastes the data models under the hood, rather than the literal formatted text.

In more detail, I have an HTML table generated in React from some data objects, like:

{ a: 'foo', b: 123, c: true, d: { nested: 'hello' } }

Each field becomes a block in the spreadsheet grid. In the simple cases where the value is a literal string, we can just render the value directly. But for booleans, let’s say we render it as “yes” or “no”, and for d (a property with more complex nested data) we have to dig into the object to get the value hello.

Ideally here is how it would work. When you cmd+x (cut) in the app, after highlighting some blocks, you are actually cutting out the data model directly. So what gets stored in memory (in the “data model clipboard”) is something like:

[
  'foo',
  123,
  true,
  { nested: 'hello' }
]

When you go to then paste somewhere else within the app’s table, it reads this data model from the “data model clipboard”, and sends that to the table, which it then formats and renders properly.

All is well and good.

But now I want to work with Excel files too. I can write to the navigator clipboard in the browser some text, which is line and tab delimited, which will nicely paste into Excel. However, I would be copying to this “native browser text clipboard” the actual formatted text you see on the screen. This is fine, because what can you do with regards to Excel, I don’t know how advanced you can get with copying to Excel (but it’s beside the point).

So now I can copy from the app to Excel (the “text”), and within the app I can copy/cut/paste from/to the app (the “data model”). However, how can I manage both at the same time?

If you copy from the app, it should do something like both copy to the native browser text clipboard, AND the data model clipboard (our own implementation of your basic in-memory stuff). The problem is, what if I then paste the text into Excel, change it a little in Excel, and then copy it back from Excel and try to paste it in the app?

It will have the old in-memory data model clipboard stuff still there, plus new text clipboard stuff from Excel.

So I need to somehow flag the data or something. Any ideas how to solve this?

Can you somehow store hidden data in the text clipboard, which won’t get pasted into Excel, but will be grabbable from the text clipboard? I am imagining like, I would copy to the data model clipboard, and also some secret/special key to the text clipboard, as well as the formatted excel text below that. Then when you paste in Excel, in theory (i.e. ideally) it would not paste this “special” header, but only the text. So if I try to paste again in the app, it would first check the text header. If the special header is still there, it knows it can use the in-memory data model clipboard. If the special header is missing in the text clipboard, this means they copied directly from Excel (or elsewhere), so we need to use the raw text data from the text clipboard instead.

Is anything like this possible? Thanks so much for the help.

problem with getting ElementLocation and adding Class to a component

I’m trying to add FadeIn Effect upon Viewport Just Like in this codePen :
https://codepen.io/treppin/pen/BWeKRY

So I created a fadeIn-Right css with sort of animation and tried adding the class to Element when it comes in viewport (only once) But it’s not working. Where did I get wrong.

I want it to just like in the above example with some changes like fadeIn from right or left.

function checkElementLocation() {
                var $window = $(window);
                var bottom_of_window = $window.scrollTop() + $window.height();

                $('.elem').each(function (i) {
                    var $that = $(this);
                    var bottom_of_object = $that.position().top + $that.outerHeight();

                    if (bottom_of_window > bottom_of_object) {
                        $(this).addClass('fadeIn-Right');
                    }
                });
            }
            checkElementLocation();
            $(window).on('scroll', function () {
                checkElementLocation();
            });
body {
            margin: 0;
        }
        .container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background-color: bisque;
        }
        .content {
            width: 30%;
            margin: 100px 0;
            padding: 50px 100px;
            height: auto;
        }
        .r1 {background-color: #3b599877;}
        .r2 {background-color: red;}
        .r3 {background-color: #3b5998;}
        .r4 {background-color: green;}
        .r5 {background-color: #3b5998da;}

        
        .fadeIn-Right {
            animation: fadeRight 3s ease-in-out  forwards;
        }
        @keyframes fadeRight {
            0% {
                transform: translateX(-20px);
                opacity: 0;
            }
            100% {
                transform: none;
                opacity: 1;
            }
        }
<div class="container">
        <div  class="elem content r1">
            Hello World
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
        </div>
        <div class="elem content r2  ">
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
        </div>
        <div class="elem  content r3 ">
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
        </div>
        <div class="elem content r4 ">
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
        </div>
        <div class="elem content r5" >
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
            "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
        </div>
    </div>

JS dropdown filter with tables

I’ve found dropdown filter for html tables for 2 different options, but i need 4 options, so Ive upgraded it, added 2 more options and copypasted js code which was for option 1 and 2 and created for option 3 and 4 same code, but it doesn’t work now, Where is the problem ?

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">

    $(document).ready(function () {
        $("#ddlType,#ddlPrice,#ddlAmount,#ddlStar").on("change", function () {
            var type = $('#ddlType').find("option:selected").val();
            var price = $('#ddlPrice').find("option:selected").val();
            var amount = $('#ddlAmount').find("option:selected").val();
            var star = $('#ddlStar').find("option:selected").val();
            SearchData(type, price, amount, star)
        });
    });
    function SearchData(type, price, amount, star) {
        if (type.toUpperCase() == 'ALL' && price.toUpperCase() == 'ALL' && amount.toUpperCase() == 'ALL' && star.toUpperCase() == 'ALL') {
            $('#table11 tbody tr').show();
        } else {
            $('#table11 tbody tr:has(td)').each(function () {
                var rowType = $.trim($(this).find('td:eq(1)').text());
                var rowPrice = $.trim($(this).find('td:eq(3)').text());
                var rowAmount = $.trim($(this).find('td:eq(4)').text());
                var rowStar = $.trim($(this).find('td:eq(5)').text());
                if (type.toUpperCase() != 'ALL' && price.toUpperCase() != 'ALL' && amount.toUpperCase() != 'ALL' 
                && star.toUpperCase() != 'ALL') {
                    if (rowType.toUpperCase() == type.toUpperCase()  && rowPrice == price && rowAmount == amount 
                    && rowStar == star) {
                        $(this).show();
                    } else {
                        $(this).hide();
                    }
                } else if ($(this).find('td:eq(1)').text() != '' || $(this).find('td:eq(1)').text() != '' 
                || $(this).find('td:eq(1)').text() != '' || $(this).find('td:eq(1)').text() != '') {
                    if (type != 'all') {
                        if (rowType.toUpperCase() == type.toUpperCase()) {
                            $(this).show();
                        } else {
                            $(this).hide();
                        }
                    }
                    if (price != 'all') {
                        if (rowPrice == price) {
                            $(this).show();
                        }
                        else {
                            $(this).hide();
                        }
                    }
                    if (amount != 'all') {
                        if (rowAmount == amount) {
                            $(this).show();
                        } else {
                            $(this).hide();
                        }
                    }
                    if (star != 'all') {
                        if (rowStar == star) {
                            $(this).show();
                        } else {
                            $(this).hide();
                        }
                    }
                }
 
            });
        }
    }
</script>

<select class="cl_type" id="ddlType">
    <option value="all">Select option </option>
    <option value="Rest">Rest</option>
    <option value="Excursion">Excursion</option>
    <option value="Shoping">Shoping</option>
</select>

<select class="cl_price" id="ddlPrice">
    <option value="all">Select option </option>
    <option value="500">500</option>
    <option value="1000">1000</option>
    <option value="3000">3000</option>
</select>

<select class="cl_amount" id="ddlAmount">
  <option value="all">Select option </option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
</select>

<select class="cl_star" id="ddlStar">
  <option value="all">Select option </option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
</select>
<table style="width: 100%" id="table11" border="1">
    <tr>
        <th>Type</th>
        <th>Description</th>
        <th>Price</th>
        <th>Amount of persons</th>
        <th>Type of hotel</th>
    </tr>
    <tr>
        <td>REST</td>
        <td>Description</td>
        <td>500</td>
        <td>2</td>
        <td>3</td>
    </tr>
    <tr>
      <td>REST</td>
      <td>Description</td>
      <td>3000</td>
      <td>3</td>
      <td>5</td>
    </tr>
    <tr>
      <td>SHOPING</td>
      <td>Description</td>
      <td>500</td>
      <td>2</td>
      <td></td>
    </tr>
    <tr>
      <td>SHOPING</td>
      <td>Description</td>
      <td>1000</td>
      <td>3</td>
      <td></td>
    </tr>
    <tr>
      <td>EXCURSION</td>
      <td>Description</td>
      <td>500</td>
      <td>2</td>
      <td></td>
    </tr>
    <tr>
      <td>EXCURSION</td>
      <td>Description</td>
      <td>1000</td>
      <td>4</td>
      <td></td>
    
    </tr>
</table>

Im bad at js, so can you please show where is mistake.
Found this code here: code

How to implement roles if user have more than one roles in Reactjs?

Previously I’ve created with Custom Hook and it works but only for 1 role .

How do I make it work for users who have more than 1 role?

example of user roles:
User 1 = [“Super Admin”, “Marketing”]
User 2 = [“Marketing”, “Customer Service”]

This code for Role Map:

enum ROLES {
  SUPER = "Super Admin",
  MARKETING = "Marketing",
  CUSTOMER_SERVICE = "Customer Service"
};

export const rolesMaps = (role) => {
  switch (role) {
    case ROLES.SUPER_ADMIN: {
      return {
        adminUserFeature: "READ WRITE DELETE",
        homePageFeature: "READ WRITE DELETE",
      };
    }
    case ROLES.MARKETING : {
      return {
        adminUserFeature: "READ WRITE DELETE",
        homePageFeature: "READ WRITE ",
      };
    }
    case ROLES.CUSTOMER_SERVICE : {
      return {
        adminUserFeature: "READ",
        homePageFeature: "READ",
      };
    }
    default:
      return {};
  }
}

This code for Custom Hook

import { useMemo } from "react";
import { rolesMaps } from "./rolesMaps"; //Role Map

export const usePermissions = (role, feature) => {
  return useMemo(() => {
    const permissions = rolesMaps(role && role[0])[feature];
    console.log("permisi", permissions);
    
    return {
      canRead: !!permissions?.includes("READ"),
      canWrite: !!permissions?.includes("WRITE"),
      canDelete: !!permissions?.includes("DELETE"),
    };
  }, [role, feature]);
}

This code for implement on component

  const role = useGetRole()
  const { canWrite } = usePermissions(role, "homePageFeature");

  {canWrite && <Button variant="primary" onClick={handleAddNew}>Add New</Button>}