Chart.js: Stacked Bar Chart Layout Issue with Additional Single Bar

I’m facing an issue with the layout of my Chart.js stacked bar chart. I’m trying to display a single bar for “前年電力量” (Previous Year’s Power Consumption) alongside a stacked bar for “予想電力量” (Current Year’s Power Consumption).

The issue is with the ordering and stack. if I comment the dataset “Previous year’s total power consumption” in the testdata and the order and stack, the layout works fine, there is an example of data with the correct layout but only for one month, trying to achieve for all 12.

here is the code example in the codesandbox: https://codesandbox.io/p/sandbox/dv2wl3

Trying to achieve the same is if you use data instead of testdata in .

const testdata = {
    labels: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
    datasets: [
      // Unique bar for 前年電力量 (Previous Year's Power Consumption)
      {
        label: "前年電力量", // Previous year's total power consumption
        data: [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
        backgroundColor: "rgb(114, 225, 164)", // Green color for previous year
        // stack: "previousYear", // Separate stack for previous year
        barPercentage: 0.5,
        // grouped: false,
        // order: 3,
      },
  
      // Baseline bar (container) for 今年の電力消費量 (Current Year Estimate)
      {
        label: "予想電力量", // Estimated power consumption for the current year
        data: [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150], // Baseline data for each month
        backgroundColor: "rgba(237, 239, 255, 1)", // Light color to act as background container
        borderColor: "rgba(106, 122, 242, 1)",
        borderWidth: 1,
        borderDash: [5, 5],
        stack: "currentYear", // Stack for current year estimate
        grouped: false,
        order: 1, // Render this first to act as a background layer
        barPercentage: 0.5,
      },

      // Stacked categories within 今年の電力消費量 (Current Year Power Consumption)
      {
        label: "空調 (今年)", // Air Conditioning - Current Year
        data: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
        backgroundColor: "rgba(88, 181, 247, 1)", // Blue color for air conditioning
        stack: "currentYear", // Stack for current year
        grouped: false,
        order: 1,
        barPercentage: 0.5,
      },
      {
        label: "照明 (今年)", // Illumination - Current Year
        data: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
        backgroundColor: "rgb(71, 68, 222)", // Color for illumination
        stack: "currentYear", // Stack for current year
        grouped: false,
        order: 1,
        barPercentage: 0.5,
      },
      {
        label: "冷ケース (今年)", // Cooling Case - Current Year
        data: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
        backgroundColor: "rgb(157, 201, 210)", // Color for cooling case
        stack: "currentYear", // Stack for current year
        grouped: false,
        order: 1,
        barPercentage: 0.5,
      },
      {
        label: "その他 (今年)", // Others - Current Year
        data: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
        backgroundColor: "rgb(182, 193, 200)", // Color for others
        stack: "currentYear", // Stack for current year
        grouped: true,
        order: 1,
        barPercentage: 0.5,
      },
    ],
  };

Thanks!

Upgrading Azure Functions from V3 to V4 when both JavaScript and TypeScript Files are there in same folder

How can the Azure Function version be upgraded from V3 to V4 when both JavaScript and TypeScript files are maintained in the same folder structure? Below is the folder structure for the V3 model.
[folder structure in azure function v3 model]

<project_root>/
 | - .vscode/
 | - dist/
 | - node_modules/
 | - myFirstFunction/
 | | - index.ts
 | | - function.json
 | - mySecondFunction/
 | | - index.ts
 | | - function.json
 | - myThirdFunction/
 | | - index.js
 | | - function.json
 | - .funcignore
 | - host.json
 | - local.settings.json
 | - package.json
 | - tsconfig.json

Additionally, how should the path value for the **main **key in the package.json file be specified for the Azure Function V4 model when both JavaScript and TypeScript files are present in the same folder?

“main”: “dist/src/functions/*.js”

Tried building the root folder and typescript files are converted to JavaScript and moved to dist folder but javascript files are stored in the same folder. After build is generated, how to run the converted JS files from dist folder and jas files from root folder.

How can fix the remainning characters counter in js

I will create a javascript remaining character counter for an HTML textarea. But my code is not working. How can I fix this.

$(document).ready(function(){

  var length = 0;
  var maximumCharacters = 160;

  $('#description').keyup(function(){
    length = this.value.length;

    if(length > maximumCharacters){

      return false;

    } else if (length > 0){

      $("#remaining-characters").html("Remaining characters: " + (maximumCharacters-length));

    } else {

      $("#remaining-characters").html("Remaining characters: " + maximumCharacters);

    }
  })
})
<div class="row mb-3">
        <label for="description" class="col-sm-2 col-form-label label">Description</label>
        <div class="col-sm-10">
          <textarea class="form-control form textarea" id="description" name="description" maxlength="160"></textarea><span id="remaining-characters"></span>
        </div>
      </div>

Print Div At The Bottom Of Page For Multiple Pages

When printing HTML I want to place footer table to the bottom of the page. In case of single page it works as expected but for multiple pages the footer section is printed in bottom of all pages. But for multiple pages I want to print footer table only on bottom of last page. Below is the code

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document with Tables</title>
<style>
    body {
        margin: 0;
        padding: 0;
        font-family: Arial, sans-serif;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .header, .footer {
        width: 100%;
        border: 1px solid #000;
        padding: 10px;
        box-sizing: border-box;
    }

    .body {
        flex: 1;
        overflow: auto;
    }

    table {
        width: 100%;
        border-collapse: collapse;
        margin: 10px 0;
    }

    th, td {
        border: 1px solid #000;
        padding: 8px;
        text-align: left;
    }

    /* Print styles */
    @media print {
        body {
            height: auto; /* Allow body to expand */
            margin: 0;
        }

        .body {
            overflow: visible;
        }

        /* Show footer only on the last page */
        .footer {
            display: block; /* Make it visible on the last page */
            position: fixed;
            bottom: 0;
            width: 100%;
        }

        @page {
            size: auto;
            margin: 0;
        }
    }
</style>
</head>
<body>

<!-- Header Table -->
<table class="header">
    <tr>
        <th colspan="3">Header Section</th>
    </tr>
</table>

<!-- Body Table -->
<div class="body">
    <table id="bodyTable">
        <thead>
            <tr>
                <th>Column 1</th>
                <th>Column 2</th>
                <th>Column 3</th>
            </tr>
        </thead>
        <tbody>
            <!-- Add dynamic rows here -->
            <!-- Example rows -->
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <tr><td>Row 1 Data 1</td><td>Row 1 Data 2</td><td>Row 1 Data 3</td></tr>
            <!-- Add more rows as necessary -->
        </tbody>
    </table>
</div>

<!-- Footer Table -->
<table class="footer" id="footerTable">
    <tr>
        <td>Signature Section</td>
    </tr>
</table>
</body>
</html>

single page print looks like Single Page Print

multiple pages print looks like Multi Page Print

I have also tried to initially hide the footer section and display footer inside onbeforeprint but still same issue for multiple pages.

Why my bootstrap tabs don’t show the content in them?

I am creating a website using the bootstrap nav-tabs, i’m creating two tabs and this tabs showing a table list of candidates, but when i click the other tabs(“Entry Form TTD” tab) the content in it is not showing/blank

<div class="container-fluid d-flex flex-column border border-danger">
        <div class="container my-3">
            <ul class="nav nav-tabs" id="candidateTabs" role="tablist">
                <li class="nav-item" role="presentation">
                    <button type="button" class="nav-link active" id="lolos-interview-tab" data-bs-toggle="tab" data-bs-target="#lolos-interview" role="tab" aria-controls="lolos-interview" aria-selected="true">Lolos Interview</button>
                </li>
                <li class="nav-item" role="presentation">
                    <button type="button" class="nav-link" id="entry-form-tab" data-bs-toggle="tab" data-bs-target="#entry-form" role="tab" aria-controls="entry-form" aria-selected="false">Entry Form TTD</button>
                </li>
            </ul>

            <div class="tab-content" id="candidateTabsContent">
                <!-- Lolos Interview Tab -->
                <div class="tab-pane fade show active" id="lolos-interview" role="tabpanel" aria-labelledby="lolos-interview-tab">
                    <div class="panel datagrid easyui-fluid my-3 border border-danger table-responsive">
                        <table id="tableCandidate" class="easyui-datagrid" style="max-height:610px; min-height:610px; width:100%">
                            <thead>
                                <tr>
                                    <th width="30%" align="center" data-options="field:'fname', sortable:true">Nama</th>
                                    <th width="10%" align="center" data-options="field:'gender'">Jenis Kelamin</th>
                                    <th width="10%" align="center" data-options="field:'age', sortable:true">Usia</th>
                                    <th width="10%" align="center" data-options="field:'religion'">Agama</th>
                                    <th width="10%" align="center" data-options="field:'marital'">Pernikahan</th>
                                    <th width="20%" align="center" data-options="field:'education'">Pendidikan Terakhir</th>
                                    <th width="20%" align="center" data-options="field:'experience'">Pengalaman Kerja</th>
                                    <th width="20%" align="center" data-options="field:'note'">Catatan</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>

                <!-- Sudah TTD Entry Form Tab -->
                <div class="tab-pane fade" id="entry-form" role="tabpanel" aria-labelledby="entry-form-tab">
                    <div class="panel datagrid easyui-fluid my-3 border border-danger table-responsive">
                        <table id="signCandidate" class="easyui-datagrid" style="max-height:610px; min-height:610px; width:100%">
                            <thead>
                                <tr>
                                    <th width="30%" align="center" data-options="field:'fname', sortable:true">Nama</th>
                                    <th width="10%" align="center" data-options="field:'gender'">Jenis Kelamin</th>
                                    <th width="10%" align="center" data-options="field:'age', sortable:true">Usia</th>
                                    <th width="10%" align="center" data-options="field:'religion'">Agama</th>
                                    <th width="10%" align="center" data-options="field:'marital'">Pernikahan</th>
                                    <th width="20%" align="center" data-options="field:'education'">Pendidikan Terakhir</th>
                                    <th width="20%" align="center" data-options="field:'experience'">Pengalaman Kerja</th>
                                    <th width="20%" align="center" data-options="field:'note'">Catatan</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        // Initialize datagrid for showing candidates
        $(function() {
            $('#tableCandidate').datagrid({
                url: 'includes/display.php',
                singleSelect: true,
                remoteSort: true,
                rownumbers: true,
                pagination: true,
                pageSize: 10,
                nowrap: false,
                remoteFilter: true,
                onClickRow: onRowClick
            });

            $('#signCandidate').datagrid({
                url: 'includes/submit.php',
                singleSelect: true,
                remoteSort: true,
                rownumbers: true,
                pagination: true,
                pageSize: 10,
                nowrap: false,
                remoteFilter: true,
                onClickRow: onRowClick
            });
        });
        // Function to handle row click
        function onRowClick(index, row) {
            if (row.id) {  // Ensure the row has an id
                window.location.href = 'entry.php?id=' + row.id;
            } else {
                console.error("Row ID is missing.");
            }
        }
    </script>

the result when clicking the tabs is like this:
entry form ttd tab

but when i tried open the devtools, or zoom out/in the screen page, the table is showing:
entry form ttd tab when opening the devtools

I already tried timeout for the screen, changing the style, or using .datagrid(‘reload’) function, but it still not solve my problem.

Puppeteer Fails to Scrape Site with SSL Issue on Server (Works Locally)

I’m trying to scrape a site using Puppeteer, and while everything works fine on my local machine, I encounter SSL-related issues when I try to run the script on my server. I’ve tried several suggested solutions but haven’t found one that resolves the issue.

Here’s what I’ve done so far:

Downgraded Puppeteer to various older versions, as well as tried the latest version.
Tested Node versions: I’m currently using Node v20.17 and Puppeteer v23.3.0.
Verified the issue using curl -v , which shows the connection stalls after resolving the host but times out while connecting.

Here’s the curl output:

* Host registration.ec.ap.gov.in:443 was resolved.
* IPv6: (none)
* IPv4: 103.129.75.144
* Trying 103.129.75.144:443...
* Failed to connect to registration.ec.ap.gov.in port 443: Connection timed out

I’ve tried all the typical fixes for SSL issues, such as ignoring certificate errors in Puppeteer and experimenting with different Puppeteer and Node.js versions. However, the issue persists only on the server.

Does anyone know how to resolve or work around SSL-related issues specifically for Puppeteer on a server, or could you suggest any alternative solutions?

Error in the schema entry point webpack 5 multiple entry point

I was setting up a React project for a Chrome extension in which I needed more than one entry point and output in webpack, but I got an error when trying to configure more than one entry point in the webpack.config.js file. I have installed webpack 5.9, so according to the webpack documentation, this should work:

const path = require("path");

module.exports = {
    mode: "development",
    entry: {
        editor: './src/editor/editor.js',
        action: './src/action/action.js'
    }, // if we make this object just the first string "./src/editor/editor.js" the command npm build works
    output: {
        filename: '[name]/[name].js', // Simple output file for testing
        path: path.resolve(__dirname, "build"),
    },
    target: "web",
    devServer: {
        port: "3000",
        static: ["./build"],
        open: true,
        hot: true,
        liveReload: true,
    },
    resolve: {
        extensions: [".js", ".jsx", ".json", ".ts"],
    },
    module: {
        rules: [
            {
                test: /.(js|jsx)$/,
                exclude: /node_modules/,
                use: "babel-loader",
            },
        ],
    },
};

When I run the command npm run build (webpack .), the console throws this error:

“[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.

  • configuration.entry[0] should be a non-empty string.
    -> A module that is loaded upon startup. Only the last one is exported.”

what I am doing wrong?

my package.json file:

{
  "name": "task_mananger_ext",
  "version": "1.0.0",
  "description": "",
  "main": "./src/editor/editor.js",
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1",
    "start": "webpack-dev-server .",
    "build": "webpack ."
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.26.0",
    "@babel/eslint-parser": "^7.25.9",
    "@babel/plugin-transform-runtime": "^7.25.9",
    "@babel/preset-env": "^7.26.0",
    "@babel/preset-react": "^7.25.9",
    "@babel/runtime": "^7.26.0",
    "babel-eslint": "^10.1.0",
    "babel-loader": "^9.2.1",
    "webpack": "^5.96.1",
    "webpack-cli": "^5.1.4",
    "webpack-dev-server": "^5.1.0"
  },
  "dependencies": {
    "react": "^18.3.1",
    "react-dom": "^18.3.1"
  }
}

i upload all in a repository at :https://github.com/FrancoDoce12/task_mananger_ext

Thanks for any help in advance!

Checklist save to Firebase [closed]

I’m trying to create a checklist with fruits and the number of calories. Add up the total calories of the marked fruits.
Example:

Yes: 1 fruit = 10 calories
Yes: fruit 2 = 20 calories
No:  fruit 3 = 30 calories 
Total calories = 30 calories. 

The same list will appear for each user, but the checkboxes will be marked individually and stored in Firebase. In the end, I would like to rank the users with the highest amount of calories.

 Example: 
    1st Lady = 60 calories 
    2nd michael = 50 calories 
    3rd Katy = 30 calories.....

create a calorie calculator with ranking, using firebase

node-redis,docker,redis stack node-redis Socket closed unexpectedly but connected in python

I’m encountering an error in Node.js when using the RedisClient class, even though I only create the class instance once. The issue occurs only in Node.js, everything works fine when I use Python or the Redis Stack console.

For context:

  • I’m running Redis Stack in a Docker container on my local machine.
  • The same setup works perfectly on my production server (also running Redis Stack in a Docker container).

Any insights?


class RedisClient {
  private static instance: RedisClientType;
  client: RedisClientType;
  constructor() {
    if (!RedisClient.instance) {
      RedisClient.instance = createClient({
        url: ENDPOINT_REDIS,
        database: DB_REDIS,
        disableOfflineQueue: true,
        socket: {
          // timeout: 10000,
          // reconnectStrategy: (retries) =>
          //   Math.min(5000 * Math.pow(2, retries), 60000 * 60),
          tls: false,
        },
      });
      this.client = RedisClient.instance;
      this.connect();
    } else {
      this.client = RedisClient.instance;
    }
  }
  connect() {
    this.client.on("error", (err) => {
      console.log("Redis Client Error", err);
    });
    this.client.on("connect", () => {
      console.log("Redis Client Connected");
    });

    this.client.connect();
  }
}

new RedisClient()

Error

Redis Client Error SocketClosedUnexpectedlyError: Socket closed unexpectedly

JavaScript Pass a (new class) as a parameter

How do I pass a (new class) as a parameter to a button component without the function executing without click event is triggered.

class cDevice {
    new() { 
        //something here;
    }
}

device: {
    // the (new cDevice).new() is what I want to pass.
    createNew: function () { (new cDevice).new() }, 
}

This is the parameter will be used for, execute (new cDevice).new() when button click event is triggered.

"<button onclick=" + device.createNew + ">new</button>"

Thank you!

Can’t show information submitted on application

I made a shopping app. On views/index.ejs I can’t see the fake credit card information I submitted to a form. But I can view it on Mango. I get an error on the file stating, “ReferenceError: C:UsersThe XXXX FamilyDocumentsPeter’s Web ProjectsNODE_LOGIN|crud_shop_appindex.ejs:29” and “C:UsersThe XXXX FamilyDocumentsPeter’s Web ProjectsNODE_LOGIN|crud_shop_appviewsinclude_show.ejs:1” along with somewhere below that, “users is not defined”.

Anyone know the solution to my problem? I have my GitHub page of the code in a link if anyone’s interested in helping me out. Thanks in advance! text

I tried everything I could think of, but am too busy at the moment to try to figure out how to fix it. I would really appreciate help provided to me and would be open to learning about the fix to the problem.

I wanted to see the information, that I submitted, on the app’s page.

Though I got an error instead of my information displayed on the page. You can learn more about the error in my post.

Why doesn’t the ID of the button update when clicked multiple times in jQuery?

Good day! I’m working on dynamically changing the ID of a button when clicking other buttons. The scenario is as follows:

I have a search button (#searchButton) and three other buttons (#changeButton1, #changeButton2, #changeButton3).
When clicking any of the other buttons (#changeButton1, #changeButton2, or #changeButton3), I want to change the ID of the #searchButton to match the button clicked.
The issue I’m facing is that the ID of the #searchButton changes successfully the first time, but when I click another button (e.g., #changeButton2 or #changeButton3), the ID does not update, even though I can see the change in the Inspect Element (F12). The click handler for the #searchButton doesn’t seem to be triggered after the ID change.

<button id="searchButton" class="btn btn-primary">Search</button>
<button class="btn btn-secondary" id="changeButton1">Button 1</button>
<button class="btn btn-secondary" id="changeButton2">Button 2</button>
<button class="btn btn-secondary" id="changeButton3">Button 3</button>

<script>
$(document).ready(function() {
    $('#searchButton').on('click', handleSearchButtonClick);

    $('#changeButton1').on('click', function() {
        $('#searchButton').attr('id', 'searchButton1');
        console.log('ID changed to searchButton1');
    });

    $('#changeButton2').on('click', function() {
        $('#searchButton').attr('id', 'searchButton2');
        console.log('ID changed to searchButton2');
    });

    $('#changeButton3').on('click', function() {
        $('#searchButton').attr('id', 'searchButton3');
        console.log('ID changed to searchButton3');
    });
});
</script>

When I click #changeButton1, the ID of the #searchButton changes to searchButton1. But after that, when I click the other buttons, the ID of #searchButton doesn’t change, and the click event doesn’t seem to fire correctly.

How can I fix this so that the ID can be changed dynamically each time a button is clicked?

How can I add a small circle on a specific day if it has a data?

I’m currently working calendar using shadcn’s datepicker. What I’m trying to do is add a little circle under a name if the date has a value. I put an example date, just for to render it.


const events = [
  { date: new Date(2024, 10, 14), title: "Meeting" },
  { date: new Date(2024, 10, 15), title: "Lunch" },
  { date: new Date(2024, 10, 23), title: "Conference" },
]

const LeftCalendar = ({ date, setDate }: Props) => {

  const user = useCurrentUser()
  const [open, setOpen] = useState<boolean>(false);

  const openDialogBox = (currentDate: Date | undefined) => {
    if (currentDate) {
      setDate(currentDate);
      setOpen(true);

    } else {
      setDate(currentDate);
      setOpen(false);
    }
  };
  

  const hasEvent = (date: Date) => {
    return events.some(
      event => format(event.date, "yyyy-MM-dd") === format(date, "yyyy-MM-dd")
    )
  }


  return (

    <div className='flex flex-col  justify-center gap-y-2 h-full md:h-[800px]  relative'>
      <p className='text-lg text-left'> DATE TODAY: </p>
      <div className='flex flex-col'>
        <div className='w-full flex gap-x-2 p-4 rounded-full mb-8 border-2 text-xl font-semibold text-green-700'>
          <CalendarClock />
          <span className=''>{`${format(new Date(), 'MM/dd/yyyy')}`}</span>
        </div>


      </div>

      <div className='flex h-4/6 w-full items-center justify-center'>
        <Calendar
          mode="single"
          selected={date}
          onSelect={openDialogBox}
          //Change this according the user/ if admin, make
          //disabled={(date) => isBefore(new Date(date), startOfDay(new Date()))}
          disabled={user ? (date) => isBefore(new Date(date), startOfDay(new Date())) : (date) => new Date(date) <= new Date()}
  
          className="shadow-lg p-6 border rounded-md h-full w-full flex "
          classNames={{
            months:
              "flex w-full flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0 flex-1",
            month: "space-y-4 w-full flex flex-col",
            table: "w-full h-full border-collapse space-y-1",
            head_row: "",
            head_cell: 'text-primary w-9 font-semibold text-[0.8rem]   ',
            row: "w-full mt-2",
            caption_label: "text-2xl font-extrabold ",
            day: 'w-full font-semibold h-full',
          }}
          components={{
            Day: ({ date, ...props }) => {
              // Check if this date has an event
              const dateHasEvent = hasEvent(date)
              
              return (
                <div className="relative">
                  <button {...props} className={`${props.className} relative`}>
                    {format(date, "d")}
                  </button>
                  {dateHasEvent && (
                    <div className="absolute bottom-1 left-1/2 h-1 w-1 -translate-x-1/2 rounded-full bg-primary" />
                  )}
                </div>
              )
            }
          }}
        />
      </div>
      <CreateScheduleDialog open={open} setOpen={setOpen} pickedDate={date} />

    </div>

  )
}

export default LeftCalendar


enter image description here

Now the main problem I encounter using this code is I’m unable to select a specific day. The calendar will look like this if i remove the component under the classNames.

The reason I need this is because i have a state that will change a modal state.

enter image description here