How to add a memo/note button for each item in a React JSON Schema Form array?

I’m building a form with React JSON Schema Form (RJSF) that contains arrays of items. I need to add a custom feature: a button next to each array item that, when clicked, displays an input field where users can enter a note/memo for that specific item.

For example, in my Authorization schema (which renders as an array of text areas for JWT tokens), I want each token field to have an associated “Add Note” button. When clicked, it should show an input field where users can add a memo about that specific token.

Here’s my current code:

import { RJSFSchema, UiSchema } from '@rjsf/utils';
import { Form as RjsfForm } from '@rjsf/antd';
import validator from '@rjsf/validator-ajv8';
import { App, Button, Tabs } from 'antd';
import { JSX, useEffect, useState } from 'react';

export interface AuthSchema {
  id: string;
  title?: string;
  schema: RJSFSchema;
  uiSchema?: UiSchema;
}

export interface RegisterExtractorOptions {
  authSchema?: AuthSchema[];
}

// Auth schema definition
const auth = {
  authSchema: [
    {
      id: 'authorization',
      title: 'Authorization',
      schema: {
        type: 'array',
        items: {
          type: 'string',
          pattern: '^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$',
        },
      },
      uiSchema: {
        items: {
          'ui:widget': 'textarea',
        },
      },
    },
    {
      id: 'account',
      title: 'Account',
      schema: {
        type: 'array',
        items: {
          type: 'object',
          properties: {
            username: {
              type: 'string',
              title: 'Username',
              minLength: 5,
              pattern: '^[a-z0-9]+$',
            },
            password: {
              type: 'string',
              title: 'Password',
              minLength: 8,
            },
          },
          required: ['username', 'password'],
        },
      },
      uiSchema: {
        items: {
          password: {
            'ui:widget': 'password',
          },
        },
      },
    },
  ]
};

interface AccountTabProps {
  source: SourceInfoClient;
}

function AccountTab({ source }: AccountTabProps): JSX.Element {
  return (
    <Tabs
      tabPosition={'right'}
      items={source.authSchema!.map((auth) => {
        return {
          key: auth.id,
          label: auth.title,
          children: <TabItem source={source} auth={auth} />,
        };
      })}
    />
  );
}

type TabItemProps = Pick<AccountTabProps, 'source'> & {
  auth: AuthSchema;
};

function TabItem({source, auth}: TabItemProps): JSX.Element{
  const [formData, setFormData] = useState();
  
  const handleSubmit = async (id: string, event: IChangeEvent): Promise<void> => {
    // save data to db
  };
  
  useEffect(() => {
    // Retrieve data from the database and set it in formData.
  }, [auth.id, source.id]);
  
  return (
    <RjsfForm
      formData={formData}
      focusOnFirstError={true}
      liveValidate={true}
      schema={auth.schema}
      uiSchema={auth.uiSchema}
      validator={validator}
      onSubmit={(e) => handleSubmit(auth.id, e)}
      showErrorList={false}
    />
  );
}

export default AccountTab;

I’m not sure how to:

  • Add a custom “Add Note” button for each array item
  • Display an input field when the button is clicked
  • Save the notes along with the form data
  • Associate each note with its specific array item

I’ve looked into custom field templates and widgets in RJSF, but I’m not sure how to implement this specific functionality. Should I modify the schema to include a note field, or is there a way to add custom UI elements outside the schema definition?

Deploy web on Render

I am trying to deploy my node web on Render service but I encountered an Error [ERR_MODULE_NOT_FOUND]: Cannot find package @vitejs/plugin-react imported from /opt/render/project/src/frontEnd/node_modules/.vite-temp/vite.config.js.timestamp-1742661308779-16638e4679c7.mjs

this issue can not find @vitejs/plugin-react but I have it in @vitejs/plugin-react”: “^4.3.4,

and this is my build command
scripts: { dev": "cross-env NODE_ENV=development nodemon backend/server.js, start": "cross-env NODE_ENV=production node backend/server.js", build": "npm install && npm install --prefix frontEnd && npm run build ---prefix frontEnd },
Project Structure

Vite project not running

I am trying to run a vite project and I am getting the error below based on the main.jsx file (which has also been attached)

import App from "./App.jsx";
import "./index.css";
import "bootstrap/dist/css/bootstrap.css";
import { Provider } from "react-redux";
import store from "./app/store.js";
import { createRoot } from "react-dom/client";

createRoot(document.getElementById("root")).render(
  <Provider store={store}>
    <App />
  </Provider>
);

Error:

Uncaught SyntaxError: The requested module ‘/node_modules/react-dom/client.js?v=21d72c5d’ does not provide an export named ‘createRoot’ (at main.jsx:6:10)

I was trying to render my React app, expecting it to showcase on the web yet that is the error that was displayed on the console

Output or log the vite rollup configuration?

When we create a vite project running npm run build will create the rollup javascript bundle.

However the command npm init vite@latest that we used to scaffold out the project does not create a rollup.config.js file.

Is there a way to output the default rollup configuration, so we can see what the settings used to create the bundle?

Why dark mode is still dependent on browsers theme?

I am trying to implement dark mode in my Next js project.

Here’s theme store

import { create } from "zustand";

export const useThemeStore = create((set) => {
  let storedTheme = localStorage.getItem("theme");

  if (!storedTheme) {
    const systemPrefersDark = window.matchMedia(
      "(prefers-color-scheme: dark)"
    ).matches;
    storedTheme = systemPrefersDark ? "dark" : "light";
    localStorage.setItem("theme", storedTheme);
    document.documentElement.classList.toggle(storedTheme);
  }


  return {
    theme: storedTheme,
    toggleTheme: () =>
      set((state: { theme: string }) => {
        const newTheme = state.theme === "light" ? "dark" : "light";
        document.documentElement.classList.toggle("dark", newTheme === "dark");
        localStorage.setItem("theme", newTheme);
        // alert("Theme changed to " + newTheme);
        return { theme: newTheme };
      }),
  };
});

Here’s my tailwind.config.ts

import type { Config } from "tailwindcss";

export default {
  content: [
    "./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
    "./src/components/**/*.{js,ts,jsx,tsx,mdx}",
    "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
  ],
  darkMode: "class", // Ensures dark mode works with manual toggle
  theme: {
    extend: {
      colors: {
        background: "var(--background)",
        foreground: "var(--foreground)",
      },
    },
  },
  plugins: [],
} satisfies Config;

Here is my toggle button

 <div className="sm:absolute  flex items-center gap-4 cursor-pointer">
          <Around
            toggled={theme === "dark"}
            onToggle={toggleTheme}
            className="h-full w-full text-3xl"
            duration={750}
          />
        </div>

Everything works as intended. Effectively maintains localstorage theme variable and applies “dark” class in html.
But the real problem is toggle button does not change theme. It is still dependent on browser’s theme.

How to Customize Video Player with Quality Selection (Using Node.js & EJS)?

Can anyone help me?

I want to customize a player like this:
Example Player

I use Node.js to get an M3U8 link and then pass it to anime.ejs in the sources variable.

server.js

res.render("anime", { animeData, sources });

Data passed to anime.ejs

[

{
“url”: “https://vault-14.kwikie.ru/stream/14/03/3ce25a73788d8dbf1420232be682f39b18d11533cd81d49cdba188b73c50e51b/uwu.m3u8”,
“isM3U8”: true,
“quality”: “SubsPlease · 360p”,
“isDub”: false
},
{
“url”: “https://vault-14.kwikie.ru/stream/14/03/891c61f3d388810669a19444f69eec108993f6ccff370c536603cf0e4dc7304c/uwu.m3u8”,
“isM3U8”: true,
“quality”: “SubsPlease · 720p”,
“isDub”: false
},
{
“url”: “https://vault-14.kwikie.ru/stream/14/03/e93f7997db52cf5ab666eaea58709e501fefc3494eaea65257ca13a99f510d5f/uwu.m3u8”,
“isM3U8”: true,
“quality”: “SubsPlease · 1080p”,
“isDub”: false
},
{
“url”: “https://vault-14.kwikie.ru/stream/14/04/fbb3d13e5f2d8f578a5835eea840f3e34d3e01ae6760ac71032d40a49459a62c/uwu.m3u8”,
“isM3U8”: true,
“quality”: “Yameii · 360p eng”,
“isDub”: true
},
{
“url”: “https://vault-14.kwikie.ru/stream/14/04/e56837232369912fa78dd9117e11239ccbcd18de26bfe1ea2d02161b5dc446fb/uwu.m3u8”,
“isM3U8”: true,
“quality”: “Yameii · 720p eng”,
“isDub”: true
},
{
“url”: “https://vault-14.kwikie.ru/stream/14/04/896052169f3a63b0b052502e4ffb0b7371bcf59a72998697c73dbf8927787754/uwu.m3u8”,
“isM3U8”: true,
“quality”: “Yameii · 1080p eng”,
“isDub”: true
}
]

anime.ejs

<div class="col-lg-6 videoplayer no_variable_height">
    <video id="video-player" controls width="640" height="360"
        poster="https://myproxy.com/proxy-image?url=<%= animeData.animePoster %>">
    </video>

    <select id="quality-selector"></select> <!-- Quality selection dropdown -->
</div>

anime.ejs javascript

document.addEventListener("DOMContentLoaded", () => {
    var player = videojs("video-player", {
        controls: true,
        autoplay: false,
        preload: "auto",
        fluid: true, // Makes it responsive
        controlBar: {
            volumePanel: { inline: false }, // Show volume controls
            pictureInPictureToggle: true, // Enable PiP
            fullscreenToggle: true
        }
    });

    // Add Quality Selector Plugin
    player.qualityLevels().on("addqualitylevel", function(event) {
        var qualityLevel = event.qualityLevel;
        qualityLevel.enabled = qualityLevel.height >= 720; // Enable HD by default
    });

    // Speed Control
    player.controlBar.addChild("PlaybackRateMenuButton", {});
});

Result:
Current Result

How do I use tsParticles Gradient Updater for color gradient animation?

I’m working on a text-based adventure game using JavaScript, and I thought it would be cool to integrate tsParticles for particle effects in the background. My goal is to create subtle animations where the particle link color changes in response to certain game events (like when the player is about to enter a new location). I also want to adjust other properties, like particle size and direction, based on these events.

For now, I’m starting with a simple color gradient animation for the particle links. When exploring the documentation, I found a folder called “Gradient Updater” which sounds like it could be exactly what I need. However, as a beginner in JavaScript, I’m struggling to figure out how to use it. The README doesn’t go into enough detail, and I’m not sure where to begin.

So, my questions are:

  1. How can I use the tsParticles Gradient Updater to create a color gradient animation for the particle links?

  2. Is there a simple function I can import and use to get started? If so, how can I use it?

  3. How should I set this up in my project, including importing and configuring it?

Here’s my GitHub repository with the project if it helps: GitHub Repository

Any guidance or code examples would be really appreciated!

Const variable changing unexpectedly

So I kinda have a guess as to why this is happening, but I still need help figuring out how to work around this. Im pretty sure the issue is because im using async functions and crypto.randomBytes.

Here’s where my function is being called:

logInForm.tsx

createUserSession(user[0]).then(sessionId => {
  localStorage.setItem('session-id', sessionId);
  console.log(sessionId);
})

And here’s the function:

export async function createUserSession(user: User): Promise<string> {
    const sessionId = crypto.randomBytes(512).toString('hex').normalize();
    try {
        redisClient.set(`session:${sessionId}`, user, {
            ex: SESSION_EXPIRATION
        })
        return sessionId
    } catch (error) {
        return ''
    }
}

So when I call the function, it sets the session in my redis db correctly; but then the localStorage that uses the same variable doesn’t return the correct sessionId. Thanks to anyone in advance; I tried looking for similar questions but I think its just too specific.

Having a problem with decomposing my code [closed]

I’m building a small budget app dashboard using React. Currently, I have a large MyNavbar.jsx file, and as I’m trying to break it into smaller, more manageable components, I’m feeling a bit lost. I need help organizing my code and splitting it properly without breaking things. I’m especially unsure about how to structure the app components and pass data between them.

Here’s the code I currently have:

App.js

import React from 'react';
import './App.css';
import MyNavbar from './components/navbar/MyNavbar';
import MyChart from './components/main/leftSide/MyChart';

function App() {
  return (
    <div className="App">
      <MyNavbar />
    </div>
  );
}

export default App;

MyNavbar.jsx

import React from 'react'
import { useState } from 'react'
import cl from './Navbar.module.css'
import transactions from '../../transactions.json'
import MyChart from '../main/left side/chart/MyChart'

const MyNavbar = () => {

    const [month, setMonth] = useState(0)

    const monthes = [
        { name: 'January 2023', value: 0, year: 2023, month: '01' },
        { name: 'February 2023', value: 1, year: 2023, month: '02' },
        { name: 'March 2023', value: 2, year: 2023, month: '03' },
        { name: 'April 2023', value: 3, year: 2023, month: '04' },
        { name: 'May 2023', value: 4, year: 2023, month: '05' },
        { name: 'June 2023', value: 5, year: 2023, month: '06' },
        { name: 'July 2023', value: 6, year: 2023, month: '07' },
        { name: 'August 2023', value: 7, year: 2023, month: '08' },
        { name: 'September 2023', value: 8, year: 2023, month: '09' },
        { name: 'October 2023', value: 9, year: 2023, month: 10 },
        { name: 'November 2023', value: 10, year: 2023, month: 11 },
        { name: 'December 2023', value: 11, year: 2023, month: 12 },
        { name: 'January 2024', value: 12, year: 2024, month: '01' },
        { name: 'February 2024', value: 13, year: 2024, month: '02' },
        { name: 'March 2024', value: 14, year: 2024, month: '03' },
        { name: 'April 2024', value: 15, year: 2024, month: '04' },
        { name: 'May 2024', value: 16, year: 2024, month: '05' },
        { name: 'June 2024', value: 17, year: 2024, month: '06' },
        { name: 'July 2024', value: 18, year: 2024, month: '07' },
        { name: 'August 2024', value: 19, year: 2024, month: '08' },
        { name: 'September 2024', value: 20, year: 2024, month: '09' },
        { name: 'October 2024', value: 21, year: 2024, month: 10 },
        { name: 'November 2024', value: 22, year: 2024, month: 11 },
        { name: 'December 2024', value: 23, year: 2024, month: 12 },
        { name: 'January 2025', value: 24, year: 2025, month: '01' },
    ]

    const allTransactions = transactions;

    let currentMonth = monthes[month].month;
    let currentYear = monthes[month].year;

    const currentDate = new RegExp(`^${currentYear}-${currentMonth}-\d{2}$`);
    console.log(currentDate)//getting the date that i should search payments from

    const matchedTransaction = allTransactions.filter(t => currentDate.test(t.date));
    console.log(matchedTransaction);//whole objects which pass through filter above

    let dataForChart =  [["Category", "Amount"], ...matchedTransaction.map(el => [el.category, el.amount])];//needs to be summed
    console.log(dataForChart);

    const dataForChartSummed = dataForChart.slice(1).reduce((acc, [category, amount]) => {
        acc[category] = (acc[category] || 0) + Math.round(amount)
        return acc
    }, {})
    console.log(dataForChartSummed)//ready for chart but not array

    const dataForChartSummedArray = Object.entries(dataForChartSummed).map(([category, amount]) => [category, amount])
    console.log(dataForChartSummedArray);

    const changeMonthUp = () => {
        if (month < monthes.length - 1) {
            setMonth(month + 1)
            console.log(month)

        } else {
            setMonth(0)
            console.log(month)
        }
    }

    const changeMonthDown = () => {
        if (month < monthes.length && month !== 0) {
            setMonth(month - 1)
            console.log(month)
        } else {
            setMonth(24)
            console.log(month)
        }
    }


    return (
        <div className={cl.header}>
            <div className={cl.inner_header}>
                <div className={cl.month_box}>
                    <h1>Month:</h1>
                </div>
                <ul className={cl.functionality}>
                    <span>
                        <li><button onClick={changeMonthDown}>back</button></li>
                    </span>
                    <span>
                        <li>
                            <h1>{monthes[month]
                                ? monthes[month].name
                                : 'error'
                            }</h1>
                        </li>
                    </span>
                    <span>
                        <li><button onClick={changeMonthUp}>further</button></li>
                    </span>
                </ul>
            </div>
            <div>
                <MyChart transactions={dataForChartSummedArray}/>
            </div>
        </div>
    )
}

export default MyNavbar

MyChart.jsx

import React from 'react';
import { Chart } from 'react-google-charts';

const MyChart = ({ transactions }) => {
  return (
    <div>
      <Chart
        chartType="PieChart"
        data={[['Category', 'Amount'], ...transactions]}
        options={{ title: 'All spendings for this month' }}
        legendToggle
      />
    </div>
  );
};

export default MyChart;

The Problem:

I want to organize my components better. Right now, everything is getting jumbled into one file (MyNavbar.js), and I’m not sure how to break it into logical components without breaking the functionality. My goal is to:

  • Have a component for the navbar (MyNavbar)
  • Have a component for the main content with a chart on the left and some items on the right
  • Have a footer
  • Have a SumOfItems component to show the total spending of the month

I’m trying to structure my app like this:

/src
  /components
    /navbar
      MyNavbar.jsx
    /main
      /leftSide
        MyChart.jsx
      /rightSide
        ItemsList.jsx
      MiddleOfPage.jsx
    /underparts
      SumOfItems.jsx
    /footer
      Footer.jsx
  App.js
  transactions.json
  App.css

What I need help with:

  1. How to structure my components and break down App.js properly.
  2. How to pass data down from parent components (like MyNavbar) to child components (like MyChart).
  3. Any best practices for managing state and props in this type of app.

My Goal:

I want to make sure that the logic in each component is clean and the app is structured well. I also want to be able to pass the required data between components while keeping the code maintainable and scalable.

Intl-tel-input format number

I need to display iti number (from iti.getNumber()) as normal human readable number (such as ‘+351920650120’ => ‘+351 920 650 120’)

i use vanilla js and tried using iti.getFormattedNumber() but it didn’t work. iti.getNumber(intlTelInputUtils.numberFormat.INTERNATIONAL) also doesn’t work.

with this i get the error ‘intlTelInputUtils is not defined’

    <script>
            document.addEventListener("DOMContentLoaded", (event) => {
                 const input = document.querySelector("#tel");
              const iti = window.intlTelInput(input, {
                  initialCountry: "auto",
                    strictMode: true,

                  geoIpLookup: callback => {
                fetch("https://ipapi.co/json")
                  .then(res => res.json())
                  .then(data => callback(data.country_code))
                  .catch(() => callback("pt"));
              },
                loadUtils: () => import("https://cdn.jsdelivr.net/npm/[email protected]/build/js/utils.js"),
              });
              
              
            iti.promise.then(() => {
                
               setTimeout(() => {
                  const formattedNumber = iti.getNumber(intlTelInputUtils.numberFormat.INTERNATIONAL);
                  console.log(formattedNumber);
                }, 100);
                
            });
             
            });
            </script>

Is it worth using generator functions as “scripts”? [closed]

The classic approach

function builderFunction(builder) {
  builder.add(thing1);
  builder.add(thing2);
  builderFunction2(builder);
}

The generator approach

function* builderFunction() {
  yield thing1;
  yield thing2;
  yield* builderFunction2();
}

Or another example

function configureRoutes(builder) {
  builder.route('app', builder => {
    builder.middleware(myMiddleware, builder => {
      builder.method('GET', indexHandler);
    })
    configureAssets(builder)
  })
  builder.method('GET', redirectToIndexHandler);
}
function* configureRoutes() {
  yield route('app', function*() {
    yield middleware(myMiddleware, function*() {
      yield method('GET', indexHandler);
    })
    yield* configureAssets()
  })
  yield method('GET', redirectToIndexHandler);
}

Does it worth it to define things that way? This is not opinion-based, but a concrete comparison of 2 methods. Is this only a preference, or these methods also have some differences?

My while loop on JavaScript isn’t re assigning a value back to its original variable

I am writing this JavaScript code using the while loop that asks a user for there age. I’ve written the code but it accepts me even after filling ages below 18. How shall I go about it.

I tried the code below and was expecting it to be in a loop as long as the age is below 18 but it didn’t work that way.

let age = Number(prompt("Please enter your age: "))

while(age<18){

console.log(prompt("You are too young"))
}

console.log("You can proceed")

Add horizontal line to React Native stacked bar chart (library undecided)

I’m looking to display data in a stacked bar chart of which there are a few options I have seen

However, I am then wanting to add a horizontal line atop the bars to show a user-defined target value.

For example, a user’s earnings from 3 revenue streams (shown in yellow, oragne and brown) over several months, where they have specified a target of $100 within a settings page.

enter image description here.

How would one go about this?

odoo18 how to fix js error in cart at step: fill address

In odoo18, after having purchased a product, at the second part of the cart: /shop/address
I get this error:

UncaughtPromiseError > TypeError

Uncaught Promise > input.parentElement is undefined

Occured on samadeva-oerp-staging-19206039.dev.odoo.com on 2025-03-22 20:42:35 GMT

TypeError: input.parentElement is undefined
    _getInputLabel@https://samadeva-oerp-staging-19206039.dev.odoo.com/web/assets/2/85f3901/web.assets_frontend_lazy.min.js:9093:446
    _markRequired@https://samadeva-oerp-staging-19206039.dev.odoo.com/web/assets/2/85f3901/web.assets_frontend_lazy.min.js:9094:6
    _changeCountry/<@https://samadeva-oerp-staging-19206039.dev.odoo.com/web/assets/2/85f3901/web.assets_frontend_lazy.min.js:9093:291
    _changeCountry@https://samadeva-oerp-staging-19206039.dev.odoo.com/web/assets/2/85f3901/web.assets_frontend_lazy.min.js:9093:264

The related code is located in Odoo18 nativ code : /addons/website_sale:

  • /address.js
  • /templates.xml

Does anyone know how to fix it please ?
enter image description here