Laravel Inertia React TypeError: this.resolveComponent is not a function

I have a laravel ap and I am trying to fetch some data from an external api and display this data with React.

There is a search field with a submit button and under this form a list of the results. When I press the search button the data gets fetched successfully from the external api but in my front end I can’t display the results my component stays empty. I think I’ve setup the routes wrong maybe? I think the issue is it tries to redirect to ‘/’ and that empties the results everytime ? Something is not correct there I think.

In my console I get this error after submitting:

Uncaught (in promise) TypeError: this.resolveComponent is not a function

My Kernel.php

class Kernel extends HttpKernel
{
    /**
     * The application's route middleware groups.
     *
     * @var array<string, array<int, class-string|string>>
     */
    protected $middlewareGroups = [
        'web' => [
            AppHttpMiddlewareHandleInertiaRequests::class,
        ],
    ];
}

Routes in web.php

Route::controller(LegoController::class)->group(function ()  {
    Route::get('/','index')->name('lego.index');
    Route::get('/searchParts','searchParts')->name('lego.searchParts');
});

LegoController.php

class LegoController extends Controller
{
    public function __construct(private LegoProvider $legoProvider)
    {
    }

    public function index()
    {
        return Inertia::render('Index');
    }

    public function searchParts(Request $request): Response
    {
        if (!$request->setNumber) {
            return Inertia::render('PartsList', ['parts' => Collection::make()]);
        }

        return Inertia::render('PartsList', ['parts' => $this->legoProvider->getPartsBySet($request->setNumber)]);
    }
}

Index.jsx

import React, { useState } from 'react';
import { router } from '@inertiajs/react'
import PartsList from "./PartsList.jsx";

const Index = () => {
    const [values, setValues] = useState({
        setNumber: "",
    });

    function handleChange(e) {
        const key = e.target.id;
        const value = e.target.value
        setValues(values => ({
            ...values,
            [key]: value,
        }))
    }

    function handleSubmit(e) {
        e.preventDefault()
        router.get('/searchParts', values)
    }

    return (
        <>
            <h1>Search parts by set number</h1>
            <hr/>
            <form onSubmit={handleSubmit}>
                <label htmlFor="setNumber">Set Number:</label>
                <input id="setNumber" value={values.setNumber} onChange={handleChange} />
                <button type="submit">Search</button>
            </form>

            <PartsList />
        </>
    )
}

export default Index

PartsList.jsx

import React, { useState } from 'react';

const PartsList = ({ parts }) => {
    return (
        <>
            <h1>Parts</h1>
            <hr/>
            { parts && parts.map( (part) => (
                <div key={part.id}>
                    <h2>{part.partName}</h2>
                    <a href={part.partUrl}>{part.partNumber}</a>
                </div>
            )) }
        </>
    )
}

export default PartsList

Inject JS code into cefsharp(inject youtube iframe)

I looked into lots of writing so I thought the code that I wrote should be working as well but it doesn’t. So I need help with finding out what is wrong with my code.

    private void Music_Control_JS(object sender, FrameLoadEndEventArgs e)
    {
        if (e.Frame.IsMain)
        {
            string url = e.Frame.Url;

            if (url.Contains("?autoplay=1"))
            {
                music_player.ExecuteScriptAsync(@"
                var tag = document.createElement('script');
                tag.src = 'https://www.youtube.com/iframe_api';
            ");
                music_player.ShowDevTools();
            }
        }
    }

so what I’m trying to do here is whenever music is played(“autoplay=1”) cefsharp will be loaded with youtube video and automatically play but in the meanwhile, I want to inject js code in to html. But it seems like it is not working. I check js is not injected using showdevtools.

what I’m trying to do using iframe api is to control youtube video using c# component(button, slider, etc)

RSA Implementation in React-JS

I have a backend in java-spring boot. I implemented RSA in Java in API call, such that every API request should be done with encrypted data and response should be decrypted . The java code is as:

public static String encrypt(String strToEncrypt){
   try {
        byte[] keyBytes = Files.readAllBytes(Paths.get(PUBLIC_KEY_FILE));
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
        PublicKey publicKey = keyFactory.generatePublic(keySpec);
        Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
        cipher.init(Cipher.ENCRYPT_MODE, publicKey);

        byte[] strBytes = strToEncrypt.getBytes("UTF-8");
        int inputLength = strBytes.length;
        int offset = 0;
        int maxBlockSize = 245;
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

        while (inputLength - offset > 0) {
            byte[] block;
            if (inputLength - offset > maxBlockSize) {
                block = cipher.doFinal(strBytes, offset, maxBlockSize);
            } else {
                block = cipher.doFinal(strBytes, offset, inputLength - offset);
            }
            outputStream.write(block, 0, block.length);
            offset += maxBlockSize;
        }

        byte[] encryptedBytes = outputStream.toByteArray();
        return Base64.getEncoder().encodeToString(encryptedBytes) + SUFFIX;
    } catch (Exception e) {
        System.out.println("Error encrypting string: " + e.getMessage());
        return strToEncrypt;
    }
}

public static String decrypt(String strToDecrypt) {
    try {
        if (strToDecrypt == null || strToDecrypt.isEmpty() || !strToDecrypt.endsWith(SUFFIX)) {
            return strToDecrypt;
        }
        strToDecrypt = strToDecrypt.replace(SUFFIX, "");

        byte[] keyBytes = Files.readAllBytes(Paths.get(PRIVATE_KEY_FILE));
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
        PrivateKey privateKey = keyFactory.generatePrivate(keySpec);

        Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
        cipher.init(Cipher.DECRYPT_MODE, privateKey);

        byte[] encryptedBytes = Base64.getDecoder().decode(strToDecrypt);
        int inputLength = encryptedBytes.length;
        int offset = 0;
        int maxBlockSize = 256;
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

        while (inputLength - offset > 0) {
            byte[] block;
            if (inputLength - offset > maxBlockSize) {
                block = cipher.doFinal(encryptedBytes, offset, maxBlockSize);
            } else {
                block = cipher.doFinal(encryptedBytes, offset, inputLength - offset);
            }
            outputStream.write(block, 0, block.length);
            offset += maxBlockSize;
        }

        byte[] decryptedBytes = outputStream.toByteArray();
        return new String(decryptedBytes, "UTF-8");
    } catch (Exception e) {
        System.out.println("Error decrypting string: " + e.getMessage());
        return strToDecrypt;
    }
}

`

How do I implement this in react? I have a two set of Key-Pair , How should i do it ? Is there any way to do with single pair of keys ? . Please explain and provide the react-js code.

How to Sanitize user provided input in javascript without any libraries like DOMpurify

I am using this following piece of code in my script.

var queryParams = new URLSearchParams(window.location.search);

when i ran codeql scanner it is showing warning at ‘window.location.search’ says below
“Cross-site scripting vulnerability due to user-provided value.”

i want to sanitize window.location.search but without any libraries as I don’t have enough permission to use libraries.

I am not sure how to sanitize, I tried but couldn’t find a proper solution.

Image is not rendering from the backend assert folder

I’m working on a movie recommendations web app, but I’m having trouble getting images from the backend to display on the frontend. When I directly use the image path, like this:

<img src={http://localhost:8000/images/Jailer.jpg} alt={item.movieName} />
I can see the image of “Jailer” from the backend. But when I comment that line out and instead use item.movieImage, like this:

<img src={http://localhost:8000/images/${item.movieImage}} alt={item.movieName} />
the image doesn’t render. In the tag, I’m seeing “Jailer.jpeg”, so I know the image path is correct. I’ve tried to debug this, but I can’t figure out why it’s not working. Could you please help me out?

I don’t know to do can anyone help me guys?

history.replaceState() causes user media video to became black on iOS 17

I have a case, when I need to update a browser’s URL while a user is streaming video from an iPhone. I update the URL like this.
window.history.replaceState(null, "", browserUrl);

On iOS 17 it causes a user media video to became black. See an attached video.
I can’t reproduce it on iOS 16.

Demo code: https://github.com/ivan-banha/safari-video-container-resize/commit/7197fb57e9758c81ff482fab7fe210bcf59f87b0

Demo link: https://ivan-banha.github.io/safari-video-container-resize

Demo video: https://github.com/ivan-banha/safari-video-container-resize/blob/main/assets/safari-replace-url-bug.mp4

STR:

  1. Open the link in mobile safari.
  2. Press the “share screen” button.
  3. When a video from a camera appears, press the “replace url” button.
  4. The video should become black.

Is this a bug in safari or expected behaviour?

Next js 14.1.4 npm run build issue like The “next export” command has been removed in favor of “output: export” in next.config.js

Hello i am new to front end next js deplyoment
currently, i have created one next js application with version 14.1.4
and to build deployment i am using this command
npm run build
but it is giving below error
The "next export" command has been removed in favor of "output: export" in next.config.js. Learn more: https://nextjs.org/docs/advanced-features/static-html-export

below is my next.config.js file can someone please help me to resolve this issue

/** @type {import('next').NextConfig} */
const nextConfig = {
    async rewrites() {
        return [{
            source: "/(t|T)(e|E)(x|X)(t|T)",
            destination: "/text"
        }]
    },
    images: {
        domains: [
            'naturalproduct.s3.amazonaws.com',
            'naturalproductproduction.s3.amazonaws.com',
            'naturalproductstaging.s3.amazonaws.com',
            'naturalproducttest.s3.amazonaws.com',
            'cdn-icons-png.flaticon.com',
            'static.vecteezy.com']
    },
    experimental: {
        missingSuspenseWithCSRBailout: false,
    },
    env: getEnvConfig()
}

module.exports = nextConfig

function getEnvConfig() {
    const dotenv = require('dotenv');

    const environment = process.env.TARGET_ENV || process.env.NODE_ENV;
    const envFilePath = `.env.${environment}`;

    try {
        const result = dotenv.config({ path: envFilePath });
        if (result.error) {
            throw result.error;
        }
        return result.parsed;
    } catch (err) {
        console.error(`Error loading environment variables from ${envFilePath}: ${err.message}`);
        return {};
    }
}

How can I capture integrated fingerprint data from an android tablet to my browser webapp?

I have a tablet with an inbuilt fingerprint scanner and I want to access the fingerprint data from the device into my NextJS app, I’ve been looking for libraries to do that but no luck.

However the device came with an android app that can access this features, but it is of no use to me as I need to capture users’ fingerprints directly in my webappPicture of device i am using and save them to my database.

I haven’t tried any workaround this issue as I dont even have any idea where to start. Although I have the SDK or source code for the app that works with this features and it’s written in Java.

Why cant I import this file into my code in JavaScript?

I tried to import a file into a code but the foulder could not be found.
However when i try to type the name of the folder out it already suggests me the folder and recognizes it as such.
I also already have tried out to write the entire path out but the result is the same.

I hope someone can find my rookie mistake.

I have provided a screenshot where the folder name and the error can be found

Best Regards.enter image description here
enter image description here

    import { Routes, Route } from "react-router-dom";
    import "./globals.css";
    import SigninForm from "./_auth/forms/SigninForm";
    import { Home } from "./_root/pages";
    import SignupForm from "./_auth/forms/SignupForm";
    import AuthLayout from "./_auth/AuthLayout";
    import RootLayout from "./_root";


    
    const App = () => {
    return (
    <main className="flex h-screen">
    <Routes>
     {/* public routes */}
     <Route element={<AuthLayout />}>

     
     <Route path= "sign-in" element ={<SigninForm />} />
     <Route path= "sign-up" element ={<SignupForm />} />
     </Route>
      {/* private routes */}
      <Route element={<RootLayout />}>

      <Route index element ={<Home />} />
      </Route>
      </Routes>
      </main>
      )
      }

      export default App

Configure DHIS2 to add Javascript

How can I customize DHIS2 to add javascript file to autocalculate form’s fields? Help me!

I tried to add autocalculate using GUI but seems GUI does not support that or maybe i just don’t know. if there is a way to do this without using javascript then, help me, if not help me on how to add the javascript file into dhis2.

How can I get waterpolo betting tips for a specific country using JavaScript?

I am a programmer looking to retrieve waterpolo betting tips for a specific country using JavaScript. I have found a resource that provides referees by country, but I am unsure how to use this information to get betting tips.

I have tried using the provided resource link with the country_id parameter, but I am not sure how to extract the betting tips data. I expected to receive a list of betting tips for the specified country, but I did not get the desired result.

const country_id = '123';
const url = `https://waterpolo.sportdevs.com/referees-by-country?country_id=eq.${country_id}`;

fetch(url)
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => console.error('Error:', error));

Update DOM in real time by JQuery (using AMCharts5) – need to find the best way to improve performance

I have a system that need to show logs of locations in real-time. My API returns 1000 rows per second and I need to show all rows in DOM. However, a row is added to table DOM every 50ms. Hence, I have a queue to store all objects that are waiting for displaying in DOM. Here is my queue array:

queue = [
  {"datetime": "20240429110000001", "id": "abc1", "country": "USA", "lat": "37.77777", "lng": "-122.5"},
  {"datetime": "20240429110000002", "id": "abc1", "country": "USA", "lat": "36.66666", "lng": "-120.5"},
  {"datetime": "20240429110000003", "id": "abc1", "country": "USA", "lat": "35.55555", "lng": "-118.5"},
  {"datetime": "20240429110000004", "id": "abc1", "country": "USA", "lat": "34.44444", "lng": "-116.5"}
]

And here is my table:

<thead>
  <tr>
    <th>Datetime</th>
    <th>ID</th>
    <th>Location</th>
    <th>Latitude</th>
    <th>Longitude</th>
  </tr>
</thead>
<tbody id="live-data">
  <tr id="item-0"></tr>
</tbody>

Each one is pushed between header row and the first row in tbody. When the table reaches 50 rows, the next row showing to DOM, it will remove the last row of table (meaning the oldest time). Here is my JQuery to insert row:

let preID = 0;
setInterval(() => {
  $(`
    <tr id="item-${queue[0].id}">
      <td>${queue[0].datetime}</td>
      <td>${queue[0].id}</td>
      <td>${queue[0].country}</td>
      <td>${queue[0].lat}</td>
      <td>${queue[0].lng}</td>
    </tr>
  `).insertBefore(`#item-${preID}`);
  preID = queue[0].id

  // Map update function (AMCharts5)
  mapUpdate(queue[0])

  queue.shift();
}, 50);

After updating, I use queue.shift() to remove the first element in queue. If there are 50 rows in table, I use the following code to remove the oldest row.

$(`#item-${oldestID}`).remove();

My problem is, this code is running smoothly after a minute or two (along with map update), but after that, DOM is updating slower and slower, and may get crashed at some points. So what should I need to improve the performance when updating DOM? Because this system must be run 24/24 hours.

Reponsive Grid MUI with order

I’m trying to achieve the following responsive Grid:

https://i.sstatic.net/ARfMpH8J.png

For desktop I’ve already set up the needed code:

         <Grid container spacing={2}>
          <Grid item sm={12} lg={6} order={{ sm: 2, lg: 1 }}>
            <Gallery
              images={product.images.map((image) => ({
                src: image.url,
                altText: image.altText
              }))}
            />
          </Grid>
          <Grid item sm={12} lg={6} container direction="column" order={{ sm: 1, lg: 2 }}>
            <Grid item>
              <ProductDescription product={product} />
            </Grid>
            <Grid item order={{ sm: 3, lg: 2 }}>
              <Typography variant="titolo-1">$99.99</Typography>
            </Grid>
          </Grid>
        </Grid>

My question has to do with the order of the items. On mobile the nested grid item container should not apply giving the possibility to order items like the attached image.
Is it possible to achieve without hiding and duplicating content?

how to put a custom close button in bootstrap modal

I’m working on a project where I need to create a Bootstrap modal with a close button positioned at the top right corner. While I’ve managed to position the button using CSS, it’s not quite sticking to one spot. Despite applying absolute positioning, the button seems to move around inconsistently. I’ve tried troubleshooting the issue by adjusting the CSS properties and inspecting the elements in the browser’s developer tools, but I haven’t been able to find a solution.

enter image description here

Html

 <div class="modal fade" id="POD__Modal" tabindex="-1" aria-labelledby="POD__ModalLabel" aria-hidden="true">
      <div id="modal__close" class="  sticky-top">
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-dialog">
        
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="POD__ModalLabel">Proof of delivery</h5>
            
            </div>
          <div class="modal-body">
            <figure class="zoom" onmousemove="zoom(event)" style="background-image: url(https://i.guim.co.uk/img/media/70a2fd5f5acddd683b892245209974fa4c768498/324_0_1429_858/master/1429.jpg?width=1200&height=1200&quality=85&auto=format&fit=crop&s=e2b8991e17e7bd966a29f5c706fe2552)">
              <img src="https://i.guim.co.uk/img/media/70a2fd5f5acddd683b892245209974fa4c768498/324_0_1429_858/master/1429.jpg?width=1200&height=1200&quality=85&auto=format&fit=crop&s=e2b8991e17e7bd966a29f5c706fe2552" />
            </figure>
          </div>
          
        </div>
      </div>
    </div>

CSS

/* POD Image Modal  */
#POD__Modal .modal-body {
  padding: 0px;
}

#POD__Modal .modal-header {
  justify-content: space-around;
  color: var(--primary-color);
}

#POD__Modal #modal__close {
  position: absolute;
  margin-right: auto;
  margin-left: auto;
  top: -0.1rem;
  right: 0rem;
  z-index: 999999;
  padding: 5px;
  border-radius: 50%;
  background-color: var(--secondary-color);
}
#POD__Modal .btn-close
{
  filter:  invert(1) grayscale(100%) brightness(300%) hue-rotate(180deg);
}

#POD__Modal .modal-content {
  border: 2px solid var(--secondary-color);
  border-radius: 1rem;
}

#POD__Modal .modal-body {
  border-bottom-left-radius: 1rem;
}

#POD__Modal figure.zoom {
  background-position: 50% 50%;
  position: relative;
  width: 100%;
  overflow: hidden;
  cursor: zoom-in;
}

#POD__Modal figure.zoom img:hover {
  opacity: 0;
}

#POD__Modal figure.zoom img {
  transition: opacity .5s;
  display: block;
  width: 100%;
 
}
#POD__Modal figure {
  border-bottom-left-radius: 1rem;
  border-bottom-right-radius: 1rem;
}

enter image description here