Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.portfolio/.MainActivity }

when I use npm start | npx react-native run-android command
then my terminal is freez in this line..

BUILD SUCCESSFUL in 52s
100 actionable tasks: 2 executed, 98 up-to-date
info Connecting to the development server…
8081
info Starting the app on “... IPaddress”…

Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.portfolio/.MainActivity }

  • i mean testing app is not installed (testing app is for developer not release APK)

i try this commands
npm start | npx react-native run-android

enter image description here

Updating array with useState in React

I am new to React and trying to figure out how to update state when a selection changes on an dropdown selection.

Here is my code:

page.js

import { useState } from 'react';
import SelectionRow from './selection-row';


export default function Home() {

  const [positions, setPositions] = useState([
    {id: 1, role : "Executive", selected_val: 2},
    {id: 2, role : "Director", selected_val: 1},
    {id: 3, role : "Manager", selected_val: 0},
    {id: 4, role : "Staff", selected_val: 0}]);

  function selectionChanged(e) {
    
  }

  return (
    <main>
      <form>
        {positions.map((position) => (
        <SelectionRow key={position.id} id={position.id} label={position.role} selected_val={position.selected_val} onSelectionChanged={selectionChanged}/>
        ))}
      </form>
    </main>
  )
}

selection-row.js

const options = [
    { id: 0, name: "David"}, 
    { id: 1, name: "Andrew"}, 
    { id: 2, name: "Steven"}, 
    { id: 3, name: "Simon"}, 
  ];

export default function SelectionRow({id, label, selected_val, onSelectionChanged}) {

    return (
        <div>
        <label>{label}</label>
        <select onChange={onSelectionChanged} value={selected_val} id={id} name={id}>
        {options.map((value) => (
          <option value={value.id} key={value.id}>
            {value.name}
          </option> ))}
        </select>
        </div>
    );
}

The sample application has an array of “company positions” that I want to populate with names chosen for a dropdown box for each. When the name is the dropdown box is changed, I want the selected_val in the positions array to be updated with id of the person selected.

Beyond passing a callback to the component, i’m unsure what I need to add in the selectionChanged function to update the positions array.

Accordin and get data from JSON

Getting data from Data.json doesn’t work
I don’t know how fix it and what is the problem

I want to make an Accordin and span of accordin must get head in json and p of accordin must get body in json

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
    <meta http-equiv="X-UA-Compatible"
        content="IE=edge"> 
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0"> 
    <!-- css -->
    <link rel="stylesheet" href="style.css"> 
    <!-- Fontawesome CDN link -->
    <link rel="stylesheet"
        href= 
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">   
</head> 
<body> 
    <div class="accordion">
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div> 
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div> 
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description">  
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description">  
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description">  
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description">  
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title">  
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                    What GeeksforGeeks offer us? 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description"> 
            </p> 
        </div>
        <div class="accordion-content"> 
            <header> 
                <span class="accordion-content-title"> 
                </span> 
                <i class="fa-solid fa-plus"></i> 
            </header> 
            <p class="accordion-content-description">  
            </p> 
        </div>
    </div>
    <script src="script.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</body> 
</html>

 const accordionContent = document.querySelectorAll(".accordion-content"); 

accordionContent.forEach((item,index)=>{ 
    let header = item.querySelector("header"); 
    header.addEventListener("click", ()=>{ 
        item.classList.toggle("is-open"); 

        let description = item.querySelector(".accordion-content-description"); 
        if(item.classList.contains("is-open")){ 
            // Scrollheight property return the height of 
            // an element including padding 
            description.style.height=`${description.scrollHeight}px`; 
            item.querySelector("i").classList.replace("fa-plus","fa-minus"); 
        }else{ 
            description.style.height = "0px"; 
            item.querySelector("i").classList.replace("fa-minus","fa-plus"); 
        } 
        // function to pass the index number of clicked header 
        removeOpenedContent(index); 
    }) 
}) 

function removeOpenedContent(index){ 
    accordionContent.forEach((item2,index2)=>{ 
        if(index != index2){ 
            item2.classList.remove("is-open"); 
            let descrip = item2.querySelector(".accordion-content-description"); 
            descrip.style.height="0px"; 
            item2.querySelector("i").classList.replace("fa-minus","fa-plus"); 
        } 
    }) 
}
$(document).ready(function(){
    // Fetch JSON data using Ajax
    $.ajax({
        url: 'Data.json',
        dataType: 'json',
        success: function(jsonData) {
            // Loop through the JSON data and create accordion sections
            jsonData.forEach(function(item) {
                var accordionItem = $('<div class="accordion-content">' +
                    '<header>' +
                    '<span class="accordion-content-title">' + item.head + '</span>' +
                    '<i class="fa-solid fa-plus"></i>' +
                    '</header>' +
                    '<p class="accordion-content-description">' + item.body + '</p>' +
                    '</div>');

                $('.accordion').append(accordionItem);
            });

            // Click event to toggle accordion sections
            $('.accordion-content header').click(function(){
                $(this).parent('.accordion-content').toggleClass('active');
            });
        },
        error: function(error) {
            console.error('Error fetching JSON data:', error);
        }
    });
});


Add multiple Prices in Stripe while adding discount to only one item

I have a problem, I want to charge two different prices while adding discount to only one of them.

The price where I want to add a discount is a subscription while the other one is one-time payment.

I am using ExpressJS with Typescript on my backend application.

I have searched a lot and found a few solutions but none were helpful for my case. I understand its a very specific case.

The only major thing that I have found was:

const subscription = await stripe.subscriptions.create({ customer: CUSTOMER_ID, items: [ { price: RECURRING_PRICE_ID, }, ], … add_invoice_items: [{ price: ONE_TIME_PRICE_ID, }] })

But if I add the discount it will be applied to both of the prices as stripe generates only 1 invoice for it.

Appreciaate your helpyour text

react YouTube player using

I’m trying to make a movie website using TMDB API. After listing the movies, I used Youtube npm to watch the trailers of the movies, but I cannot get any reaction.

const [selectedMovie, setSelectedMovie] = useState({});

  const fetchMovie = async (id) => {
    const { data } = await axios.get(`${API_URL}/movie/${id}`, {
      params: {
        api_key: MOVIE_API_KEY,
        append_to_response: "videos",
      },
    });
    return data;
  };

  const selectMovie = async (movie) => {
    const data = await fetchMovie(movie.id);
    // console.log("movie data", data);
    setSelectedMovie(movie);
  };

  const renderMovies = () =>
    movies.map((movie) => (
      <MovieCard key={movie.id} movie={movie} selectMovie={selectMovie} />
    ));

  const renderTrailer = () => {
    const trailer = selectedMovie.videos.results.find(
      vid => vid.name = 'Official Trailer'
    );

    return <YouTube videoId={trailer.key} />;
  };

HTML

{selectedMovie.videos ? renderTrailer() : null}

Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘parentNode’) – router.push({})

I have recently upgraded my dependencies and now every time I click on my button to navigate to the next page (and thus triggers router.push({ path: getBaseRoute("next-route") }) it throws the error Uncaught (in promise) TypeError: Cannot read properties of null (reading 'parentNode'). I understand what the error means, but logging the router, I notice router isn’t null. When I refresh the page however, the router succeeds in navigating me to the next page.

This is the part which causes the error:

    const router = useRouter();

    return await api
        .getByPostalCode(params)
        .then((response: PostalCodeResult) => {
            result.value = response;
            router.push({ path: getBaseRoute('next-route') });
        })
        .catch((error) => {
            return Promise.reject(error);
        });
}

Removing the router.push part, removes the error as well. Logging the flow I can confirm I also get in the then successfully.

Dependency versions I am running:

"vitest": "^1.0.4",
"nuxt": "^3.9.1",
"nuxt-vite": "^0.3.5",
"@pinia/nuxt": "^0.5.1",

if any other dependency version is required, please say so.

Issue with JavaScript Tip Calculator – Result not Displaying Correctly

I’m working on a tip calculator web application using HTML and JavaScript. The user inputs the bill amount, selects a service rating, and specifies the number of people splitting the bill. The application is designed to calculate the tip amount per person based on the given parameters.

<!DOCTYPE html>

<head>
    <style>
        *{
            margin: 0px auto;
            padding: 0;
            font-family: Helvetica, sans-serif;
        }
        body{
            background-color: #006600;
        }
        #main{
            margin-top: 50px;
            width: 300px;
            box-shadow: 5px 5px 7px black;
            border-radius: 10px;
        }
        #header{
            background-color: #001a00;
            color: white;
            text-align: center;
            height: 35px;
            line-height: 35px;
            border-radius: 10px 10px 0 0;
        }
        #form{
            background-color: #f7f7f7;
            display: flex;
            flex-direction: column;
            row-gap: 12px;
            padding: 15px;
            height: 360px;
            border-radius: 0 0 10px 10px;
        }
        #ocena{
            height: 40px;
        }
        input{
            height: 25px;
        }
        #button{
            background-color: #800000;
            color: white;
            width: 160px;
            margin: 10px auto;
            height: 40px;
            line-height: 40px;
            text-align: center;
        }
        #res{
            display: flex;
            flex-direction: column;
            visibility: hidden;
        }
        #res p:nth-child(1), #res p:nth-child(3){
            font-weight: bold;
        }
    </style>

    <script>
        function obl(kwota, ocena, osob){
            if( !kwota || !ocena ) {
                alert("Proszę uzupełnić pola!");
                return;
            }
            if( osob < 1 ) osob = 1;
            document.getElementById('wynik').innerHTML = (kwota * ocena / 100 / osob).toFixed() + ' zł';
            document.getElementById('res').style.visibility = 'visible';
        }
    </script>
</head>

<body>

    <div id="main">
        <p id="header">Kalkulator Napiwków</p>
        <div id="form">
            <p>Podaj kwotę rachunku</p>
            <div>
                <input type="number" name="kwota" id="kwota" placeholder="Kwota rachunku"><span> zł</span>
            </div>
            <p>Jak oceniasz obsługę?</p>
            <select name="ocena" id="ocena">
                <option value="" selected disabled>-- Wybierz z poniższych --</option>
                <option value="30">30% - wyróżniająca</option>
                <option value="20">20% - dobra</option>
                <option value="15">15% - średnia</option>
                <option value="10">10% - zła</option>
                <option value="5">5% - bardzo zła</option>
            </select>
            <p>Ile osób dzieli rachunek?</p>
            <input type="number" name="osob" id="osob" placeholder="Liczba osób płacących">
            <div id="button" onclick="obl(kwota.value, ocena.value, osob.value)">
                <p>OBLICZ</p>
            </div>
            <div id="res">
                <p>KWOTA NAPIWKU</p>
                <p id="wynik"></p>
                <p>każdy</p>
            </p>
        </div>
    </div>

</body>

The issue I’m facing is that the result is not displaying correctly. The JavaScript function obl(kwota, ocena, osob) is supposed to calculate the tip per person and display it, but the result is not showing up as expected.
In the JavaScript section, the function obl(kwota, ocena, osob) should calculate the tip amount per person and display it using the innerHTML property. However, the result is not showing up, and the visibility of the result div (#res) is set to hidden initially.

Unexpected behaviour in javascript async function with nested loops

I am creating a script to join multiple databases together.
It must check many variables like primary keys, data types etc..

I have an async function main that first of all gets the databases listed in postgresql, it then iterates over them (one-by-one is the intended behaviour) and create a pool.

For each db, it iterates over all the tables, then i populate an array of columns data-types for each table, and then iterate over each record and do my stuff.

The problem is the follow:
From my tests, this loop for (const table of tables.rows) does not wait its content before continuing,
so i am having some strange results (i.e. logging table name prints out 5 times before printing the columns array)

Should i use something like Promises or is there another solution to this problem?

async function main() {
    let databases = await getDatabases();

    // Iterates over each database
    for (const database of databases.rows) {
        const slave = new Pool({
            host: "localhost",
        user: "postgres",
        password: "postgres",
        port: 5432,
        database: dbname,
    });

        let tables = await getTables(slave);

        // Iterates over each table
        for (const table of tables.rows) {
            const tableName = table.tablename;
            let columnsData = await getColumns(slave, tableName);
            let columns = [];
            let insertQuery

            // Iterates over each column meta data
            for (columnData of columnsData.rows) {
        columns.push({
            name: columnData.column_name,
                type: columnData.data_type,
            });
        }


        let rows = await getTableData(slave, tableName);

            // Iterates over each record
        for (row of rows.rows) {
                let values = Object.values(row);
        let keys = Object.keys(row);

                // Iterates over each column of a record
                for (value of values) {
                    ...
                    ...
                }
        }

        await target.query(insertQuery);

        }
    }
}
async function getDatabases() {
    let databases = await target.query("SELECT datname FROM pg_database;");
    return databases;
}

async function getTables(pool) {
    let tables = await pool.query(
        "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';"
    );

    return tables;
}

async function getColumns(pool, tablename) {
    let columns = await pool.query(`SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = N'${tablename}'`);
    return columns;
}

async function getTableData(pool, tablename) {
    let data = await pool.query(`SELECT * FROM ${tablename}`);
    return data;
}

I tried to split the code in functions and awaiting for them, but it does not work.
I expect the code to execute for each table an insert statement of each row (move the data from a db to another with checks built in)

How to return value by id and not index in ramda?

So I have an array of objects with weekdays, it looks like this:

const weekDays = [
      {
        id: 1,
        name: 'monday'
      },
      {
        id: 2,
        name: 'tuesday'
      },
      {
        id: 3,
        name: 'wednesday'
      },
      {
        id: 4,
        name: 'thursday'
      },
      {
        id: 5,
        name: 'friday'
      },
      {
        id: 6,
        name: 'saturday'
      },
      {
        id: 7,
        name: 'sunday'
      }
    ]

And I have a function for formatting a day, it is used for displaying days in select component, it looks like this:

export const formatDay = flip(nth)(['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'])

So this function should return a day name by its id, for example if we pass 1 it should return monday etc., though currently it returns days by their index, so if we pass 1 it returns tuesday, though flip should’ve dealt with that problem

_ctx.function is not defined in vue

....
</v-container>
  <v-container v-else>
    <v-row>
      <v-col cols="12">
        <v-card flat>
          <v-card-title>{{ userDetails.name.givenName + ' ' + userDetails.name.familyName }}</v-card-title>
        </v-card>
      </v-col>
    </v-row>
.....
import {mapActions, mapState} from 'pinia';
import {userStatus} from '@/plugins/userHelper';
import Assigner from '@/components/Assigner';
import { useUserStore } from '../../stores/useUserStore';
import { useGroupStore } from '../../stores/useGroupStore';
import { useIndexStore } from '../../stores/useIndexStore';

    export default {
      name: 'UserDetails',
      components: { Assigner },
      data: () => ({
      //
      }),
      computed: {
        ...mapState(useIndexStore,[
        'isLoading'
       ]),
        ...mapState(useUserStore, [
          'userById',
          'userDetails'
       ]),
        ...mapState(useGroupStore, [
          'groups'
       ]),
....
   methods: {
    ...mapActions(useUserStore, [
      'getUserDetails',
      'saveUser',
      'modifyUser'
    ]),
    ...mapActions(useIndexStore, [
      'saveChanges',
      'setStatusDialog'
    ]), ....
    useUserStore
    export const useUserStore = defineStore("UserStore", {

    state: () => {
        return {
          users: [],
          userDetails: {},
          createUser: {},
        }
    },
        actions: {
          async getUsers() {
            await axiosInstance().get('api/admin/users')
            .then((response) => {
              this.users = response.data.users;
              console.log(this.users);
              });
        },
          async getUserDetails(userId) {
            await axiosInstance().get(`api/admin/user/${userId}`)
            .then((response) => {
           // commit('setUserDetails', response.data ? response.data : `error receiving data ${response.status}`);
          this.userDetails = response.data ? response.data : `error receiving data:          ${response.status}`;
          console.log("Details: " + JSON.stringify(this.userDetails));
          console.log(JSON.stringify(this.userDetails.name))
        });
     
    },.... 

    methods:{
      async beforeMount() {
      console.log("beforeMount"+this.$route.params.id)
      await this.getUserDetails(this.$route.params.id);
      },
     ....
    }

Hello dear people,

recently i had to switch from vuex to pinia, however some problems arose. The store inside my component is set up correctly as, when debugging, i see that i receive the wanted object and correct data and with set breakpoints that individual functions work correctly. Specifically <v-card-title>{{ userDetails.name.givenName + ' ' + userDetails.name.familyName }}</v-card-title> here i get an error that _ctx.userDetails.name is undefined which implies to me that at that time the object isn’t “there” yet. My question then would be why userDetails seems to be undefined at that point although it has been properly introduced by these map-functions? Or maybe i have a misconception about something. I’d be happy about some help.

As the “getUserDetails” function is async i tried to put a “v-if=userDetails.name” to stop it from erroring as i have seen in another thread but to no avail. Inside “computed” i have the user object, but as i already have the mapActions in place i changed every “user.” to “getUserDetails”. – no change.

How can I maintain the context in react while navigating to different page?

I’m facing an issue in my React application where I have multiple components, each with its own context using the useContext hook. I want to maintain the context for each component even if the URL changes.

I want to implement a behavior where, if I switch between tabs on a webpage and then navigate to another page through a link (e.g., ), the previously selected tab should remain active when I return to the original page(by back button of browser). Essentially, I am looking to maintain the state of the selected tab across page transitions.

Here is my code

Tab.js

import React, { useState, useCallback, createContext } from "react";

const TabContext = createContext({
  current: 0,
});

const Tab = ({ children }) => {
  const [current, setCurrent] = useState(0);

  const handleUpdateCurrent = useCallback((value) => {
    setCurrent(value);
  }, []);

  return (
    <TabContext.Provider value={{ current, handleUpdateCurrent }}>
      {children}
    </TabContext.Provider>
  );
};

export { Tab, TabContext };

TabListToggle.js


import React, { useContext } from "react";
import { TabContext } from "./Tab";

const TabListToggle = ({ data = [] }) => {

  const { current } = useContext(TabContext);
  const { handleUpdateCurrent } = useContext(TabContext);

  return (
    <div className="tabs-container">
      {data.map((value, index) => (
        <button
          key={index}
          onClick={() => handleUpdateCurrent(index)}
          className={`tab ${current === index ? "active" : ""}`}
          role="tab"
          aria-selected={current === index ? true : false}
        >
          <span>{value}</span>
        </button>
      ))}
    </div>
  );
};

export default TabListToggle;

Page1.js


import React from "react";
import { Link } from "react-router-dom";

import TabListToggle from "../components/TabListToggle";
import { Tab } from "../components/Tab";

const Page1 = () => {
  return (
    <div>
      <h1>Page1</h1>
      <Tab>
        <TabListToggle data={["Tab1", "Tab2","Tab3"]} />
        <div>
            <Link to="/page2/">Page2</Link>
        </div>
      </Tab>
    </div>
  );
};

export default Page1;

Page2.js

import React from "react";
import { Link } from "react-router-dom";
import TabListToggle from "../components/TabListToggle";
import { Tab } from "../components/Tab";

const Page2 = () => {
  return (
    <div>
      <h1>Page2</h1>
      <Tab>
        <TabListToggle data={["Tab1", "Tab2", "Tab3","Tab4"]} />
        <div>
        <Link to="/page1/">Page1</Link>
        </div>
      </Tab>
    </div>
  );
};

export default Page2;


App.js


const App = () => {
  const routeElement = useRoutes(routes);
  return routeElement;
  // return (
  //   <Tab>
  //     {routeElement}
  //   </Tab>
  // )
  
};

I tried to move Tab in app.js and remove the Tab component from the page1 and page2. This create a global state and changing one tab on one component changes the tab on the other pages which I dont want.

What am I doing wrong? Is it possible to achieve this using Context or i have to use localStorage ?

Please help.

How to store the value of telerik GridTemplateColumn in a JS variable

I am working on ASP.NET webforms. I am using Telerik GridTemplate to display the data from array.

I have inline c# code to manupulate the data and I want to store that data to js variable.

<telerik:GridTemplateColumn HeaderText="Doc Number">
     <ItemTemplate>
          <%# (Container.ItemIndex + (DGResult.CurrentPageIndex * DGResult.PageSize) + 1).ToString() %>
     </ItemTemplate>
</telerik:GridTemplateColumn>

Thanks in advance.

npm run start has something wrong

{
    "name": "webdiff",
    "version": "0.0.5",
    "scripts": {
        "start": "node ./bin/start",
        "build": "webpack --color --config webpack.config.js",
        "deploy": "npm run build && node writeHtml.js"
    },
    "dependencies": {
        "@babel/core": "^7.3.4",
        "@babel/preset-env": "^7.3.4",
        "antd": "^4.4.2",
        "classnames": "^2.2.6",
        "diff": "^4.0.2",
        "ejs": "^3.1.9",
        "express": "^4.16.4",
        "http-errors": "^1.6.2",
        "morgan": "^1.9.1",
        "react": "^16.8.3",
        "react-dom": "^16.8.3"
    },
    "devDependencies": {
        "@babel/plugin-proposal-class-properties": "^7.8.3",
        "@babel/plugin-proposal-optional-chaining": "^7.10.4",
        "@babel/plugin-transform-runtime": "^7.3.4",
        "@babel/preset-react": "^7.0.0",
        "babel-loader": "^8.0.6",
        "babel-plugin-import": "^1.13.0",`your text`
        "css-loader": "^6.9.0",
        "mini-css-extract-plugin": "^0.4.5",
        "source-map-loader": "^1.0.1",
        "webpack": "^5.0.0",
        "webpack-cli": "^3.2.3"
    }
}

enter image description here
enter image description here

it seems the webpack version is wrong but i dont know how to fix it, please help, thank you`

Show a coloumn of DataTable in Laravel

I am using DataTable to show data. I have a service like the one below.

Service

class HowtorentService
{
    use ResponseTrait;
    
    public function getAll()
    {
        $data = Howtorent::get();
        return $data;
    }

    public function getAllData()
    {
        $howtorents = $this->getAll();

        return datatables($howtorents)
            ->addColumn('url', function ($howtorent) {
                return  $howtorent->url;
            })
            ->addColumn('view', function ($howtorent) {
                return '<div>Hello</div>';
            })
            ->addColumn('action', function ($howtorent) {
                return '<div class="tbl-action-btns d-inline-flex">
                            <button type="button" class="p-1 tbl-action-btn viewdata" data-detailsurl="' . route('owner.safety.electric_safety.electric_details', $howtorent->id) . '" title="' . __('View') . '"><span class="iconify" data-icon="carbon:view-filled"></span></button>      
                            <button type="button" class="p-1 tbl-action-btn edit" data-detailsurl="' . route('owner.safety.boiler.boiler_details', $howtorent->id) . '" title="' . __('Edit') . '"><span class="iconify" data-icon="clarity:note-edit-solid"></span></button>  
                            <button onclick="deleteItem('' . route('owner.safety.boiler.destroy', $howtorent->id) . '', 'gassaftiesDatatable')" class="p-1 tbl-action-btn"   title="' . __('Delete') . '"><span class="iconify" data-icon="ep:delete-filled"></span></button>
                        </div>';
            })
            ->rawColumns(['view','action'])
            ->make(true);
    }
}

JavaScript

$('#howtorentDatatable').DataTable({
    processing: true,
    serverSide: true,
    pageLength: 25,
    responsive: true,
    ajax: $('#howToRentRoute').val(),
    order: [1, 'desc'],
    ordering: false,
    autoWidth: false,
    drawCallback: function () {
        $(".dataTables_length select").addClass("form-select form-select-sm");
    },
    language: {
        'paginate': {
            'previous': '<span class="iconify" data-icon="icons8:angle-left"></span>',
            'next': '<span class="iconify" data-icon="icons8:angle-right"></span>'
        }
    },
    columns: [
        {
            "data": "url",
        },
        {
            "data": "view",
        },
        {
            "data": "action",
        },
    ]
});

Blade

<table id="howtorentDatatable" class="table responsive theme-border p-20 ">
                                <thead>
                                    <tr>
                                        <th class="all">{{ __('URL') }}</th>
                                        <th class="all">{{ __('View') }}</th> 
                                        <th class="all">{{ __('Action') }}</th>
                                    </tr>
                                </thead>
                            </table>

But I can’t see any data of View Coloumn.