Why does my react app reset completely (resetting all states to default values, clearing the console, etc)

Here’s my App component –

import Sidebar from "./components/Sidebar";
import { useState } from "react";
import Project from "./components/Project";
import CreateProject from "./components/CreateProject";
import HomePage from "./components/HomePage";

function App() {
  const [mainArea, setMainArea] = useState(undefined);
  const [projects, setProjects] = useState([]);
  function handleMainArea() {
    console.log(mainArea)
    return(
      <div id = "main-area">
        {
          mainArea  ?  <Project /> : <CreateProject onSaveProject = {handleSaveProject} onCancel = {handleCancel}/>
        }
      </div>
      );
  }
  function handleSaveProject(projectDetails) {
    console.log('here')
    setProjects((projects) => {
      let tempProjects = [...projects];
      tempProjects.push(projectDetails);
      return tempProjects;
    })
    //setMainArea(undefined)
  }
  function handleCancel() {
    setMainArea(undefined)
  }
  function handleAddProject() {
    setMainArea(false)
  }
  return (
    <>
      <Sidebar onAddProject={handleAddProject} projects={[...projects]} />
      {mainArea === undefined ? <HomePage /> : handleMainArea()}
    </>
  );
}

export default App;

Here’s my CreateProject component –

import { useRef } from "react"
export default function CreateProject({onSaveProject, onCancel}) {
    const titleRef = useRef();
    const descrRef = useRef();
    const dateRef = useRef();
    function onSubmit() {
        const projectDetails = {};
        projectDetails.title = titleRef.current.value;
        projectDetails.description = descrRef.current.value;
        projectDetails.date = dateRef.current.value;
        onSaveProject(projectDetails);
    }
    return(
        <form id="myform" >
            <div id = "buttonHeader">
                <button id = "cancel" onClick = {onCancel}>
                    Cancel
                </button> 
                <button id = "save" onClick = {onSubmit}>
                    Save
                </button>
            </div>
            <label>
                TITLE
            </label> <br></br>
            <input ref = {titleRef} type = "text" className = "input" id = "titleInput"></input> <br></br>
            <label>
                DESCRIPTION
            </label> <br></br>
            <textarea ref = {descrRef} type = "text" className = "input" id = "descriptionInput"></textarea> <br></br>
            <label>
                DUE DATE
            </label> <br></br>
            <input ref = {dateRef} type = "date" id = "dateInput"></input> <br></br>
            
        </form>
       
    )
}

When I click on AddProject button, the handleAddProject() is called, which sets the mainArea to false, and displays the CreateProject component, which is just a form.

Now, when I submit this form, the handleSaveProject function is called, which should update the state of projects and re-renders the page. But I am encountering a weird bug here, where my entire app is resetting, erasing all states, etc.

(This bug is solved if I just uncomment the setMainArea(undefined) in the handleSaveProject function. But I am trying to understand why it occurs in the first place)

Is there a way to tell my user how many tries they took in a guessing game?

I am working on a guessing game where Java holds a random number from 1-50. The user has unlimited tries, and will be told if they were too high or too low. Once they get it correct, I let them know and tell them how many tries they took. I just don’t know how to get the correct amount of tries without errors. And yes, this is an assignment so I would just like a little help without solving it for me completely.

I tried myGuess.length, which obviously wouldn’t work but I wanted it as a placeholder for now. I also tried holding a const or var and then placing it into the loop with increments, and calling it back. I actually didn’t expect it to work because I didn’t see the logic behind it. Also I am using Brackets.

`

React.js Refetch after deletion

I’m trying to make my webpage to refresh when a user deletes an album from a digital record collection. I’ve tried a few different options with no luck and cant seem to find out what the problem is. Here’s my code. I’d really appreciate any help! Some comments are from previous things I’ve tried.

import React from "react";
import { useState, useEffect } from "react";
import { Link } from "react-router-dom";4
import { useGetSingleCollectionQuery } from '../src/api/spinsapi'; 
import { fetchCollectionAlbumsById, fetchCollectionById, fetchSpotifyAlbumArt, deleteCollectionAlbum, deleteCollectionById} from "../fetching"
// import styles from "../index.css"; 
import { useNavigate} from "react-router-dom";
import { useParams } from "react-router-dom";


export default function SingleCollection ({token, setToken, spotifyToken}) {
  const { id } = useParams()
  const [error, setError] = useState(null)
  const backToCollections = useNavigate()
  const [albums, setAlbums] = useState([])
  const [collection, setCollection] = useState({})
  const nav = useNavigate()
  // const newCollectionPage = () => {
  //   const { isLoading, data, isError, error, isFetching } = useGetSingleCollectionQuery(
  //     'collections',
  //     fetchCollectionAlbumsById,
  //     {refetchOnMount: true,
  //     }
      
  //   )
  //   console.log({isLoading, isFetching})

  //   if (isLoading) {
  //     return <h1>Loading...</h1>
  //   }
  //   if (isError) {
  //     return <h2>error.message</h2>
  //   }
  // }
  // // const [reducerValue, forceUpdate] = useReducer(x => x + 1, 0);

  useEffect(() => {
    async function fetchCollection() {
      let res = await fetchCollectionAlbumsById(id)
      const coll_res = await fetchCollectionById(id)
      setCollection(coll_res)
      console.log(coll_res)
      async function fetchArt(albs) {
        await albs.forEach(async (album) => {
          let url = await fetchSpotifyAlbumArt(album.title, album.artist, spotifyToken)
          album.imgUrl = url
          albums.push(album)
        })
      }
      fetchArt(res)
      console.log(res)
    }

    fetchCollection()
  }, [])

async function removeAlbum(album_id) {
    let removedAlbum = await deleteCollectionAlbum(album_id, token, id)
    console.log(removedAlbum)
    // refetch();
  }

async function deleteCollection() {
  let deletedCollection = await deleteCollectionById(id, token)
  nav('/collections')

}

return (
  <>
  <div key={id} className="singleCollection column">
    <h1>{collection.name}</h1>
    <div className="all-albums-container">
      {albums.map((album) => {
        console.log(album.imgUrl)
        return (
        <ul key={album.id} className="album-card">
          <Link to={`/albums/${album.id}`}><img src={album.imgUrl} alt={album.title} /></Link>
            <li>{album.title} </li> 
            <li>{album.artist}</li> 
             <button onClick={() => removeAlbum(album.id)}>Remove</button>
        </ul>)
      })}
    </div>
  </div>
        <button onClick={() => deleteCollection()}>Delete Collection</button>
        <button onClick={() => backToCollections('/collections')}>Return To Collections</button>
  </>
  );
  }

Everything I’ve tried putting something in the dependency array within useEffect so it’s updated on that change too, but I may have been putting the wrong call in there.

Customizing the appearance of Stripe Payment Element in React

I am currently using the Stripe Payment Element in my React application with the following code:

import { useStripe, useElements, PaymentElement, } from '@stripe/react-stripe-js'

export const PaymentDetails = () => {
  const stripe = useStripe()
  const elements = useElements()

  const paymentElementOptions = {
    layout: 'tabs',
    paymentMethodOrder: ['card']
  }

  return (
    <div className="mb-4">
      <PaymentElement
        id="payment-element"
        options={paymentElementOptions}
      />
    </div>
  )
}

I want to customize the appearance of this payment element align with the theme of my application, specifically changing the colorText for the labels above input fields.

I have reviewed the Stripe documentation, however I wasn’t able to amend the appearance of the payment element.

Any help would be appreciated. Thanks!

Issue setting values in 2d Array – JS

I am trying to set values of a 2d array at the specific index.

Each iteration is setting all contained arrays at the j index to the variable(number).

inputTensor dimensions 140x7 - 140 arrays of 7 
inputMinArray dimensions 1x7 - 1 array of 7 
inputMaxArray dimensions 1x7 - 1 array of 7 

  var transformedInputTensor = new Array(inputTensor.length).fill(new Array(inputTensor[0].length))
  for(let i = 0; i< inputTensor.length; i++){
    for(let j = 0; j< inputTensor[0].length; j++ ){
      number = scale(inputTensor[i][j], inputMinArray[j],inputMaxArray[j], outMin, outMax);
      transformedInputTensor[i][j] = number;
    }
  }

The function scale() only returns a single value.

Everything works as expected, except transformedInputTensor[i][j] = number;.

Have I missed something very simple or any suggestions? – Thank You

Create-react-app won’t provide template despite react being up to date

I’ve tried to create a new react directory with npx create-react-app and with every solution I’ve tried, the template was not provided with the recommended reasoning being that I might be using an outdated version of create-react-app.

I’ve checked what version of React is being downloaded and it up to date (18.2.0).

I’ve cleared the cache in my directory, uninstalled create-react-app globally multiple times, checked in my ‘~/users/name’ directory to manually delete it. I installed with both npx create-react-app@latest and without @latest.

Installing react, react-dom, and react-scripts...

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@eslint-community/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@eslint/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@eslint/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@typescript-eslint/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@typescript-eslint/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0', npm: '>=6' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@typescript-eslint/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@typescript-eslint/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@typescript-eslint/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '>=14.17' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@typescript-eslint/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@typescript-eslint/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@typescript-eslint/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@typescript-eslint/[email protected]',
npm WARN EBADENGINE   required: { node: '^12.22.0 || ^14.17.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '>=16 || 14 >=14.17' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '>=16 || 14 >=14.17' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '>=16 || 14 >=14.17' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '>=16 || 14 >=14.17' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '>=16 || 14 >=14.17' },
npm WARN EBADENGINE   current: { node: 'v14.15.5', npm: '8.10.0' }
npm WARN EBADENGINE }
npm WARN deprecated [email protected]: Please use @jridgewell/sourcemap-codec instead
npm WARN deprecated [email protected]: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
npm WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated [email protected]: [email protected]
npm WARN deprecated [email protected]: Use your platform's native performance.now() and performance.timeOrigin.
npm WARN deprecated [email protected]: Use your platform's native DOMException instead
npm WARN deprecated [email protected]: Use your platform's native atob() and btoa() methods instead
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead.
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
npm WARN deprecated [email protected]: This SVGO version is no longer supported. Upgrade to v2.x.x.

added 1484 packages, and audited 1485 packages in 2m

250 packages are looking for funding
  run `npm fund` for details

8 vulnerabilities (2 moderate, 6 high)

partial package.json:

{
  "name": "client",
  "version": "0.1.0",
  "lockfileVersion": 2,
  "requires": true,
  "packages": {
    "": {
      "name": "client",
      "version": "0.1.0",
      "dependencies": {
        "react": "18.2.0",
        "react-dom": "18.2.0",
        "react-scripts": "5.0.1"
      }
    }

Uncaught Error: Call to a member function close() on null and Undefined variable

PHP Warning: Undefined variable $con in /home/bdlotter/public_html/gamerbazi/AdminPanel/APIs/index.php on line 730
PHP Fatal error: Uncaught Error: Call to a member function close() on null in /home/bdlotter/public_html/gamerbazi/AdminPanel/APIs/index.php:730
Stack trace:
thrown in /home/bdlotter/public_html/gamerbazi/AdminPanel/APIs/index.php on line 730

I Can’t Understand What Can I Do. My Full Code Is here

real_escape_string($_POST[‘username’]);
$getPassword = $con->real_escape_string($_POST[‘password’]);

$users = new Users( $con );
$response = array();

if($getUsername == ‘admin’ && $getPassword == ‘123456’){
$response[‘status’] = 1;
$response[‘msg’] = “Success”;
$_SESSION[‘userName’] = “Admin”;
$_SESSION[‘mainId’] = “1”;
}
else{
$response[‘status’] = 0;
$response[‘msg’] = “Failed”;
}

echo json_encode($response);

// Create Object
//echo $users->loginUser( $getUsername, $getPassword);
}

else if ($from == ‘get_users’){

$userId = $con->real_escape_string($_POST[‘user_id’]);
$type = $con->real_escape_string($_POST[‘type’]);

// how many rows
$draw = $con->real_escape_string($_POST[‘draw’]);
// start of
$startPosition = $con->real_escape_string($_POST[‘start’]);
// how many rows
$rowPerPage = $con->real_escape_string($_POST[‘length’]);
// Column index
$columnIndex = $con->real_escape_string($_POST[‘order’][0][‘column’]);
// Column name
$columnName = $con->real_escape_string($_POST[‘columns’][$columnIndex][‘data’]);
// asc or desc
$columnSortOrder = $con->real_escape_string($_POST[‘order’][0][‘dir’]);
// Search value
$searchValue = $con->real_escape_string($_POST[‘search’][‘value’]);

// Create Object
$getSearchRows = new getSearchRows( $con );

// set column names to search or filter into
$getSearchRows->setSearchColumns( “id, register_date, login_date, email, mobile, fullname, referral_code” );

// set sql WHERE condition
if($type != ”){
$currentDate = date(‘Y-m-d’);
$yesterdayDate = date(‘Y-m-d’, strtotime(‘-1 day’, strtotime($currentDate)));

if($type == ‘today_login’){
$getSearchRows->getSelectCondition(“login_date LIKE ‘%”.$currentDate.”%'”);
}
else if($type == ‘yesterday_login’){
$getSearchRows->getSelectCondition(“login_date LIKE ‘%”.$yesterdayDate.”%'”);
}
}
else if($userId != ”){
$getSearchRows->getSelectCondition(“id=”.$userId);
}

// ADD INNER JOINS
//$getSearchRows->addInnerJoin(“INNER JOIN (SELECT id AS sponsorId, fullname AS sponsor FROM users LIMIT 1) AS userData” );
//$getSearchRows->setInnerJoinONCondition(” ON (users.sponsor_id = ‘0’ OR userData.sponsorId = users.sponsor_id)”);

// set select column names
$getSearchRows->setSelectColumns(“*”);

// set objects which needs in get_search_rows
//$getSearchRows->setObjects( array( $admins, $courses, $batches, $users ) );

//set table name which from get data
$getSearchRows->setTableName( “users” );

// for use as a condition in additionalData function in getSearchRows class
$getSearchRows->setFrom( “users” );

echo $getSearchRows->getSearchData( $draw, $startPosition, $rowPerPage, $columnIndex, $columnName, $columnSortOrder, $searchValue );

}

else if ($from == ‘get_tournaments’){

// get type
$type = $_SESSION[‘tournament_type’];

// how many rows
$draw = $con->real_escape_string($_POST[‘draw’]);
// start of
$startPosition = $con->real_escape_string($_POST[‘start’]);
// how many rows
$rowPerPage = $con->real_escape_string($_POST[‘length’]);
// Column index
$columnIndex = $con->real_escape_string($_POST[‘order’][0][‘column’]);
// Column name
$columnName = $con->real_escape_string($_POST[‘columns’][$columnIndex][‘data’]);
// asc or desc
$columnSortOrder = $con->real_escape_string($_POST[‘order’][0][‘dir’]);
// Search value
$searchValue = $con->real_escape_string($_POST[‘search’][‘value’]);

// Create Object
$getSearchRows = new getSearchRows( $con );

// set column names to search or filter into
$getSearchRows->setSearchColumns( “id,name,entry_fees,prize_pool, total_players,map,type,mode,gameName”);

$condition = “”;

if($type == ‘ongoing’){
$condition = ” status = ‘available’ AND is_live = ‘1’”;
}
else if($type == ‘results’){
$condition = ” status = ‘completed'”;
}
else if($type == ‘upcoming’){
$condition = ” status = ‘available’ AND is_live = ‘0’”;
}

// set sql WHERE condition
$getSearchRows->getSelectCondition($condition);

// ADD INNER JOINS
$getSearchRows->addInnerJoin(“INNER JOIN (SELECT id AS gameId, name AS gameName FROM games) AS gameData” );
$getSearchRows->setInnerJoinONCondition(” ON (tournaments.game_id = gameData.gameId) “);

// set select column names
$getSearchRows->setSelectColumns(“*”);

// set objects which needs in get_search_rows
//$getSearchRows->setObjects( array( $admins, $courses, $batches, $users ) );

//set table name which from get data
$getSearchRows->setTableName( “tournaments” );

// for use as a condition in additionalData function in getSearchRows class
$getSearchRows->setFrom( “tournaments” );

echo $getSearchRows->getSearchData( $draw, $startPosition, $rowPerPage, $columnIndex, $columnName, $columnSortOrder, $searchValue );

}

else if($from == ‘get_joined_players’){

$tournamentId = $con->real_escape_string($_POST[‘tournament_id’]);
$getType = $con->real_escape_string($_POST[‘type’]);

// creating Objects
$tournaments = new Tournaments($con);

echo $tournaments->getJoinedPlayers(true, $tournamentId, $getType);
}

else if($from == ‘remove_joined_user’){

$tournamentId = $con->real_escape_string($_POST[‘tournament_id’]);
$userId = $con->real_escape_string($_POST[‘user_id’]);
$message = $con->real_escape_string($_POST[‘message’]);
$type = $con->real_escape_string($_POST[‘type’]);

// creating Objects
$tournaments = new Tournaments($con);

echo $tournaments->removeJoinedUser($tournamentId, $userId, $type, $message);
}

else if($from == ‘update_details’){

$response = array();

$tournamentId = $con->real_escape_string($_POST[‘tournament_id’]);
$details = $con->real_escape_string(str_replace(“‘”, “”, $_POST[‘details’]));

$tournamentDetails = explode(“,”, $details);

$updateTournament = “UPDATE tournaments SET details = ‘”.json_encode($tournamentDetails).”‘ WHERE id = ‘$tournamentId'”;

if($con->query($updateTournament)){
$response[‘status’] = 1;
$response[‘msg’] = “Updated”;
}
else{
$response[‘status’] = 0;
$response[‘msg’] = “Failed”;
}

echo json_encode($response);
}

else if ( $from == ‘change_user_status’ ) {

$response = array();

$userId = $con->real_escape_string($_POST[‘user_id’]);

$selectUser = “SELECT status FROM users WHERE id = ‘$userId'”;
$usersResults = $con->query($selectUser);
$userRows = $usersResults->fetch_assoc();

$updateUser = “UPDATE users SET status = ‘1’ WHERE id = ‘$userId'”;
if($userRows[‘status’] == 1){
$updateUser = “UPDATE users SET status = ‘0’ WHERE id = ‘$userId'”;
}

if($con->query($updateUser)){
$response[‘status’] = 1;
$response[‘msg’] = “Updated”;
}
else{
$response[‘status’] = 0;
$response[‘msg’] = “Failed”;
}

echo json_encode($response);
}

else if ( $from == ‘add_new_tournament’ ) {

$response = array();

$getGameId = $con->real_escape_string($_POST[‘t_game_id’]);
$getTitle = $con->real_escape_string(str_replace(“‘”, “”, $_POST[‘t_title’]));
$getImage = $_FILES[‘t_image’];
$getMap = $con->real_escape_string($_POST[‘t_map’]);
$getType = $con->real_escape_string($_POST[‘t_type’]);
$getMode = $con->real_escape_string($_POST[‘t_mode’]);
$getEntryFees = $con->real_escape_string($_POST[‘t_entry_fees’]);
$getPrizePool = $con->real_escape_string($_POST[‘t_prize_pool’]);
$getPerKill = $con->real_escape_string($_POST[‘t_per_kill’]);
$getFromBonus = $con->real_escape_string($_POST[‘t_from_bonus’]);
$getTotalPlayers = $con->real_escape_string($_POST[‘t_total_players’]);
$getPrizeCount = $con->real_escape_string($_POST[‘prizes_count’]);
$getSchedule = $con->real_escape_string($_POST[‘t_schedule’]);
$getDetails = $con->real_escape_string(str_replace(“‘”, “”, $_POST[‘t_details’]));

$prizeDistributions = array();

for($i = 1; $i setPostName(“t_image”);

if ( !empty( $getImage[‘tmp_name’] ) ) {
$filePath = “TournamentImages”;
if (!file_exists($filePath)) {
mkdir($filePath, 0755, true);
}
$uploadStatus = $uploadFile->uploadFile( $filePath, $getImage );

if ( $uploadStatus[‘status’] == true ) {
$actualFilePath = $uploadStatus[‘filepath’];
$actualFilePath = $pathh.””.$actualFilePath; // creating url of image file

$response = $tournaments->addNewTournament($getGameId, $getTitle, $actualFilePath, $getMap, $getType, $getMode, $getEntryFees, $getPrizePool, $getPerKill, $getFromBonus, $getTotalPlayers, $prizeDistributions, $getSchedule, $getDetails);
}
else{
$response[‘status’] = 0;
$response[‘msg’] = $uploadStatus[‘msg’];
}
}
else{
$response[‘status’] = 0;
$response[‘msg’] = “Unable to get Tournament Image”;
}

echo json_encode($response);
}

else if ( $from == ‘update_tournament’ ) {

$response = array();

$getTournamentId = $con->real_escape_string($_POST[‘tournament_id’]);
$getGameId = $con->real_escape_string($_POST[‘t_game_id’]);
$getTitle = $con->real_escape_string($_POST[‘t_title’]);
$getImage = $_FILES[‘t_image’];
$getMap = $con->real_escape_string($_POST[‘t_map’]);
$getType = $con->real_escape_string($_POST[‘t_type’]);
$getMode = $con->real_escape_string($_POST[‘t_mode’]);
$getEntryFees = $con->real_escape_string($_POST[‘t_entry_fees’]);
$getPrizePool = $con->real_escape_string($_POST[‘t_prize_pool’]);
$getPerKill = $con->real_escape_string($_POST[‘t_per_kill’]);
$getFromBonus = $con->real_escape_string($_POST[‘t_from_bonus’]);
$getTotalPlayers = $con->real_escape_string($_POST[‘t_total_players’]);
$getPrizeCount = $con->real_escape_string($_POST[‘prizes_count’]);
$getSchedule = $con->real_escape_string($_POST[‘t_schedule’]);
$getDetails = $con->real_escape_string(str_replace(“‘”, “”, $_POST[‘t_details’]));

$prizeDistributions = array();

for($i = 1; $i setPostName(“t_image”);

$actualFilePath = $_POST[‘old_image’];

if ( !empty( $getImage[‘tmp_name’] ) ) {
$filePath = “TournamentImages”;
$uploadStatus = $uploadFile->uploadFile( $filePath, $getImage );

if ( $uploadStatus[‘status’] == true ) {
$actualFilePath = $uploadStatus[‘filepath’];
$actualFilePath = $pathh.””.$actualFilePath; // creating url of image file
}
}

$response = $tournaments->updateTournament($getTournamentId, $getGameId, $getTitle, $actualFilePath, $getMap, $getType, $getMode, $getEntryFees, $getPrizePool, $getPerKill, $getFromBonus, $getTotalPlayers, $prizeDistributions, $getSchedule, $getDetails);

echo json_encode($response);
}

else if($from == ‘cancel_tournament’){

$getTournamentId = $con->real_escape_string($_POST[‘tournament_id’]);
$reason = $con->real_escape_string(str_replace(“‘”, “”, $_POST[‘reason’]));

// creating Objects
$tournaments = new Tournaments($con);

echo $tournaments->cancelTournament($getTournamentId, $reason);
}

else if($from == ‘send_room_id’){

$getTournamentId = $con->real_escape_string($_POST[‘tournament_id’]);
$getRoomId = $con->real_escape_string($_POST[‘room_id’]);
$getMessage = $con->real_escape_string(str_replace(“‘”, “”, $_POST[‘message’]));
$getYouTubeLink = $con->real_escape_string($_POST[‘youtube’]);

// creating Objects
$tournaments = new Tournaments($con);

echo $tournaments->sendRoomId($getTournamentId, $getRoomId, $getMessage, $getYouTubeLink);
}

else if($from == ‘send_notification’){

$title = $con->real_escape_string($_POST[‘title’]);
$to = $con->real_escape_string($_POST[‘to’]);
$body = $con->real_escape_string($_POST[‘body’]);
$getUserId = $con->real_escape_string($_POST[‘user_id’]);
$destinationUrl = $con->real_escape_string($_POST[‘des_url’]);

// create objects
$notificatios = new Notifications ($con);
$uploadFile = new UploadFile( $con );

$fileDetails = $_FILES[‘img’];

if ( !empty( $fileDetails[‘tmp_name’] ) ) {

$filePath = “NotificationImages”;
if (!file_exists($filePath)) {
mkdir($filePath, 0755, true);
}
$uploadStatus = $uploadFile->uploadFile( $filePath, $fileDetails );

if ( $uploadStatus[‘status’] == true ) {
$actualFilePath = $uploadStatus[‘filepath’];

if($to == ‘single’){
$notificatios->pushNotificationToSingle($title, $body, $pathh.””.$actualFilePath, $destinationUrl, $getUserId);
}
else{
$notificatios->pushNotification($title, $body, $pathh.””.$actualFilePath, $destinationUrl);
}

}
else{

if($to == ‘single’){
$notificatios->pushNotificationToSingle($title, $body, “”, $destinationUrl, $getUserId);
}
else{
$notificatios->pushNotification($title, $body, “”, $destinationUrl);
}
}

}
else{
if($to == ‘single’){
$notificatios->pushNotificationToSingle($title, $body, “”, $destinationUrl, $getUserId);
}
else{
$notificatios->pushNotification($title, $body, “”, $destinationUrl);
}
}

}

else if($from == ‘update_main_data’){

$version = $con->real_escape_string($_POST[‘version’]);
$appLink = $con->real_escape_string($_POST[‘app_link’]);
$paymentGateway = $con->real_escape_string($_POST[‘payment_gateway’]);
$terms = $con->real_escape_string($_POST[‘terms’]);
$updateDetails = $con->real_escape_string($_POST[‘update_details’]);
$websiteLink = $con->real_escape_string($_POST[‘website_link’]);
$instagram = $con->real_escape_string($_POST[‘instagram’]);
$youTube = $con->real_escape_string($_POST[‘youtube’]);
$privacyPolicy = $con->real_escape_string($_POST[‘privacy_policy’]);
$referAmount = $con->real_escape_string($_POST[‘refer_amount’]);
$minWithdraw = $con->real_escape_string($_POST[‘min_withdraw’]);
$registrationBonus = $con->real_escape_string($_POST[‘registration_bonus’]);
$annoucements = $con->real_escape_string($_POST[‘announcements’]);
$shareText = $con->real_escape_string(str_replace(“‘”, “”, $_POST[‘share_txt’]));

$response = array();

// Update Main Data
$updateMainData = ‘UPDATE main_data SET announcements = “‘.$annoucements.'”, version = “‘.$version.'”, gateway = “‘.$paymentGateway.'”, update_details = “‘.$updateDetails.'”, app_link = “‘.$appLink.'”, terms = “‘.$terms.'”, privacy_policy = “‘.$privacyPolicy.'”, website_link = “‘.$websiteLink.'”, instagram = “‘.$instagram.'”, youtube = “‘.$youTube.'”, refer_amount=”‘.$referAmount.'”, min_withdraw = “‘.$minWithdraw.'”, registration_bonus = “‘.$registrationBonus.'”, share_txt = “‘.$shareText.'” WHERE id = “1”‘;

if($con->query($updateMainData)){
$response[‘status’] = 1;
$response[‘msg’] = “Success”;
}
else{
$response[‘status’] = 0;
$response[‘msg’] = “Failed”;
}

echo json_encode($response);
}

else if($from == ‘distribute_prize’){

$tournamentId = $con->real_escape_string($_POST[‘tournament_id’]);
$ranks = $con->real_escape_string($_POST[‘ranks’]);
$winningAmount = $con->real_escape_string($_POST[‘win_amounts’]);

// creating Objects
$tournaments = new Tournaments($con);

echo $tournaments->distributePrize($tournamentId, $ranks, $winningAmount);

}

else if($from == ‘withdraw_requests’){

// how many rows
$draw = $con->real_escape_string($_POST[‘draw’]);
// start of
$startPosition = $con->real_escape_string($_POST[‘start’]);
// how many rows
$rowPerPage = $con->real_escape_string($_POST[‘length’]);
// Column index
$columnIndex = $con->real_escape_string($_POST[‘order’][0][‘column’]);
// Column name
$columnName = $con->real_escape_string($_POST[‘columns’][$columnIndex][‘data’]);
// asc or desc
$columnSortOrder = $con->real_escape_string($_POST[‘order’][0][‘dir’]);
// Search value
$searchValue = $con->real_escape_string($_POST[‘search’][‘value’]);

// Create Object
$getSearchRows = new getSearchRows( $con );

// set column names to search or filter into
$getSearchRows->setSearchColumns( “userData.profileName, type, amount, mobile, account_no, fullname, bank_name, ifsc, status” );

// ADD INNER JOINS
$getSearchRows->addInnerJoin(“INNER JOIN (SELECT id AS userId, fullname AS profileName FROM users) AS userData” );
$getSearchRows->setInnerJoinONCondition(” ON (userData.userId = user_id)”);

// set select column names
$getSearchRows->setSelectColumns(“*”);

// set objects which needs in get_search_rows
//$getSearchRows->setObjects( array( $admins, $courses, $batches, $users ) );

//set table name which from get data
$getSearchRows->setTableName( “withdraw_requests” );

// for use as a condition in additionalData function in getSearchRows class
$getSearchRows->setFrom( “withdraw_requests” );

echo $getSearchRows->getSearchData( $draw, $startPosition, $rowPerPage, $columnIndex, $columnName, $columnSortOrder, $searchValue );

}

else if($from == ‘get_transactions’){

$userId = $con->real_escape_string($_POST[‘user_id’]);

// how many rows
$draw = $con->real_escape_string($_POST[‘draw’]);
// start of
$startPosition = $con->real_escape_string($_POST[‘start’]);
// how many rows
$rowPerPage = $con->real_escape_string($_POST[‘length’]);
// Column index
$columnIndex = $con->real_escape_string($_POST[‘order’][0][‘column’]);
// Column name
$columnName = $con->real_escape_string($_POST[‘columns’][$columnIndex][‘data’]);
// asc or desc
$columnSortOrder = $con->real_escape_string($_POST[‘order’][0][‘dir’]);
// Search value
$searchValue = $con->real_escape_string($_POST[‘search’][‘value’]);

// Create Object
$getSearchRows = new getSearchRows( $con );

// set sql WHERE condition
if($userId != ‘0’){
$getSearchRows->getSelectCondition(‘user_id = ‘.$userId);
}

// set column names to search or filter into
$getSearchRows->setSearchColumns( “userData.fullname, title, amount, message, reciept_no, date, time” );

// ADD INNER JOINS
$getSearchRows->addInnerJoin(“INNER JOIN (SELECT id AS userId, fullname FROM users) AS userData” );
$getSearchRows->setInnerJoinONCondition(” ON (userData.userId = user_id)”);

// set select column names
$getSearchRows->setSelectColumns(“*”);

// set objects which needs in get_search_rows
//$getSearchRows->setObjects( array( $admins, $courses, $batches, $users ) );

//set table name which from get data
$getSearchRows->setTableName( “transactions” );

// for use as a condition in additionalData function in getSearchRows class
$getSearchRows->setFrom( “transactions” );

echo $getSearchRows->getSearchData( $draw, $startPosition, $rowPerPage, $columnIndex, $columnName, $columnSortOrder, $searchValue );

}

else if($from == ‘get_games’){

// how many rows
$draw = $con->real_escape_string($_POST[‘draw’]);
// start of
$startPosition = $con->real_escape_string($_POST[‘start’]);
// how many rows
$rowPerPage = $con->real_escape_string($_POST[‘length’]);
// Column index
$columnIndex = $con->real_escape_string($_POST[‘order’][0][‘column’]);
// Column name
$columnName = $con->real_escape_string($_POST[‘columns’][$columnIndex][‘data’]);
// asc or desc
$columnSortOrder = $con->real_escape_string($_POST[‘order’][0][‘dir’]);
// Search value
$searchValue = $con->real_escape_string($_POST[‘search’][‘value’]);

// Create Object
$getSearchRows = new getSearchRows( $con );

// set sql WHERE condition
//$getSearchRows->getSelectCondition(‘user_id = ‘.$userId);

// set column names to search or filter into
//$getSearchRows->setSearchColumns( “userData.fullname, title, amount, message, reciept_no, date, time” );

// ADD INNER JOINS
//$getSearchRows->addInnerJoin(“INNER JOIN (SELECT id AS userId, fullname FROM users) AS userData” );
//$getSearchRows->setInnerJoinONCondition(” ON (userData.userId = user_id)”);

// set select column names
$getSearchRows->setSelectColumns(“*”);

// set objects which needs in get_search_rows
//$getSearchRows->setObjects( array( $admins, $courses, $batches, $users ) );

//set table name which from get data
$getSearchRows->setTableName( “games” );

// for use as a condition in additionalData function in getSearchRows class
$getSearchRows->setFrom( “games” );

echo $getSearchRows->getSearchData( $draw, $startPosition, $rowPerPage, $columnIndex, $columnName, $columnSortOrder, $searchValue );

}

else if($from == ‘withdraw_action’){

$response = array();

$withdrawId = $con->real_escape_string($_POST[‘id’]);
$status = $con->real_escape_string($_POST[‘status’]);
$message = $con->real_escape_string($_POST[‘message’]);
$refundStatus = $con->real_escape_string($_POST[‘refund’]);

// create objects
$notificatios = new Notifications ($con);
$transactions = new Transactions($con);
$title = “”;

$selectWithdraw = “SELECT user_id, amount FROM withdraw_requests WHERE id = ‘$withdrawId'”;
$withdrawResults = $con->query($selectWithdraw);
$withdrawRow = $withdrawResults->fetch_assoc();
$getAmount = $withdrawRow[‘amount’];

$updateWithdraw = “UPDATE withdraw_requests SET status = ‘$status’ WHERE id = ‘$withdrawId'”;

if($con->query($updateWithdraw)){

$response[‘status’] = 1;
$response[‘msg’] = “Updated”;

if($status == ‘declined’){
$title = “Withdraw Request Declined”;
}
else{
$title = “Withdraw Request accepted”;
}

// refund user
if($refundStatus == ‘true’){
$updateUser = “UPDATE users SET deposit_amount = deposit_amount + $getAmount WHERE id = ‘”.$withdrawRow[‘user_id’].”‘”;
$con->query($updateUser);

$transactions->makeTransaction($withdrawRow[‘user_id’], $title, $message, “+”.$getAmount, “”);
}

$notificatios->pushNotificationToSingle($title, $message, “”, “”, $withdrawRow[‘user_id’]);

}
else{
$response[‘status’] = 0;
$response[‘msg’] = “Failed”;
}

echo json_encode($response);
}

else if($from == ‘update_game’){

$response = array();

$gameId = $con->real_escape_string($_POST[‘game_id’]);
$gameName = $con->real_escape_string($_POST[‘game_name’]);
$howToGetId = $con->real_escape_string($_POST[‘how_to_get_game_id’]);

$getImage = $_FILES[‘game_image’];

$uploadFile = new UploadFile( $con );
$uploadFile->setPostName(“game_image”);

if ( !empty( $getImage[‘tmp_name’] ) ) {
$filePath = “GameImages”;

if (!file_exists($filePath)) {
mkdir($filePath, 0755, true);
}

$uploadStatus = $uploadFile->uploadFile( $filePath, $getImage );

if ( $uploadStatus[‘status’] == true ) {
$actualFilePath = $uploadStatus[‘filepath’];
$actualFilePath = $pathh.””.$actualFilePath; // creating url of image file

$updateGames = “UPDATE games SET image = ‘$actualFilePath’ WHERE id = ‘$gameId'”;
$con->query($updateGames);

}
}

$updateGames = “UPDATE games SET name = ‘$gameName’, how_to_get_id = ‘$howToGetId’ WHERE id = ‘$gameId'”;
if($con->query($updateGames)){
$response[‘status’] = 1;
$response[‘msg’] = “Success”;
}
else{
$response[‘status’] = 0;
$response[‘msg’] = “Failed”;
}

echo json_encode($response);
}
}

$con->close();
?>

Let receive 0 but not invalid values

I have a input that i want to recive any number (dont matter if its negative, float, long) i code this to now allow null, undefined or empty values, but if I enter 0 it is read as empty

const inputElement = Number(document.getElementById("inputNumber").value);
  if (!inputElement) {
    window.alert("Insira um valor válido");
    return;
  }

i already tried this but dont work

if (!inputElement && inputElement != 0){
  window.alert("Insira um valor válido");
  return;
 }

Does anyone know how to differentiate 0 from empty or vice versa?

Troubleshooting firebase auth signup: catch block not executing on error

I’m currently working on implementing a signup feature using Firebase Auth. To ensure security, I’ve placed my Firebase config within an action function, despite understanding that the risks of exposing config values on the client side are minimal. The signup process itself is functioning smoothly. However, I’m encountering an issue with the error handling part of my code. Specifically, the code within my catch block doesn’t seem to trigger at all, even in scenarios where it is expected to throw an error code snippet

I would expect an error to occur, such as signing up with credentials that have already been used. There’s no feedback or error message on either the client or the server side in these cases. Could anyone offer some insights or suggestions on what might be causing this issue and how to resolve it?

Insert and reoder an array according to changes made on a sub collection of the orignal array

I have two arrays: A and B, A contains all elements of B, A also contains some other elements.
When array B changes, array A should be updated according B, here’re some rules:

  1. in array A, we must keep the elements that not belong to array B and keep their order.
  2. we can add new elements to array B, the new elements are added at the end of array B, and they are also added to the array A, following closely with the last element of array B in array A.
  3. we can switch the position of two elements in array B, and relative elements in array A will also switch their position.
  4. we can add new elements to array B and meanwhile switch positions of some elements (multiple switches), the array A should be updated according the 3 rules above.

I want to write a function taking 3 parameters: A, B, BX, and it will return the updated array A (we call it as AX).
Here’re some examples:

  1. A = [a1, a2, b1, a3, b2, b3, a4], B = [b1, b2, b3], BX = [b3, b2, b1], then AX = [a1, a2, b3, a3, b2, b1, a4]
    
  2. A = [a1, a2, b1, a3, b2, b3, a4], B = [b1, b2, b3], BX = [b3, b1, b2], then AX = [a1, a2, b3, a3, b1, b2, a4]
    
  3. A = [a1, a2, b1, a3, b2, b3, a4], B = [b1, b2, b3], BX = [b1, b2, b3, b4, b5], then AX = [a1, a2, b1, a3, b2, b3, b4, b5, a4]
    
  4. A = [a1, a2, b1, a3, b2, b3, a4], B = [b1, b2, b3], BX = [b3, b1, b2, b4, b5], then AX = [a1, a2, b3, a3, b1, b2, b4, b5, a4]
    
  5. A = [a1, a2, b1, a3, b2, b3, a4], B = [b1, b2, b3], BX = [b4, b3, b1, b2, b5], then AX = [a1, a2, b4, b3, a3, b1, b2, b5, a4]
    
  6. A = [a1, a2, b1, a3, b2, b3, a4], B = [b1, b2, b3], BX = [b4, b3, b1, b5, b2], then AX = [a1, a2, b4, b3, a3, b1, b5, b2, a4]
    

How can this be done?

How to create an infinite reviews carousel

Can anyone help create infinite reviews carousel. I have been trying for 2 days. Btw, I’m new to web developement, if my code looks hard to see, I’m sorry for that.
Here’s the code

html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="big-box">
        <div class="heading">
            <h1>Our Reviews</h1>
        </div>
        
        <div class="container">
            <div class="content">
                <div class="slide first-slide">
                    <img src="whiteProfile.jpeg">
                    <h3>Sans</h3>

                    <p>“This app allows me to do problem from my smartphone where I want and when I want to. The interface is easy to navigate and I find everything I need quickly. I can’t wait for new feature!”</p>

                </div>

                <div class="slide second-slide">
                    <img src="blackProfile.jpeg">
                    <h3>Adam</h3>

                    <p>“The tool X has really automated some of our company’s processes. We now spend less time doing manual work. It’s making problem very easy for us. Thanks to its scheduling feature, we don’t need staff to work outside of business hours.”</p>

                </div>

                <div class="slide third-slide">
                    <img src="blueProfile.jpeg">
                    <h3>Jane</h3>

                    <p>“Working with Company has been an absolute pleasure. Their team of skilled professionals is not only knowledgeable in their field but also dedicated to providing top-notch service and support. They took the time to understand our unique needs and developed a tailored solution that exceeded our expectations. I cannot recommend Company highly enough for any business seeking innovative software solutions and exceptional customer care.”</p>

                </div>

                <div class="slide fourth-slide">
                    <img src="cyanProfile.jpeg">
                    <h3>John</h3>

                    <p>“App has quickly become one of my favorite apps, thanks to its sleek design and powerful features. The app’s versatility allows me to stay organized, informed, and connected, all from the convenience of my mobile device. I appreciate the attention to detail and dedication to user satisfaction that the developers have put into App. It’s truly a game-changer and a must-have app for anyone looking to improve their overall digital experience.”</p>

                </div>

                <div class="slide fifth-slide">
                    <img src="greenProfile.jpeg">
                    <h3>Spark</h3>

                    <p>“App has quickly become one of my favorite apps, thanks to its sleek design and powerful features. The app’s versatility allows me to stay organized, informed, and connected, all from the convenience of my mobile device. I appreciate the attention to detail and dedication to user satisfaction that the developers have put into App.”</p>

                </div>
            </div>

            <div class="btn-box">
                <button class="btn btn-left"><ion-icon name="arrow-back-outline"></ion-icon></button>
                <button class="btn btn-right"><ion-icon name="arrow-forward-outline"></ion-icon></button>
            </div>
        </div>
    </div>

    <script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
    <script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>

    <script src="script.js"></script>
</body>
</html>

css

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;500;600;700;800;900&display=swap');

* {
    font-family: 'Montserrat', sans-serif;
    margin: 0;
    padding: 0;
}

h1 {
    font-size: 45px;
    font-weight: 500;
    margin-bottom: 15px;
}

img {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    margin: 15px;
    margin-top: 0;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.big-box {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.container {
    z-index: 100;
    width: 720px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 600px;
    overflow: hidden;
    border-radius: 30px;
    box-shadow:  12px 12px 24px #5a5a5a,
             -12px -12px 24px #ffffff;
}

.content {
    position: relative;
    width: 3600px;
    /* left: 50%; */
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translateX(0);
    transition: transform .3s ease-in,opacity .25s linear;
}

.slide {
    width: 720px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

h3 {
    margin: 10px;
    font-size: 25px;
    font-weight: 500;
}

p {
    width: 70%;
    text-align: center;
    margin: 15px;
    font-weight: 400;
    line-height: 25px;
}

.btn-box {
    position: absolute;
    height: 30px;
    bottom: 20px;
    display: flex;
    justify-content: space-evenly;
    width: 80px;
}

.btn {
    font-size: 20px;
    font-weight: 500;
    outline: none;
    border: none;
    background-color: white;
    width: 30px;
    height: 30px;
    border-radius: 15px;
    padding-top: 4px;
}

.btn:hover {
    background-color: gainsboro;
}

javascript

var rightButton = document.querySelector('.btn-right');
var leftButton = document.querySelector('.btn-left');


let transform = 0;

let current = 0;


rightButton.addEventListener('click', function() {
    transform = transform - 720;
    current++;
    document.querySelector('.content').style.transform = 'translateX(' + transform + 'px)';

    
});

leftButton.addEventListener('click', function() {
    transform = transform + 720;
    current--;
    document.querySelector('.content').style.transform = 'translateX(' + transform + 'px)';

    
});

I’m trying to create a reviews carousel that when I click to the left or right button, it swipes to the next page. But I’m trying to make the carousel be the loop that when I reach the end of each side left or right, It circles to the first one agian forever. Thank you for your help

Importing Component into Root Component in React Correctly and it is not being rendered

Problem statement: I am tring to import a Navbar component that is built using the Radix library into the root component App.js of my react application. I have tried both name and default export to render the component. None of these options work.

Error that comes in Live Server

Code setup and App.js file

Navbar Component

Troubleshoots:

I have tried renaming the components to resolve any possible conflicts. Also, I used different export and import convention built for react. None of these solutions work.I adjusted the file paths but it doesn’t help either.

Can you kindly help me?

Trouble with React project

I am trying to make a very simple project as one of my first react projects ever. What i tried to accomplish is making a simple input and making it print itself as i type however it doesn’t do anything. This is the code i wrote so far:

import './App.css';
import React from 'react';
import Header from './Header/Header';

function App() {

  const [userInput, setUserInput] = React.useState('')

  const handleChange = (event) => {
    console.log(event.target.value)
    setUserInput(event.target.value)
  }

  return (
    <div className="App">
      <Header userInput={userInput} handleChange={handleChange}/>
      <h1>{userInput}</h1>
    </div>
  );
}

export default App;

import React from "react";
import './Header.css'

const Header = ({userInput, handleChange}) => {
    return (
        <div className="headerContainer">
            <picture>
                <img alt='Something' className="logo"></img>
            </picture>
            <div>
                <label>Event:</label>
                <input type="text" onChange={handleChange} value={userInput}/><br /><br/>
            </div>
        </div>
    )
}
export default Header

I tried debugging, asked ChatGPT and Googling.`

How to manipulate audio being played by Twitch’s video player

I want to be able to intercept the video/audio being received by the player and analyze it as it is being received by the socket much before it is played by the player. If possible, I’d also need the stream information (where on the buffer is the player at). In sum, I want to synchronize an external audio player with twitch’s video player.

Reversal engenier seems to be the way, but it seems very convoluted. Looking at the network traffic, the response for what it seems to be the stream data doesn’t look readable and looking trough the javascript is a bit inconvinient. Tried to search for the video tag inside the js file as it might be what is manipulated, but nothing useful.

Looked it up if someone knows how to mess around with the played, but most google searches are unreleated