I’m following a YouTube tutorial on a Full Stack eCommerce website using React JS and I’m having a problem after clicking on the product page

according to this tutorial from 01:46:50 to 01:54:00, I should be able to click on any product and see “HOME > SHOP > men > Men Green Solid…” on top of page, but after I click any product there is no “HOME > SHOP > men > Men Green Solid…” and it just shows footer and navbar. Basically the product information is empty.
After reading the comments, I saw at least 2 people who have the same problem.

I re-watched the video several times to make sure I was doing everything correctly and exactly according to the video, but I didn’t manage to solve the problem.

//Product.jsx =>
import React, { useContext } from 'react'
import { ShopContext } from '../Context/ShopContext'
import { useParams } from 'react-router-dom';
import Breadcrum from '../Components/Breadcrums/Breadcrum';


const Product = () => {
  const {all_product}= useContext(ShopContext);
  const {productId} = useParams();
  const product = all_product.find((e)=> e.id === Number(productId));
  return (
    <div>
     <Breadcrum product={product}/>
    </div>
  )
}

export default Product
//Breadcrum.jsx =>
import React from 'react'
import './Breadcrum.css'
import arrow_icon from '../Assets/breadcrum_arrow.png'

const Breadcrum = (props) => {
    const {product} = props;
  return (
    <div className='breadcrum'>
      HOME <img src={arrow_icon} alt="" /> SHOP <img src={arrow_icon} alt="" /> {product.category} <img src={arrow_icon} alt="" /> {product.name}
    </div>
  )
}

export default Breadcrum
//ShopContext.jsx =>
import React, { createContext } from "react";
import all_product from '../Components/Assets/all_product';
export const ShopContext = createContext(null);

const ShopContextProvider = (props) => {

    const contextValue = {all_product}

    return (
        <ShopContext.Provider value={contextValue}>
            {props.children}
        </ShopContext.Provider>
    )
}

export default ShopContextProvider;

Prisma and Supabase Images Upload

I have an input file with multiple images upload. I am adding them to Supabase storage as you can see in the server actions, it works fine. When I try adding the images URL’s to the Prisma database it does not work. The “create” is giving an error : Types of property ‘imageUrl’ are incompatible. Here is my code. I omitted the extra fields just to keep it simple. Anyone can help to sport the problem in my code?

The Image Input File

<Input name="image" type="file" multiple={true} required />

The Server Action

export async function createDescription(formData: FormData) {

  const homeId = formData.get("homeId") as string;
  const photos = formData.getAll("image") as string[];

  const photoNames = photos.map((_, index) => `blog-${Date.now()}-${index}`);

  
  const uploadPromises = photos.map((photo, index) => {
    return supabase.storage.from("images").upload(photoNames[index], photo, {
      contentType: "image/png",
      cacheControl: "2592000",
    });
  });

  const uploadResults = await Promise.all(uploadPromises);
  const errors = uploadResults.map((result) => result.error).filter(Boolean);

  if (errors.length > 0) {
    return { error: "Unable to upload one or more blog images to Storage." };
  }

  const paths = uploadResults.map((result) => result.data?.path);
  const photoUrls = paths.map(
    (path) =>
      `${process.env.SUPABASE_URL}/storage/v1/object/public/images/${path}`,
  );

  const { data: imageData } = await supabase.from("blogs").update([
    {
      homeId,
      photoUrls,
    },
  ]);

  if (imageData === null) {
    return { error: "Unable to upload one or more blog images to Storage." };
  }

  const imageFilesUrl = photoUrls.map((url) => ({ url }));

  const data = await prisma.home.update({
    where: {
      id: homeId,
    },
    data: {
      title,
      addedDescription: true,

      HomePhoto: {
        create: {
          imageUrl: imageFiles,
        },
      },
    },
  });

  return redirect(`/create/${homeId}/address`);
}

The Prisma Model

model User {
  id           String  @id @unique
  authId       String  @unique
  email        String  @unique
  firstName    String
  lastName     String
  profileImage String?
  Home         Home[]
}

model Home {
  id           String  @id @default(uuid())
  title        String?
  description  String?
  guests       String?
  bedrooms     String?
  bathrooms    String?
  country      String?
  price        Int?
  categoryName String?

  addedCategory    Boolean @default(false)
  addedDescription Boolean @default(false)
  addedLocation    Boolean @default(false)

  createdAT DateTime @default(now())
  User      User?    @relation(fields: [userId], references: [id])
  userId    String?
  HomePhoto Photo[]
}

model Photo {
  id       String @id @default(uuid())
  imageUrl String

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  Home   Home   @relation(fields: [homeId], references: [id])
  homeId String
}

How to add interactive charts in Excel?

I’m trying to add the below interactive chart in excel. But using the below example chart is not rendered inside the excel. I’m trying for interactive charts which is there in the excel using JavaScript. I have attached the below image from excel. I need to draw a chart like below, when I hover on it, it should show the data on it. Whenever there is a change in table data, chart should be automatically updated. This is the feature in excel, how to incorporate the same in JS code. Please help me to add the interactive chart in excel with respective table data.

enter image description here

document.addEventListener('DOMContentLoaded', function() {
  var table = document.getElementById('myTable');
  var chartCanvas = document.getElementById('myChart');
  var ctx = chartCanvas.getContext('2d');

  // Extract data from table
  var data = [];
  for (var i = 1; i < table.rows.length; i++) {
    var row = table.rows[i];
    data.push({
      month: row.cells[0].innerText,
      revenue: parseFloat(row.cells[1].innerText)
    });
  }

  // Create chart
  var myChart = new Chart(ctx, {
    type: 'bar',
    data: {
      labels: data.map(function(item) {
        return item.month;
      }),
      datasets: [{
        label: 'Revenue',
        data: data.map(function(item) {
          return item.revenue;
        }),
        backgroundColor: [
          'rgba(255, 99, 132, 0.2)',
          'rgba(54, 162, 235, 0.2)',
          'rgba(255, 206, 86, 0.2)'
        ],
        borderColor: [
          'rgba(255, 99, 132, 1)',
          'rgba(54, 162, 235, 1)',
          'rgba(255, 206, 86, 1)'
        ],
        borderWidth: 1
      }]
    },
    options: {
      scales: {
        y: {
          beginAtZero: true
        }
      }
    }
  });

  // Generate Excel file
  var wb = XLSX.utils.book_new();
  var ws = XLSX.utils.table_to_sheet(table);
  XLSX.utils.book_append_sheet(wb, ws, "Data");

  // Add chart image to Excel
  var imgData = chartCanvas.toDataURL("image/png");
  var imgObj = new Image();
  imgObj.src = imgData;
  var ctxImg = document.createElement('canvas').getContext('2d');
  imgObj.onload = function() {
    ctxImg.canvas.width = chartCanvas.width;
    ctxImg.canvas.height = chartCanvas.height;
    ctxImg.drawImage(imgObj, 0, 0);
    var chartImg = ctxImg.canvas.toDataURL("image/png");
    XLSX.utils.sheet_add_image(ws, chartImg, {
      tl: {
        col: 2,
        row: 0
      },
      br: {
        col: 8,
        row: 10
      }
    });
    var excelFile = XLSX.write(wb, {
      bookType: 'xlsx',
      type: 'binary'
    });
    saveAs(new Blob([s2ab(excelFile)], {
      type: 'application/octet-stream'
    }), 'chart_with_data.xlsx');
  };
});

function s2ab(s) {
  var buf = new ArrayBuffer(s.length);
  var view = new Uint8Array(buf);
  for (var i = 0; i < s.length; i++) {
    view[i] = s.charCodeAt(i) & 0xFF;
  }
  return buf;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.4/xlsx.full.min.js"></script>
<table id="myTable">
  <thead>
    <tr>
      <th>Month</th>
      <th>Revenue</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>January</td>
      <td>10000</td>
    </tr>
    <tr>
      <td>February</td>
      <td>12000</td>
    </tr>
    <tr>
      <td>March</td>
      <td>15000</td>
    </tr>
  </tbody>
</table>
<canvas id="myChart" width="400" height="400"></canvas>

JavaScript code for pagination button on a website that automates pagination does not work as expected

I’m new here and its my first question. Hope I get my query resolved. I tried searching here but couldn’t find it. Please help me. Thank you.

Here is the link to source code that I want pagination Javascript for:
text

Following is the code I have which is not correct as it directs me back to same page instead of going to next. Please help me correct this code or provide me the corrected code based on source code above. I used Bardeen for pagination of the same website and it works fine but I’m not sure what is the Javascript that enables correct pagination. Thank you again in advance for your kind help

document.addEventListener("DOMContentLoaded", function() {
    // Get the active page element
    var activePageElement = document.querySelector("#paging a.active");
    
    if (activePageElement) {
        // Get the next page URL
        var nextPageUrl = activePageElement.parentElement.nextElementSibling.querySelector("a").getAttribute("href");

        // Redirect to the next page
        window.location.href = nextPageUrl;
    }
});

I tried the code as mentioned above but it did not work. I want the Javascript for pagination for the website link provided

document.addEventListener("DOMContentLoaded", function() {
    // Get the active page element
    var activePageElement = document.querySelector("#paging a.active");
    
    if (activePageElement) {
        // Get the next page URL
        var nextPageUrl = activePageElement.parentElement.nextElementSibling.querySelector("a").getAttribute("href");

        // Redirect to the next page
        window.location.href = nextPageUrl;
    }
});

What is this character format and how to decode to normal text?

this is the result of a post with normal text after hit the edit button, on a forum webpage where I am admin.

%u0398%u03B1 %u03C4%u03C1%u03B5%u03BE%u03C9 %u03B5%u03C3%u03C4%u03C9 %u03BA%u03B1%u03B9 %u03BC%u03B5 %u03B5%u03BD%u03B1 %u03C0%u03BF%u03B4%u03B9

How to get the original normal text?

A little research I did showed that the forum(Simple Machine Forum) is built with javascript and php

Set Min and Max dates for Datatables Datepicker to use

I’m hoping this is a very simple request and I’m just missing something obvious.

I’m using the DataTables DatePicker to allow a Date Range search and whilst it’s working exactly as it should, I really want to set how far back (and forward) a user can select a date.

At the moment it allows a user to select back to 2009 and up to 2049. Ideally I’d want it so that the minimum date allowed is the first date from the data in the DataTable and then the max being the max. I’m happy to set a specific year if that isn’t possible.

Can anyone help please?

Here’s my code:

// Create date inputs
minDate = new DateTime('#datefrom', {
    format: 'DD-MM-YYYY'
});
maxDate = new DateTime('#dateto', {
    format: 'DD-MM-YYYY'
});

// Custom filtering function which will search data in column four between two values
DataTable.ext.search.push(function (settings, data, dataIndex) {
    let min = moment($('#datefrom').val(), 'DD-MM-YYYY', true).isValid() ?
        moment($('#datefrom').val(), 'DD-MM-YYYY').format('YYYYMMDD') : "";

     let max = moment($('#dateto').val(), 'DD-MM-YYYY', true).isValid() ?
         moment($('#dateto').val(), 'DD-MM-YYYY').format('YYYYMMDD') : "";

    var date = moment( data[2], 'DD-MM-YYYY' ).format('YYYYMMDD');

    if ( max <= "" ) {
      max = "99991231";
    }

    if ( date >= min && date <= max ) {
       return true;
    }

    return false;
});

If it can only be done by removing the HTML once the DataTable has been rendered, how would I go about that?

NodeMailer is running on localhost. But when I deploy to Vercell it is not running. Please solve it [closed]

Here Is my Code:

const transporter = nodemailer.createTransport({
  service: "gmail",
  host: "smtp.gmail.com",
  auth: {,
    user: "[email protected]",
    pass: "aaaaaaaaaa",
  },
});

const mailOptions = {
  from: `[email protected]`,
  to: `[email protected]`,
  subject: `Random Subject`,
  text:"Testing SMS "
};

//Send Email
await transporter.sendMail(mailOptions);

const transporter = nodemailer.createTransport({
  host:"smtp.gmail.com",
   port: 465,
  secure: true,
  host: "smtp.gmail.com",
  auth: {,
    user: "[email protected]",
    pass: "aaaaaaaaaa",
  },
});

also Tried In this code.But not Solve…..

css transition not working inside next/tailwind app

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js"></script>


import React, { useState } from 'react';

const Navbar = () => {
  const [isOpen, setIsOpen] = useState(false);

  const toggleNavbar = () => {
    setIsOpen(!isOpen);
  };

  return (
    <div>
      <button
        onClick={toggleNavbar}
        className="fixed top-0 right-0 p-4 text-white"
      >
        Toggle Menu
      </button>
      <div
        className={`fixed top-0 right-0 h-screen bg-gray-900 w-64 overflow-hidden transition-transform duration-300 ease-in-out ${
          isOpen ? 'transform translate-x-0' : 'transform translate-x-full'
        }`}
      >
        {/* Navigation content here */}
        <ul className="mt-10">
          <li className="text-white py-2 px-4">Home</li>
          <li className="text-white py-2 px-4">About</li>
          <li className="text-white py-2 px-4">Services</li>
          <li className="text-white py-2 px-4">Contact</li>
        </ul>
      </div>
    </div>
  );
};

export default Navbar;

above is my next/tailwind app its a client component.

my issue is CSS transition here is not working in next app i tried checking in Codepen using vanilla js its working but inside next app its not working. tried to get help from chatGBT also but seems like the tailwind configuration also ok no error showing just the transition is not working. my expected out put is when the toggle navbar should ease in.
Does anyone have any idea of this error and any way to tackle this?

ECharts 5: Display of a large number of data points

I am developing an Apache ECharts based application that is supposed to display a very large number of data points in a line chart.
There may well be millions of data points.
The X-axis represents the time and the Y-axis the value.
The “xAxis->data” option is not used.
The series is configured as follows:

let option = {
    series: [
        type: 'line',
        data: [[time1, value1], [time2, value2], ...]
    ]
}

As long as the viewport (DataZoom) is scaled in and, let’s say, shows less than 4000 points,
then the left/right scrolling and zooming of the chart behaves smoothly.

However, if you zoom out and the chart has to display more than 10,000 data points, then it starts to become sluggish.

It is always the case that the further you zoom out, the fewer data points are required,
to display a graph in a meaningful way.
As the number of data points does not currently change, the system is overloaded.

In order to keep the graph fluid and performant at all times,
it is advisable to “thin out” the data, e.g. by using the Ramer-Douglas-Peucker algorithm:
https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm

Now to my questions:

  1. Does Echarts offer anything in this regard to somehow dynamically reduce the visible range data?
    E.g. through some filter mechanism?

If not, then the approach could be to pass a reduced set of data to Echarts.
So that ECharts can/should constantly work with (let’s say) 2,000 – 5,000 data points,
regardless of whether you zoom in or out.
In this case, I should always replace the series data in ECharts when zooming and scrolling,
so that these 2,000 – 5,000 data points are always used for a specific time range.

  1. The question now is, are there any examples of the best way to implement something like this?
    It gets tricky because you not only have to set the data points again and again when scrolling/zooming,
    but presumably also have to reconfigure the DataZoom again and again.

Ideally, the DataZoom slider should take the entire temporal range into account,
so that the user does not notice anything when scrolling and zooming,
that the data is constantly changing in the background.

How can i create a daily streak function?

I have been trying to implement a feature that updates the streak to +1 if i play daily and resets if i skip a day. also when every date changes i want to reset all data stored locally for the game.

const lastDateVal = localStorage.getItem('lastDate');
    setLastDate(JSON.parse(lastDateVal));
    if(lastDateVal){ 
        console.log(curDay, parseInt(lastDateVal, 10));
        console.log(curDay == lastDateVal);
        if(curDay == lastDate){
            console.log('Same Day');
        } else {
            console.log('New Day');
        }
    } else {
        setLastDate(curDay); 
        localStorage.setItem('lastDate', JSON.stringify(curDay));
    }

this is the sample code i implemented but this this condition is always returning new day even if the date is same.

it was of type string so i parsedIt as int and then also compared but id didn’t worked.

I am trying to develop an algorithm for a derivative given inverse function f(x) = acos(x) or cos^-1(x)

I am trying to develop a calculator using JSX but the code below is using JS.

I am trying to make an algorithm about the derivative of a given function acos(x) or cos^-1(x) using Taylor’s polynomial. The function is given, now the user will input the desired degree, x, and number of decimal places. x could be 0 (which is Maclaurin series from Taylor’s polynomial).

My algorithm seems to not work correctly and I cannot figure it out.

I tried degree = 4, x = 0 and decimal places of 6. (Although I don’t think decimal places matter much).

example

import * as math from 'mathjs';

// Function to calculate the derivative of arccos(x) using the provided formula
function derivativeArccos(x, degree) {
  if (x === 0) {
    return degree % 2 === 0 ? '0' : `-1 / ${math.factorial(degree)}`;
  }

  let result = '';
  for (let i = 0; i <= degree; i++) {
    let coefficient;
    if (i === 0) {
      coefficient = 'pi / 2';
    } else {
      coefficient = (i % 2 === 0) ? 0 : (-1) ** ((i - 1) / 2);
    }
    const denominator = math.factorial(i) * 2 ** i;
    const term = `${coefficient} * (${x})^${i} / ${denominator}`;
    result += (result === '' && term !== '0') ? term : (term !== '0' ? ` + ${term}` : '');
  }
  return result;
}

export default function getTaylor(degree, x, decimalPlace) {
  let taylorEquation = ''; // Initialize the Taylor series equation
  for (let i = 0; i <= degree; i++) {
    const derivative = derivativeArccos(x, i); // Calculate the derivative up to the current     degree
    if (derivative !== '0') {
      const term = i === 0 ? `${derivative}` : `(${derivative}) * x^${i}`; // Generate terms    for the Taylor series expansion
      taylorEquation = (taylorEquation === '') ? term : `${taylorEquation} + ${term}`; //     Concatenate terms with appropriate signs
    }
  }
  return taylorEquation;
}

Multiple renders of TradingView Widget

I am using a real-time chart from tradingview.com but that chart is rendering two times at the starting and whenenever I am changing something in my code that chart in rendering again. Due to that there are multiple renders as I have shown you in the image. If any one who’s how can I resolve this then please let me know.
I am sharing code of that chart component for your convenience.

// TradingViewWidget.jsx
import React, { useEffect, useRef, memo } from 'react';

function TradingViewWidget() {
    const container = useRef();

    useEffect(() => {
        const script = document.createElement("script");
        script.src = "https://s3.tradingview.com/external-embedding/embed-widget-advanced-chart.js";
        script.type = "text/javascript";
        script.async = true;
        script.innerHTML = `
            {
                "autosize": true,
                "symbol": "BITSTAMP:BTCUSD",
                "interval": "D",
                "timezone": "Etc/UTC",
                "theme": "light",
                "style": "3",
                "locale": "en",
                "enable_publishing": false,
                "gridColor": "rgba(0, 0, 0, 0.06)",
                "hide_top_toolbar": true,
                "hide_legend": true,
                "save_image": false,
                "calendar": false,
                "hide_volume": true,
                "support_host": "https://www.tradingview.com"
            }`;
        container.current.appendChild(script);
        },[]);

    return (
        <div className="tradingview-widget-container" ref={container} style={{ height: "100%", width: "100%" }}>
            <div className="tradingview-widget-container__widget" style={{ height: "calc(100% - 32px)", width: "100%" }}>
            </div>
            <div className="tradingview-widget-copyright">
                <a href="https://www.tradingview.com/" rel="noopener nofollow" target="_blank">
                    <span className="blue-text">
                        Track all markets on TradingView
                    </span>
                </a>
            </div>
        </div>
    );
}

export default memo(TradingViewWidget);

Offset eCharts markLine label when two markLine labels overlap

When markLines exist very close together on yAxis, it is hard to read.
enter image description here

I have tried offsetting vertically with distance and padding but both don’t seem to move the label in the vertical axis.

CodePen: https://codepen.io/isachenx/pen/ZEZbLXg

option = {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [150, 230, 224, 218, 135, 147, 260],
      type: 'line',
            markLine: {
        data: [
             {
            type: 'test',
            name: 'test',
            yAxis: 197,
            label: {
              backgroundColor: 'pink',
              distance: [20, 300],
              padding: [50,0,0,0]
            }
          },
          {
            type: 'average',
            name: 'Avg',
          }
        ]
      }
    }
  ]
};