Reference error: API_URL_KEY is not defined

hardhat.config.js

require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
 solidity: "0.8.18",
};

/* @type import('hardhat/config').HardhatUserConfig*/
require("@nomiclabs/hardhat-ethers");
require('dotenv').config(); 
const { API_URL_KEY, PRIVATE_KEY } = process.env; 
module.exports = {   
  solidity: "0.8.17",   
  defaultNetwork: "goerli",   
  networks: {      
    hardhat: {},      
    goerli: {         
     url: API_URL_KEY,         
     account: [`${PRIVATE_KEY}`]      
   }   
 },
   }

.env

PRIVATE_KEY=b14......3f
API_URL_KEY=https://alien-few-river.ethereum-goerli.discover.quiknode.pro/..../

npx hardhat compile
An unexpected error occurred:

ReferenceError: API_URL_KEY is not defined

Remove cookies using chrome.cookies.remove api method

Working on a Cookie Manager chrome extension, I added below 4 cookies one by one using chrome.cookies.set method. All the 4 cookies have the same name, but different domain/path combination.

enter image description here

Now, if I remove one cookie using chrome.cookies.remove method, it is also deleting some other cookies depending on domain and path. For example, if I delete first cookie which have domain as “stackoverflow.com” and path as “/questions”, it is deleting the remaining 3 cookies as well which have the same name.

How can I distinguish between the domains “stackoverflow.com” and “.stackoverflow.com” in chrome.cookies.remove method?

Why deleting cookies of same domain, same name but longer path also deleting the cookies of same domain, same name but shorter path?

How can I achieve the behavior of deleting any one cookie does not remove any of the other 3 cookies?

I am using below method to construct url when using chrome.cookies.remove method:

function buildRemoveCookieUrl(cookie) {
   return `http${cookie.secure ? 's' : ''}://${cookie.domain}${cookie.path}`;
}

Thanks,

Column Resize using PrimeNG p-table not working

hi I am trying to use primeNG column resize using pResizableColumn but it is not working.
I have tried using this https://primeng.org/table#column-resize . kindly help me to solve this.

<p-table #dt [columns]="headers" [value]="DocumentList" [paginator]="true" [rows]="rowSize" [pageLinks]="5"
          (sortFunction)="customSort($event)" [customSort]="true" [alwaysShowPaginator]=true exportFilename="ListDocs"
          [responsive]="true" [(first)]="first" [showCurrentPageReport]="true"
          currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries"
          [rowsPerPageOptions]="[5,10,15,25,50]" [autoLayout]="true" [resizableColumns]=true responsiveLayout="scroll"
          selectionMode="multiple" [(selection)]="selectedItems">

 



<ng-template pTemplate="header" let-columns>
<tr>
<th pResizableColumn style="border-bottom: none !important;" [style]="{minWidth: '120px'}"><span><p-tableHeaderCheckbox
                style="padding-left:5px;border-bottom: none !important;">
</p-tableHeaderCheckbox>{{'Select' | translate}}</span></th>
<th [pSortableColumn]="'DOC_GRP_NUM'" pResizableColumn style="padding-left:5px !important;border-bottom: none !important;
          border-left:none !important" [style]="{minWidth: '150px'}">
                {{'Document_Group_Number' | translate}}
<p-sortIcon [field]="'DOC_GRP_NUM'" ariaLabelAsc="Activate to sort in ascending order"
                  ariaLabelDesc="Activate to sort in descending order">
</p-sortIcon>
</th>

</tr>
</ng-template>
<ng-template pTemplate="body" id="table" let-documentList>
<tr>
<td>
<p-tableCheckbox [value]="rowData"></p-tableCheckbox>
</td>
<td [style]="{minWidth: '150px'}"><a id="docNum"
                  style="cursor: pointer;" (click)="openDocNumPopup(docNumPopup);Data(rowData)">{{rowData.DOC_GRP_NUM}}
</a>
</td>

</tr>
</ng-template>

</p-table>

Populating select options from database on tabulator?

can you help me Populating select options from the database I’m using Tabulator to update data from the database dynamically can you check the code below and tell me how I can save data on the database or there any other way I can use Populating

Full Code on a tabulator JS

<script>
  document.addEventListener("DOMContentLoaded", function() {
  var tabledata = {!! $Payment !!};
  var Paymentcat = {!! $Paymentcat !!};
  var contract = {!! $Contract !!};  
  var paymentmethod = {!! $PaymentMethod !!};  
  var product = {!! $Product !!};  

  var table = new Tabulator("#example-table-theme", {
    layout: "fitColumns",
    columnCalcs:"both",
    paginationSize:20,
    pagination: "local", // Enable local pagination
    paginationSizeSelector:[10, 20, 30, 50, 100, 200],
    paginationCounter:"rows",
    data: tabledata,
    columns: [
      { title: "Payment ID", field: "PaymentID", editor: "input"},
      { title: "Payment Category",field: "category.Name", editor: "list",
                editorParams: function(cell, formatterParams, onRendered) {
                var options = {};
                Paymentcat.forEach(function(item) {
                options[item.ID] = item.Name;
                });
                // Return the options for the editor
                return {
                 values: options ,
             };
         },    
      },
      {
        title: "Select Contract /Product",
        field: "Descriptions",
        editor: "list",
        editorParams: function(cell, onRendered, success, cancel, editorParams) {
          var rowData = cell.getRow().getData();
          var category = rowData.category.Name;
          var netpay = rowData.NetPay;
          var options = {};
        
          if (category === "Product Payment" || category === "1") {
            product.forEach(function(item) {
              options[item.Name] = item.Name;
          });
  
          } else if (category === "Membership Payment" || category === "2" ) {
            contract.forEach(function(item) {
              options[item.Package] = item.Package;
          });
            ////////////////////////////////////////////////////////////////
          } else if (category === "3") {
            ////////////////////////////////////////////////////////////////
           
          } else if (category === "4") {
            ////////////////////////////////////////////////////////////////
          }
          return {
            values: options,
          };
        }
      },
      { title: "Net Pay (₱)", field: "NetPay", editor: "number" },
      { title: "Discount", field: "Discount", editor: "number" },
      { title: "Grand Total", field: "GrandTotal", editor: "number", bottomCalc:"sum", bottomCalcParams:{
       precision:2,}},
      { title: "Date Sale", field: "DateSale", editor: "date"},
      { title: "Payment Method",field: "PaymentMethod", editor: "list",
                editorParams: function(cell, formatterParams, onRendered) {
                var options = {};
                paymentmethod.forEach(function(item) {
                options[item.Name] = item.Name;
                });
                // Return the options for the editor
                return {
                 values: options ,
             };
         },    
      },
      { title: "Sales Person", field: "SalesPerson", editor: "input"},
      { title: "ReferenceNo", field: "ReferenceNo", editor: "input"},
      { title: "Receipt", field: "Receipt", editor: "input"},
      { title: "Status", field: "Status"},
      ],
     });
     table.on('cellEdited', (cell) => {
              var row = cell.getRow();
              var field = cell.getField();
              var value = cell.getValue();
                  var data = {
                    id: row.getData().ID, // Get the MID value from the row data
                    column: field,
                    value: value
                  };
                  console.log(data);
                // Update the data in the table
                axios.get(`/payment/edit/${data.id}`, {
                      params: {
                          column: data.column,
                          value: data.value
                      }
                  })
                .then(function(response) {
                  if (response.data.success) {
                    table.setData('/payment/view');
                  } else {
                      //alert("The provided data is already exists for another member");
                      table.setData('/payment/view');
                  }
                })
                .catch(function(error) {
                  console.log(response.data.message);
                });
               })
        // Add row to bottom of table on button click
        document.getElementById("reactivity-add").addEventListener("click", function() {
          var newData = { ID: "" };
          tabledata.unshift(newData);
          table.setData(tabledata);
          // Send AJAX request to store the new data
          axios.post('/payment/store', newData)
            .then(function(response) {
              //table.setData('/payment/view');
            })
            .catch(function(error) {
              // Handle error
              console.error(error);
            });
        });
      
      });
</script>

This is the foreach

 if (category === "Product Payment" || category === "1") {
            product.forEach(function(item) {
              options[item.Name] = item.Name; // Get Data  like item.Name , item.Price and parse data to other cell 
          });

Cell I want to parse data from foreach

 { title: "Net Pay (₱)", field: "NetPay", editor: "number" },
 { title: "Discount", field: "Discount", editor: "number" },
      { title: "Grand Total", field: "GrandTotal", editor: "number", bottomCalc:"sum", bottomCalcParams:{
       precision:2,}},

popover bootstrap not display on all pages although i put it on layout page?

I work on asp.net razor pages . I face issue I can’t display popovers content on all pages of web applications

it working and display on some pages and some pages not working

popovers exist on layout page and all pages inherit from it

so my question why popovers not working on some pages and working on another page

I need to know why it not working

my layout page as below so

content This is the popover content. not show on on some pages so why and how to solve this issue please

DashboardLyout

<a  data-toggle="popover"  title="ahmed salah"><img src="@Url.Content("~/Img/imgprofile.png")" alt="ImageProfile" /></a>

@RenderBody()
                        <script>

                            $(function () {
                                // Enables popover
                                $("[data-toggle=popover]").popover({ content: "This is the popover content."});
                            });
                        </script>

sample page from inherit from DashboardLayout page

@page "/AddBranch"
@model UC.ADC.Host.Pages.Branch.AddBranchModel
@{
    Layout = "DashboardLayout";
}

why popovers working on some pages and display content and other pages not display content popovers

error running react-native application MaxBufferError: stderr maxBuffer exceeded

When I try to run any react-native application I don’t come across this error, even when I’ve just created a new application!

Please help me! more error details:


C:laragonbinnodejsnode-v18.16.0-win-x64node.exe C:UsersgPhpstormProjectsBoleianode_modulesreact-native/local-cli/cli.js run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1485 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
Starting a Gradle Daemon, 2 busy Daemons could not be reused, use --status for details
> Task :react-native-gradle-plugin:compileKotlin UP-TO-DATE
> Task :react-native-gradle-plugin:compileJava UP-TO-DATE
> Task :react-native-gradle-plugin:pluginDescriptors UP-TO-DATE
> Task :react-native-gradle-plugin:processResources UP-TO-DATE
> Task :react-native-gradle-plugin:classes UP-TO-DATE
> Task :react-native-gradle-plugin:inspectClassesForKotlinIC UP-TO-DATE
> Task :react-native-gradle-plugin:jar UP-TO-DATE

MaxBufferError: stderr maxBuffer exceeded
    at PassThrough.<anonymous> (C:UsersgPhpstormProjectsBoleianode_modules@react-native-communitycli-platform-androidnode_modulesget-streamindex.js:41:19)
    at PassThrough.emit (node:events:525:35)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:293:11)
    at Readable.push (node:internal/streams/readable:234:10)
    at node:internal/streams/transform:182:12
    at PassThrough._transform (node:internal/streams/passthrough:46:3)
    at Transform._write (node:internal/streams/transform:175:8)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
info Run CLI with --verbose flag for more details.
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.


I’ve tried unfortunately I couldn’t solve this error, I’ve already tried to increase the maxBuffer when executing the react-native run android

Shop Electric Balance Bikes & Scooters with Baskets Order Now

At BrocUSA, we are dedicated to providing top-quality [electric balance bikes and scooters for kids](https://brocusa.com/products/balance-e-bike-kids-12pink).
enter image deselectric balance bikes and scooters for kidscription here
Our selection of electric balance bikes is perfect for children who are learning to ride and want a fun and easy way to get around. With a lightweight and sturdy design, our electric balance bikes are perfect for kids of all ages.

We also offer electric scooters with baskets, perfect for kids who love to ride and need a way to carry their belongings. Our electric scooters are designed with safety in mind, and feature a stable and durable construction that can withstand even the toughest of rides.

At BrocUSA, we pride ourselves on providing excellent customer service and unbeatable prices. We offer fast and reliable shipping, and our knowledgeable staff are always available to answer any questions you may have. So if you’re looking for the perfect electric balance bike or scooter for your child, look no further than BrocUSA.

we give our best and we give best electric balance bikes and scooters for kids under low prise in usa

Sidebar collapsed on page load making click twice to open the menu

I am using the sidebar expand/collapse menu. I need to hide it on pageload but when I doing it using jquery $(".page-container").addClass("sidebar-collapsed") I have to click twice to open it for the first time after that it works as expected.

Need help with this. I have added working example as well.

var toggle = true;
$(".page-container").addClass("sidebar-collapsed")
$(".sidebar-icon").click(function() {
    if (toggle)
    {
    $(".page-container").addClass("sidebar-collapsed").removeClass("sidebar-collapsed-back");
    $("#menu span").css({"position":"absolute"});
    }
    else
    {
    $(".page-container").removeClass("sidebar-collapsed").addClass("sidebar-collapsed-back");
    setTimeout(function() {
        $("#menu span").css({"position":"relative"});
    }, 400);
    }
    toggle = !toggle;
});
.page-container.sidebar-collapsed {
padding-right: 0;
transition: all 100ms linear;
transition-delay: 300ms;
}

.page-container.sidebar-collapsed-back {
padding-right: 0;
transition: all 100ms linear;
}

.page-container.sidebar-collapsed .sidebar-menu {
width: 75px;
transition: all 100ms ease-in-out;
transition-delay: 300ms;
}

.page-container.sidebar-collapsed-back .sidebar-menu {
width: 280px;
transition: all 100ms ease-in-out;
}

.page-container.sidebar-collapsed .sidebar-icon {
transform: rotate(90deg);
transition: all 300ms ease-in-out;
}

.page-container.sidebar-collapsed-back .sidebar-icon {
transform: rotate(0deg);
transition: all 300ms ease-in-out;
}

.page-container.sidebar-collapsed .logo {
padding: 20px;
box-sizing: border-box;
transition: all 100ms ease-in-out;
transition-delay: 300ms;
}

.page-container.sidebar-collapsed-back .logo {
width: 100%;
padding: 20px;
box-sizing: border-box;
transition: all 100ms ease-in-out;
}

.page-container.sidebar-collapsed #logo {
opacity: 0;
transition: all 200ms ease-in-out;
}

.page-container.sidebar-collapsed-back #logo {
opacity: 1;
transition: all 200ms ease-in-out;
transition-delay: 300ms;
}

.page-container.sidebar-collapsed #menu span {
opacity: 0;
transition: all 50ms linear;
}

.page-container.sidebar-collapsed-back #menu span {
opacity: 1;
transition: all 200ms linear;
transition-delay: 300ms;
padding-left: 10px;
}

.sidebar-menu {
position: fixed;
float: left;
width: 280px;
top: 0;
left: 0;
bottom: 0;
background-color: #5B79A1;
color: #fff;
z-index: 1031;
}

#menu {
list-style: none;
margin: 0;
padding: 0;
margin-bottom: 20px;
}

#menu li {
position: relative;
margin: 0;
margin-top: 25px;
padding: 0;
}

#menu li ul {
opacity: 0;
height: 0px;
}

#menu li a {
font-style: normal;
font-weight: 400;
position: relative;
display: block;
padding: 10px 0 10px 15px;
color: #fff;
white-space: nowrap;
z-index: 2;
font-size: 20px;
}

#menu li a:hover {
color: #ffffff;
background: rgba(255, 255, 255, 0.25);
transition: color 250ms ease-in-out, background-color 250ms ease-in-out;
text-decoration: none;
}

#menu li.active > a {
background-color: #2b303a;
color: #ffffff;
}

#menu ul li { 
    background-color: #2b303a; 
}

#menu ul {
list-style-type: none;
margin: 0;
padding: 0;
}

#menu li ul {
position: absolute;
visibility: hidden;
left: 100%;
top: -1px;
background-color: #2b303a;
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.5);
opacity: 0;
transition: opacity 0.1s linear;
border-top: 1px solid rgba(69, 74, 84, 0.7);
}

#menu li:hover > ul {
visibility: visible;
opacity: 1;
}

#menu li li ul {
left: 100%;
visibility: hidden;
top: -1px;
opacity: 0;
transition: opacity 0.1s linear;
}

#menu li li:hover ul {
visibility: visible;
opacity: 1;
}

#menu .fa { margin-right: 5px; }

.logo {
width: 100%;
box-sizing: border-box;
}

.sidebar-icon {
float: right;
font-size: 25px;
color: #D0D5DD;
margin-top: -10px;
position: relative;
}
<script src="https://code.jquery.com/jquery-3.6.4.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<div class="page-container">
<div class="sidebar-menu">
              <div class="logo"> 
                <a href="#" class="sidebar-icon"><svg width="37" height="26" viewBox="0 0 37 26" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M27.6667 9.33333H2M35 2H2M35 16.6667H2M27.6667 24H2" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
                    </svg>
                    </a> 
              </div>
              <div class="menu">
                <ul id="menu">
                  <li><a href="#"><svg width="36" height="33" viewBox="0 0 36 33" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M15.0051 31.5649V29.7669C15.0051 28.8132 14.6339 27.8986 13.9731 27.2242C13.3122 26.5499 12.4159 26.171 11.4814 26.171H4.4339C3.49935 26.171 2.60307 26.5499 1.94224 27.2242C1.28141 27.8986 0.910156 28.8132 0.910156 29.7669V31.5649M11.4814 18.9792C11.4814 20.9652 9.90376 22.5751 7.95765 22.5751C6.01153 22.5751 4.4339 20.9652 4.4339 18.9792C4.4339 16.9932 6.01153 15.3833 7.95765 15.3833C9.90376 15.3833 11.4814 16.9932 11.4814 18.9792Z" stroke="white" stroke-width="1.71232" stroke-linecap="round" stroke-linejoin="round"/>
                    <path d="M34.386 31.5649V29.7669C34.386 28.8132 34.0147 27.8986 33.3539 27.2242C32.6931 26.5499 31.7968 26.171 30.8622 26.171H23.8148C22.8802 26.171 21.9839 26.5499 21.3231 27.2242C20.6623 27.8986 20.291 28.8132 20.291 29.7669V31.5649M30.8622 18.9792C30.8622 20.9652 29.2846 22.5751 27.3385 22.5751C25.3924 22.5751 23.8148 20.9652 23.8148 18.9792C23.8148 16.9932 25.3924 15.3833 27.3385 15.3833C29.2846 15.3833 30.8622 16.9932 30.8622 18.9792Z" stroke="white" stroke-width="1.71232" stroke-linecap="round" stroke-linejoin="round"/>
                    <path d="M32.624 6.09421C32.626 6.88523 32.4449 7.66555 32.0954 8.37161C31.681 9.21769 31.044 9.92934 30.2557 10.4268C29.4674 10.9243 28.5589 11.188 27.632 11.1884C26.8568 11.1905 26.0922 11.0056 25.4003 10.649L22.0527 11.7877L23.1686 8.37161C22.8191 7.66555 22.638 6.88523 22.64 6.09421C22.6404 5.14834 22.8988 4.22125 23.3863 3.41679C23.8738 2.61233 24.5712 1.96226 25.4003 1.5394C26.0922 1.18277 26.8568 0.997955 27.632 1.00002H27.9256C29.1497 1.06893 30.3059 1.59619 31.1728 2.48084C32.0397 3.36549 32.5564 4.54536 32.624 5.79455V6.09421Z" stroke="white" stroke-width="0.933995" stroke-linecap="round" stroke-linejoin="round"/>
                    <path d="M2.67292 6.09421C2.6709 6.88522 2.85201 7.66554 3.20148 8.37161C3.61586 9.21769 4.25288 9.92934 5.0412 10.4268C5.82952 10.9243 6.738 11.188 7.66489 11.1884C8.44003 11.1905 9.20469 11.0056 9.89659 10.649L13.2441 11.7877L12.1283 8.37161C12.4778 7.66554 12.6589 6.88522 12.6569 6.09421C12.6565 5.14834 12.3981 4.22125 11.9106 3.41679C11.4231 2.61233 10.7257 1.96226 9.89659 1.5394C9.20469 1.18277 8.44003 0.997955 7.66489 1.00002H7.37124C6.14713 1.06893 4.99093 1.59619 4.12403 2.48084C3.25714 3.36549 2.74046 4.54536 2.67292 5.79455V6.09421Z" stroke="white" stroke-width="0.933995" stroke-linecap="round" stroke-linejoin="round"/>
                    </svg>
                    <span>Counseling</span></a></li>
                  <li><a href="#"><svg width="24" height="27" viewBox="0 0 24 27" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M22.6111 25.6401V23.0134C22.6111 21.6201 22.0576 20.2839 21.0724 19.2987C20.0872 18.3135 18.751 17.7601 17.3577 17.7601H6.85101C5.45773 17.7601 4.12152 18.3135 3.13633 19.2987C2.15113 20.2839 1.59766 21.6201 1.59766 23.0134V25.6401M17.3577 7.25335C17.3577 10.1547 15.0057 12.5067 12.1044 12.5067C9.20302 12.5067 6.85101 10.1547 6.85101 7.25335C6.85101 4.35201 9.20302 2 12.1044 2C15.0057 2 17.3577 4.35201 17.3577 7.25335Z" stroke="white" stroke-width="2.62668" stroke-linecap="round" stroke-linejoin="round"/>
                    </svg>
                    <span>Coaching</span></a></li>
                  <li><a href="#"><svg width="29" height="28" viewBox="0 0 29 28" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M21.7879 7.68604H14.1466C13.64 7.68604 13.1541 7.8873 12.7958 8.24555C12.4376 8.6038 12.2363 9.0897 12.2363 9.59635V24.8788C12.2363 25.3855 12.4376 25.8714 12.7958 26.2296C13.1541 26.5879 13.64 26.7891 14.1466 26.7891H25.6085C26.1151 26.7891 26.601 26.5879 26.9593 26.2296C27.3175 25.8714 27.5188 25.3855 27.5188 24.8788V13.417M21.7879 7.68604L27.5188 13.417M21.7879 7.68604V13.417H27.5188M23.6982 18.1927H16.0569M23.6982 22.0134H16.0569M17.9673 14.3721H16.0569" stroke="white" stroke-width="1.91031" stroke-linecap="round" stroke-linejoin="round"/>
                    <path d="M20.8336 5.77578C20.8336 5.26913 20.6323 4.78324 20.2741 4.42498C19.9158 4.06673 19.4299 3.86547 18.9233 3.86547H10.3269L8.41656 1H3.64078C3.13413 1 2.64824 1.20126 2.28999 1.55952C1.93173 1.91777 1.73047 2.40366 1.73047 2.91031V16.2825C1.73047 16.7891 1.93173 17.275 2.28999 17.6333C2.64824 17.9915 3.13413 18.1928 3.64078 18.1928H10.3269" stroke="white" stroke-width="1.91031" stroke-linecap="round" stroke-linejoin="round"/>
                    </svg>
                    <span>Application</span></a></li>
                  <li><a href="#"><svg width="24" height="29" viewBox="0 0 24 29" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M13.275 2H4.19262C3.50439 2 2.84435 2.26919 2.3577 2.74835C1.87105 3.22752 1.59766 3.8774 1.59766 4.55504V24.9953C1.59766 25.673 1.87105 26.3229 2.3577 26.802C2.84435 27.2812 3.50439 27.5504 4.19262 27.5504H19.7624C20.4506 27.5504 21.1106 27.2812 21.5973 26.802C22.0839 26.3229 22.3573 25.673 22.3573 24.9953V10.9426M13.275 2L22.3573 10.9426M13.275 2V10.9426H22.3573" stroke="white" stroke-width="2.04403" stroke-linecap="round" stroke-linejoin="round"/>
                    <path d="M8.78364 12.3799V23.5582M11.4451 14.4123H7.45289C6.95878 14.4123 6.48491 14.5997 6.13552 14.9332C5.78613 15.2667 5.58984 15.719 5.58984 16.1907C5.58984 16.6623 5.78613 17.1147 6.13552 17.4482C6.48491 17.7817 6.95878 17.969 7.45289 17.969H10.1144C10.6085 17.969 11.0824 18.1564 11.4318 18.4899C11.7812 18.8234 11.9774 19.2757 11.9774 19.7474C11.9774 20.219 11.7812 20.6714 11.4318 21.0049C11.0824 21.3384 10.6085 21.5258 10.1144 21.5258H5.58984" stroke="white" stroke-width="1.02202" stroke-linecap="round" stroke-linejoin="round"/>
                    </svg>
                    <span>Financial</span></a></li>
                  <li><a href="#"><svg width="39" height="30" viewBox="0 0 39 30" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M16.3818 15.546L13.0697 3.67821L14.7861 3.6152L23.0362 16.2794L23.3194 16.7141L23.8383 16.7131L32.6456 16.6963L32.6456 16.6963L32.6556 16.6962C33.2862 16.6884 33.7448 16.9174 34.1216 17.4345C34.5003 17.9545 34.6086 18.5161 34.4225 19.2107C34.3161 19.6076 34.1116 19.9075 33.794 20.1435C33.4619 20.3893 33.1004 20.5126 32.6821 20.5207L5.40794 20.584L3.41488 13.3678L4.2755 13.4287L6.20821 16.3522L6.49234 16.782L7.00756 16.7806L15.4644 16.7579L16.7191 16.7545L16.3818 15.546Z" stroke="white" stroke-width="1.91031"/>
                    <path d="M5.00195 27.0103H34.0129" stroke="white" stroke-width="1.91031"/>
                    </svg>
                    <span>Pre-Departure</span></a></li>
                  <li><a href="#"><svg width="36" height="33" viewBox="0 0 36 33" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M16.5254 15.3966L8.43488 7.97995L9.69228 7.1319L21.8994 12.8301L22.3226 13.0277L22.7186 12.7802L29.3778 8.61835L29.3778 8.61839L29.3854 8.61354C29.8569 8.31197 30.3092 8.26951 30.8356 8.48253C31.3649 8.69674 31.7098 9.06888 31.8954 9.68021C32.0014 10.0292 31.9879 10.3507 31.8592 10.6774C31.7242 11.0182 31.5098 11.2805 31.1985 11.4826L10.5872 24.376L5.69177 19.8641L6.35842 19.5119L9.19512 20.8128L9.6166 21.0061L10.0096 20.7601L16.4007 16.7589L17.3578 16.1597L16.5254 15.3966Z" stroke="white" stroke-width="1.71928"/>
                    <path d="M5.53125 31.218H31.3977" stroke="white" stroke-width="1.71928"/>
                    </svg>
                    <span>Post-Departure</span></a></li>
                </ul>
              </div>
            </div>
            </div>

Sync Up External Script Tag and React State

I have some issues getting the updated data from an external script tag.
I need to navigate to next/prev page before it takes effect.
Right now I have a problem specifically on this part of the code.
The sampleScript.widgetOpen() doesn’t take effect immediately.
Any workaround or idea on how to fix this? What’s the best approach?

Note: SampleScript is only a sample name for privacy purposes. It’s an external script that I referenced in my react app.

The goal is when Sample Script Widget is open, GuidesAndResources modal and Help button should be hidden. Once Sample Script is closed, Help button should appear.

zIndex={
  showGuidesAndResourcesModal || sampleScript.widgetOpen() ? 800 : 1000
}
sx={{
  opacity: showGuidesAndResourcesModal || sampleScript.widgetOpen() ? 0 : 1,
}}

sampleScript.ts

const sampleScript = {
  openMenu: () => {
    window?.SampleScript?.open?.("menu");
  },

  closeMenu: () => {
    window?.SampleScript?.close?.("menu");
  },

  widgetOpen: () => {
    return window?.SampleScript?.isOpen;
  },
};

export default sampleScript;

CustomerLayout.ts

import sampleScript from './sampleScript'

const CustomerLayout = () => {
  const [showGuidesAndResourcesModal, setShowGuidesAndResourcesModal] = useState(false);
  return (
    <>
      <GuidesAndResources
        isOpen={showGuidesAndResourcesModal}
        setIsOpen={setShowGuidesAndResourcesModal}
      />
      <Box
        zIndex={
          showGuidesAndResourcesModal || sampleScript.widgetOpen() ? 800 : 1000
        }
        sx={{
          opacity: showGuidesAndResourcesModal || sampleScript.widgetOpen() ? 0 : 1,
        }}
      >
        <Button
          onClick={() => {
            setShowGuidesAndResourcesModal(true);
          }}
        >
          Open sample script widget
        </Button>
      </Box>
    </>
  );
};

export default CustomerLayout;

GuidesAndResources.ts

const GuidesAndResources = ({ isOpen, setIsOpen }) => {
  const GUIDE_GROUP_ITEMS = [
    {
      groupLabel: "Test",
      guideItems: [
        {
          label: "Sample Script Widget",
          onClick: () => {
            setIsOpen(false);
            sampleScript.openMenu();
          },
        },
      ],
    },
  ];

  return (
    <>
      <Card>
        <Box p={3}>
          {GUIDE_GROUP_ITEMS.map((guideGroup, index) => {
            const { guideItems, groupLabel } = guideGroup;

            return (
              <Box
                key={groupLabel}
              >
                <Box mb={1}>
                  <Typography>
                    {groupLabel}
                  </Typography>
                  <Divider light />
                </Box>
                {guideItems.map((props) => (
                  <GuideItem {...props} />
                ))}
              </Box>
            );
          })}
        </Box>
      </Card>
    </>
  );
};

export default GuidesAndResources;

Select2 with ajax not showing placeholder

I don’t know why the placeholder didn’t appear in select2

   $(document).ready(function(){
    $('#input-search-one').select2({
        placeholder: '{{__("Cari")}}',
        dropdownParent: $('#modal_add_one'),
        ajax: {
            url: "{{ route('api.add.one') }}",
            delay: 300,
            headers: {
              Authorization: `Bearer ${sanctumToken()}`,
            },
            data: function(params) {
                const query = {
                    param: params.term,
                    rpid : '{{ $rpid }}',
                    dc_id : $('#div_one #dc_id').val(),
                    limit: 10,
                                page: params.page || 1,
                }

                return query
            },
            processResults: function(data, params) {
                const more = data.data.length >= 1;
                const formatted = data.data.map(res => {
                    return {
                        id: res.id,
                        text: res.name,
                        ...res
                    }
                })

                return {
                    results: formatted,
                    pagination: {
                        more
                    }
                };
            }
        },
    }).on('select2:opening', function(e){
        const dc = $(''#div_one #dc_id').val()
        
        if ( !dc )
        {
            e.preventDefault()
            Swal.fire('Not completed', __('error_null', 'Not choosen yet'))
        }
    }).on('select2:select', function(e){

        /* clear search input */
        $(this).val('null').trigger('change')

        const data = e.params.data

        const params = {
            rpid: '{{ $rpid }}',
            eqid: data.id,
            dc_id: $('#div_one #dc_id').val(),
        }

        /*for checking price value */
        $.ajax({
            url : '{{ route("api.add.check.one") }}',
            data: params,
            headers: {
                Authorization: `Bearer ${sanctumToken()}`,
            },
            success: function(r) {
                if ( parseFloat(r.data.price) > 0 )
                {
                    appendData(data.id, data.text)
                }
            },
            error: function(err) {
                const res = err?.responseJSON
                Swal.fire('Failed', res.message, 'error')
            }
        })
    })

And this is the view code:

<div class="row g-4 mb-5">
        <div class="col-md-12 fv-row">
            <label class="text-primary fw-bold fs-7 pb-1 required">{{__('Tindakan')}}</label>
            <select class="form-select form-select-sm rounded-1" id="input-search-tindakan-medis-pasien"></select>
        </div>
    </div>

I’m having another one that exactly using the same select2 but for selecting different value and that one is works, the placeholder showing in that select2 field and having no problem but this one is not working, is it have any correlation with ajax when it try to catching the data or something else