My custom modal doesn’t close because of react’s useState hook. Need help in finding a solution

My custom modal window opens up but doesn’t close when I click on the darkened area. I investigated a bit and found out that the setActive function in the modal component doesn’t set the active to false for some reason. How can I fix this?

The modal file

import React from 'react'
import './style.css'


const Modal = ({active, setActive, children}) => {

  return (
    <div className={active?'modal_main active':'modal_main'} onClick={()=>{setActive(false)}}>
        <div className={active?'modal_content active':'modal_content'} onClick={e=>e.stopPropagation()}>
           {children}
        </div>
    </div>
  )
}

export default Modal

Where I use the modal window

import React, { useState } from 'react'
import Modal from '../../modal'
import './style.css'

function TagItem(props) {
  const [tagActive, setTagActive] = useState(false);

  return (
    <div className='tag-item' onClick={()=>setTagActive(true)}>
      {props.tag}
      <Modal active = {tagActive} setActive = {setTagActive}>
        <div >{props.tag}</div>
      </Modal>
    </div>
  )
}

export default TagItem

Modal not popping up at react and sends to an empty page after click of a button

Hello on ReactJS Bootstrap. When I try to click my button for the handleShow of the Modal
It sends me to a blank webpage and just get’s stuck there. I tried to debug and my state show changes to true but it never shows the modal.

added text since stack overflow does not want me to post if the wording is not a lot, added text since stack overflow does not want me to post, added text since stack overflow does not want me to post
Any help would be appreciated.

Thanks!

 import React, { Component, useState } from "react";
    import Modal from "react-bootstrap/Modal";
    import { useHistory } from "react-router-dom";
    import Axios from "axios";
    // import Profile from '../pages/forms';
    import { Link } from "react-router-dom";
    import Form from "react-bootstrap/Form";
    
    import "../index.css";
    import { setGlobalState, useGlobalState } from "../globals/globalVar";
    
    function LoginComponent(props) {
      // const
      const [email, setEmail] = useState("");
      const [password, setPassword] = useState("");
      const [show, setShow] = useState(false);
      const history = useHistory();
      // make an axios query
    
      const url = useGlobalState("defaultUrl");
    
      const handleClose = () => setShow(false);
      const handleShow = () => setShow(true);
      const handleEmailAndpasswordVerify = () => {
        if (email.length === 0) {
          alert("Email cannot be empty.");
          return -1;
        }
        // email must contain @csub.edu
        if (!email.includes("@csub.edu")) {
          alert("Email must contain @csub.edu");
          return -1;
        }
        // if the len of password is less than 8 then reject
        if (password.length < 8) {
          alert("Password must be at least 8 characters long.");
          return -1;
        }
    
        return 0;
      };
      const handleSubmit = (e) => {
        if (handleEmailAndpasswordVerify() !== 0) {
          // if the email and password are valid then send the request to the server
          // to register
          // send the request to the server
          // if success then close the modal
          // if fail then alert the error
          return;
        }
        e.preventDefault();
        // make a post axios request to a server
        Axios.post("http://localhost:8000/index.php", {
          email: email,
          password: password,
        }).then((response) => {
          if (response.data.message) {
            console.log(response.data);
            // console.log(loginStatus);
          } else {
            // alert the error
            alert(response.data.error);
            // history.push("/main");
          }
        });
        setShow(false);
      };
    
      const login = () => {
        Axios.post(url, {
          email: email,
          password: password,
        }).then((response) => {
          if (response.data.message) {
            console.log(response.data);
            // console.log(loginStatus);
          } else {
            // setLoginStatus(response.data[0].username);
            history.push("/main");
          }
        });
      };
      //login validator
      const loginValidate = () => {
        if (email.length === 0) {
          alert("Username cannot be empty.");
          return;
        }
        if (password.length === 0) {
          alert("Password cannot be empty.");
          return;
        }
        login();
      };
    
      return (
        <div>
          <form>
            <nav className="navbar navbar-expand-lg navbar-light fixed-top">
              <div className="container">
                <Link className="navbar-brand fs-1"> StuHuB </Link>{" "}
                <div
                  className="collapse navbar-collapse"
                  id="navbarTogglerDemo02"
                ></div>{" "}
              </div>{" "}
            </nav>{" "}
            <div className="auth-wrapper">
              <div className="auth-inner">
                <h3> Sign In </h3>{" "}
                <div className="form-group">
                  <label> Login ID </label>{" "}
                  <input
                    type="text"
                    className="form-control"
                    placeholder="Enter Login ID"
                    onChange={(e) => {
                      setEmail(e.target.value);
                    }}
                  />{" "}
                </div>{" "}
                <div className="form-group">
                  <label> Password </label>{" "}
                  <input
                    type="password"
                    className="form-control"
                    placeholder="Enter password"
                    onChange={(e) => {
                      setPassword(e.target.value);
                    }}
                  />{" "}
                </div>{" "}
                <button
                  onClick={loginValidate}
                  type="button"
                  className="btn btn-primary btn-block"
                >
                  Submit{" "}
                </button>{" "}
              </div>{" "}
              <button className="btn btn-primary btn-block" onClick={handleShow}>
                Register
              </button>
            </div>{" "}
          </form>
          {/* Not working? */}
          {/* Modal */}
          <Modal show={show} onHide={handleClose}>
            <Modal.Header closeButton>
              <Modal.Title>Modal heading</Modal.Title>
            </Modal.Header>
            <Modal.Body>
              <Form>
                <Form.Group className="mb-3" controlId="exampleForm.ControlInput1">
                  <Form.Label>Email address</Form.Label>
                  <Form.Control
                    type="email"
                    placeholder="[email protected]"
                    autoFocus
                    onChange={(e) => setEmail(e.target.value)}
                  />
                </Form.Group>
                {/* form password */}
    
                <Form.Item
                  name="password"
                  label="Password"
                  rules={[
                    {
                      required: true,
                      message: "Please enter password!",
                    },
                  ]}
                >
                  <input
                    type="password"
                    onChange={(e) => setPassword(e.target.value)}
                  />
                </Form.Item>
              </Form>
            </Modal.Body>
            <Modal.Footer>
              <button variant="secondary" onClick={handleClose}>
                Close
              </button>
              <button variant="primary" onClick={handleSubmit}>
                Submit
              </button>
            </Modal.Footer>
          </Modal>
    
          {/* make a hidden modal */}
        </div>
      );
    }
    
    export default LoginComponent;

How to do named imports on NodeJS?

I have a js file called Auth.js that contains two functions. How can I correctly do named imports on Node?

const Func1 () => {}
const Func2 () => {}

export {
 Func1
 Func2
}

In my index.js I import like so:

import { Func1, Func2 } from './Auth.js'

In my package.json I have "type": "module"

I get the following error:

internal/process/esm_loader.js:74
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module

Bold submenu items in sidebar menu

I followed the explanation below to create what I needed, but there is an additional requirement i am trying to fulfill.

highlight the navigation menu for the current page

My submenu items are anchor links on the same page as the main menu item. Example:

    $(function() {
        var url = window.location.href;
        $(".imagingmenu a").each(function() {
            if (url == (this.href)) {
                $(this).closest("li").addClass("active");
               $(this).closest("li").parent().parent().addClass("active");
            }
        });
    });        
.imagingmenu ul li.active a, .imagingmenu ul li a:hover {
font-weight:bold;
}
<div class="imagingmenu">

<ul>
<li><a href="http://exampleurl-1.com">Menu item 1</a>

<li><a href="#">Menu item 2</a>

<ul>
<li><a href="#/#submenuitem1">Submenu Item 1</a></li>
<li><a href="#/#submenuitem2">Submenu Item 2</a></li>
<li><a href="#/#submenuitem3">Submenu Item 3</a></li>
</ul>

</li>
</ul>

</div>

You can see the bolding works when you hover over the submenu items, but when they are clicked and active, I want just that submenu item to be bolded and the other not to be. However, when any of the submenu items are active, all of them in the list are bolded. How can I achieve what I’m looking for?

Thanks.

Spotify API Fetch 401 and 400 error only valid bearer authentication supported

Under guidance of the Spotify WebAPI doc I am trying to get request user/account data via Client Credentials method. Spotify Doc. I am using a nested fetch request. I am getting a 400 and 401 response on my second fetch complaining about either not being authorized or

“message”: “Only valid bearer authentication supported”

depending on my get request. I followed the doc and I have my token response that seems valid I’m unsure as to why it wouldn’t be. Yes I tried different endpoints, and I reset my client secret. I have also included the code, the key was reset before posting so, code

import React, { Component, useState, useEffect } from 'react';
//Custom IMPORTS: 
import '../PageCss/HeaderSection.css'

const Spotify = () => {

  const [baseUrl, setBaseUrl] = useState("https://accounts.spotify.com/api/token");
  const [spotifyArtists, setSpotifyArtists] = useState("https://api.spotify.com/v1/artist/7bSpQNOg9UsW530DuXM3X5");
  const [token, setToken] = useState([]);
  const [spotifyResonse, setspotifyResonse] = useState([]);
  const [currentStatus, setStatus] = useState(false);
  const [currentStatus2, setStatus2] = useState(false);

  const client_id = '';
  const client_secret = '48bdac084... f8ddb412';
 

  useEffect(() => {
      fetch(baseUrl,
      {
        method: 'POST',
        body: 'grant_type=client_credentials&client_id=' + client_id + '&client_secret=' + client_secret,
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      })
      .then((response) => {

        if (!response.ok) {
          return Promise.reject(new Error("Spotify Token Request Error"));
        }
        else {
          return response.json();
        }
      })
      .catch((err) => {
        console.log("First Fetch " + err);
      })
      .then((json) => {
        try {
          console.log("Current token after first fetch: " + json.access_token);
          console.log(": " + json.token_type);
          console.log(": " + json.expires_in);
          setToken(json.access_token);
          setStatus(true);
          console.log("Fetch 2 Requesting data with token: " + token);
          return fetch(spotifyArtists,{
            method: 'GET',
            headers: {
              'Authorization': `Bearer ${token}` ,
              'Content-Type': 'application/json'
            }})
        }
        catch
        {
          return Promise.reject(new Error(`State Error!: Data: ${token} , Connection:${currentStatus}`));
        }
      })
      .then((response) => {

        if (!response.ok) {
          return Promise.reject(new Error("Spotify Data Request with token Error" + response.status));
        }
        else {
          return response.json();
        }
      })
      .catch((err) => {
        console.log("Second Fetch" + err);
      })
      .then((json) => {
        try {
          console.log("After data request: " + json)
          console.log("Token after request" + token);
          setspotifyResonse(json);
          setStatus2(true);
        }
        catch
        {
          return Promise.reject(new Error(`State Error2 !: Data: ${spotifyResonse} , Connection2:${currentStatus2}`));
        }
      })
      .catch((err) => {
        console.log("After 2nd Fetch Error" + err);
      })

  }, [baseUrl, spotifyArtists]);

  return (
    <div >
    </div>
  )
};
export default Spotify;

Endpoints in question
enter image description here
enter image description here

Error Log

enter image description here

My request header yes the keys are different from above code, I had to redo this so many times.
enter image description here

Exact response
enter image description here

azure function outgoing service bus message with correlation filter

I have an azure function that I want to send a message to a service bus that has a correlation filter on it. Specifically the correlation filter is on the label/subject with a value of ‘APPLICATION’. correlation filter

How do I send the message from the azure function so that it will set this value and the subscription will receive the message?

Currently the function is set up something like this:

index.js:

module.exports = async function(context, inMessage) {
  context.bindings.outMessage = someJavascriptObject;
}

function.json:

{
  "bindings": [
    {
      "name": "inMessage",
      "type": "serviceBusTrigger",
      "direction": "in",
      "topicName": "some_topic_1",
      "subscriptionName": "SUBSCRIPTION_NAME",
      "connection": "CONNECTION_STRING_1"
    },
    {
      "name": "outMessage",
      "type": "serviceBus",
      "topicName": "some_topic_2",
      "connection": "CONNECTION_STRING_2",
      "direction": "out"
    },
  ]
}

How do I get the canvas to show behind my HTML so my animated cursor will move over the screen?

I want the canvas to show behind the website not over it. I have tried using z index and that does not work. I want to be able to see my actual website while moving the cursor over things. So I need the cursor to show on the website. It just blocks out my whole section. How can I get this to work correctly?

const navToggle = document.querySelector('.nav-toggle');
const navLinks = document.querySelectorAll('.nav__link')


navToggle.addEventListener('click', () => {
    document.body.classList.toggle('nav-open');
});

navLinks.forEach(link => {
    link.addEventListener('click', () => {
        document.body.classList.remove('nav-open');
    })
})

// Canvas

const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let spots = [];
let hue = 0;

const mouse = {
    x: undefined,
    y: undefined
}

canvas.addEventListener('mousemove', function (event) {
    mouse.x = event.x;
    mouse.y = event.y;
    for (let i = 0; i < 3; i++) {
        spots.push(new Particle());
    }
});

class Particle {
    constructor() {
        this.x = mouse.x;
        this.y = mouse.y;
        this.size = Math.random() * 2 + 0.1;
        this.speedX = Math.random() * 2 - 1;
        this.speedY = Math.random() * 2 - 1;
        this.color = 'hsl(' + hue + ', 100%, 50%)';
    }
    update() {
        this.x += this.speedX;
        this.y += this.speedY;
        if (this.size > 0.1) this.size -= 0.03;
    }
    draw() {
        ctx.fillStyle = this.color;
        ctx.beginPath();
        ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
        ctx.fill();
    }
}
function handleParticle() {
    for (let i = 0; i < spots.length; i++) {
        spots[i].update();
        spots[i].draw();
        for (let j = i; j < spots.length; j++) {
            const dx = spots[i].x - spots[j].x;
            const dy = spots[i].y - spots[j].y;
            const distance = Math.sqrt(dx * dx + dy * dy);
            if (distance < 90) {
                ctx.beginPath();
                ctx.strokeStyle = spots[i].color;
                ctx.lineWidth = spots[i].size / 10;
                ctx.moveTo(spots[i].x, spots[i].y);
                ctx.lineTo(spots[j].x, spots[j].y);
                ctx.stroke();
            }
        }
        if (spots[i].size <= 0.3) {
            spots.splice(i, 1); i--;
        }
    }
}
function animate() {
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    handleParticle();
    hue++;
    requestAnimationFrame(animate);
}
window.addEventListener('resize', function () {
    canvas.width = innerWidth;
    canvas.height = innerHeight;
    init();
})
window.addEventListener('mouseout', function () {
    mouse.x = undefined;
    mouse.y = undefined;
})
animate()
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    overflow-x: hidden;
}

body {
    position: relative
}


/* Custom Properties */

:root {
    --ff-primary: 'Source Sans Pro', sans-serif;
    --ff-secondary: 'Source Code Pro', monospace;

    --fw-reg: 300;
    --fw-bold: 900;

    --clr-light: #fff;
    --clr-dark: #303030;
    --clr-accent: #16e0bd;

    --fs-h1: 3rem;
    --fs-h2: 2.25rem;
    --fs-h3: 1.25rem;
    --fs-body: 1rem;

    --bs: 0.25em 0.25em 0.75em rgba(0, 0, 0, .25),
        0.125em 0.125em 0.25em rgba(0, 0, 0, .15);
}

@media (min-width: 800px) {
    :root {
        --fs-h1: 4.5rem;
        --fs-h2: 3.75rem;
        --fs-h3: 1.5rem;
        --fs-body: 1.125rem;
    }
}

/* General styles */

html {
    scroll-behavior: smooth;
}


body {
    background: var(--clr-light);
    color: var(--clr-dark);
    margin: 0;
    font-family: var(--ff-primary);
    font-size: var(--fs-body);
    line-height: 1.6;
}

#canvas {
    width: 100%;
    height: 100%;
    border: 2px solid red;
    z-index: -1;
}

/* #canvas {
    position: absolute;
    left: 0;
    top: 0;
    z-index: -1;
    width: 100%;
    height: 100%;
} */

section {
    padding: 5em 2em;
}

img {
    display: block;
    max-width: 100%;
}

strong {
    font-weight: var(--fw-bold)
}

:focus {
    outline: 3px solid var(--clr-accent);
    outline-offset: 3px;
}

/* Buttons */

.btn {
    display: inline-block;
    padding: .5em 2em;
    background: var(--clr-accent);
    color: var(--clr-dark);
    text-decoration: none;
    cursor: pointer;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 5px;
    font-weight: var(--fw-bold);
    transition: transform 200ms ease-in-out;
    margin: 15px;
    border-radius: 8px;
    border-style: groove;
    border-width: 3px;
    border-color: var(--clr-accent);
}

.btn2 {
    display: inline-block;
    padding: .4em 1em;
    background: var(--clr-accent);
    color: var(--clr-dark);
    text-decoration: none;
    cursor: pointer;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: var(--fw-bold);
    transition: transform 200ms ease-in-out;
    margin: 15px;
    border-radius: 8px;
    border-style: groove;
    border-width: 3px;
    border-color: var(--clr-accent);
}

.btn2:hover {
    transform: scale(1.2);
}

.btn:hover {
    transform: scale(1.2);
}

/* Typography */

h1,
h2,
h3 {
    line-height: 1;
    margin: 0;
}

h1 {
    font-size: var(--fs-h1)
}

h2 {
    font-size: var(--fs-h2)
}

h3 {
    font-size: var(--fs-h3)
}

.section__title {
    margin-bottom: .25em;
}


.section__title--intro {
    font-weight: var(--fw-reg);
}

.section__title--intro strong {
    display: block;
}

.section__subtitle {
    margin: 0;
    font-size: var(--fs-h3);
}

.section__subtitle--intro,
.section__subtitle--about {
    background: var(--clr-accent);
    padding: .25em 1em;
    font-family: var(--ff-secondary);
    margin-bottom: 1em;
}

.section__subtitle--work {
    color: var(--clr-accent);
    font-weight: var(--fw-bold);
    margin-bottom: 2em;
}


/* header */

header {
    display: flex;
    justify-content: space-between;
    padding: 1em;
}


.logo {
    max-width: 150px;
    z-index: 100;
}

.nav {
    position: fixed;
    background: var(--clr-dark);
    color: var(--clr-light);
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;

    transform: translateX(100%);
    transition: transform 250ms cubic-bezier(.5, 0, .5, 1);
}

.nav__list {
    list-style: none;
    display: flex;
    height: 100%;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
    margin: 0;
    padding: 0;
}

.nav__link {
    color: inherit;
    font-weight: var(--fw-bold);
    font-size: var(--fs-h2);
    text-decoration: none;
}

.nav__link:hover {
    color: var(--clr-accent);
}

.nav-toggle {
    padding: .5em;
    background: transparent;
    border: 0;
    cursor: pointer;
    position: absolute;
    right: 1em;
    top: 1em;
    z-index: 1000;
}

.nav-open .nav {
    transform: translateX(0);
}

.nav-open .nav-toggle {
    position: fixed;
}

.nav-open .hamburger {
    transform: rotate(.625turn);
}

.nav-open .hamburger::before {
    transform: rotate(90deg) translateX(-6px);
}

.nav-open .hamburger::after {
    opacity: 0;
}

.hamburger {
    display: block;
    position: relative;
}

.hamburger,
.hamburger::before,
.hamburger::after {
    background: var(--clr-accent);
    width: 2em;
    height: 3px;
    border-radius: 1em;
    transition: transform 250ms ease-in-out;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
}

.hamburger::before {
    top: 6px;
}

.hamburger::after {
    bottom: 6px;
}


/*  Intro section  */

.intro {
    position: relative;
}

.intro__img {
    box-shadow: var(--bs);
    border-radius: 8px;
}

.section__subtitle--intro {
    display: inline-block;
}

@media (min-width: 600px) {
    .intro {
        display: grid;
        width: min-content;
        margin: 0 auto;
        grid-column-gap: 1em;
        grid-template-areas:
            "img title"
            "img subtitle";
        grid-template-columns: min-content max-content;
    }

    .intro__img {
        grid-area: img;
        min-width: 300px;
        position: relative;
        z-index: 2;
    }

    .section__subtitle--intro {
        align-self: start;
        grid-column: -1 / 1;
        grid-row: 2;
        text-align: right;
        position: relative;
        left: -1.5em;
        width: calc(100% + 1.5em);
    }
}



/*  My services section  */

.my-services {
    background-color: var(--clr-dark);
    color: var(--clr-light);
    text-align: center;
    padding-top: 30px;
    padding-bottom: 30px;
}

.section__title--services {
    position: relative;
}

.section__title--services::after {
    content: '';
    display: block;
    width: 2em;
    height: 1px;
    margin: 0.5em auto 1em;
    background: var(--clr-light);
    opacity: 0.25;
}

.service {
    max-width: 500px;
    margin: 0 auto;
}

.service p:hover {
    color: var(--clr-accent);
}


.service p {
    font-family: var(--ff-secondary);
    font-size: 15px;
}

@media (min-width: 800px) {
    .services {
        display: flex;
        max-width: 1000px;
        margin-left: auto;
        margin-right: auto;
    }

    .service+.service {
        margin-left: 2em;
    }
}

.about-me {
    max-width: 1000px;
    margin: 0 auto;
    margin-top: -3%;
    margin-bottom: -3%;
}

.about-me__body {
    font-family: var(--ff-secondary);
    text-align: center;
}

.about-me__img {
    box-shadow: var(--bs);
    border-radius: 8px;
}

@media(min-width: 600px) {
    .about-me {
        display: grid;
        grid-template-columns: 1fr 200px;
        grid-template-areas:
            "title img"
            "subtitle img"
            "text img";
        grid-column-gap: 2em;
    }

    .section__title--about {
        grid-area: title;
    }

    .section__subtitle--about {
        grid-column: 1 / -1;
        grid-row: 2;
        position: relative;
        left: -1em;
        width: calc(100% + 2em);
        padding-left: 1em;
        padding-right: calc(200px + 4em);
    }

    .about-me__img {
        grid-area: img;
        position: relative;
        z-index: 2;
    }
}

/* My Work */

.my-work {
    background-color: var(--clr-dark);
    color: var(--clr-light);
    text-align: center;
    padding-top: 30px;
    padding-bottom: 40px;
}

.portfolio {
    display: grid;
    margin-left: 50px;
    column-gap: 20px;
    row-gap: 30px;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}


@media(min-width: 200px) {
    .portfolio__item {
        text-align: center;
        padding-right: 50%;

    }
}


@media(min-width: 250px) {
    .portfolio__item {
        text-align: center;
    }
}

@media(min-width: 350px) {
    .portfolio__item {
        text-align: center;
        padding-right: 60px
    }
}


.item-header1,
.item-header2,
.item-header3,
.item-header4,
.item-header5,
.item-header6 {
    text-align: center;
    color: white;
    display: flex;
    justify-content: center;
}

.item-header1:hover,
.item-header2:hover,
.item-header3:hover,
.item-header4:hover,
.item-header5:hover,
.item-header6:hover {
    color: var(--clr-accent);
}

.text1,
.text2,
.text3 {
    opacity: 0;
    position: absolute;
    text-align: center;
    font-weight: var(--fw-bold);
    margin-top: 10%;
    border: solid 2px;
    border-radius: 50%;
    padding: 20px;
    border-color: aqua;
    background-color: var(--clr-dark);
    width: 130px;
    height: 130px;
    font-size: 20px;
    color: var(--clr-accent);

}

.text4,
.text5,
.text6 {
    opacity: 0;
    position: absolute;
    text-align: center;
    font-weight: var(--fw-bold);
    margin-top: 40%;
    border: solid 2px;
    border-radius: 50%;
    padding: 20px;
    border-color: aqua;
    background-color: var(--clr-dark);
    width: 130px;
    height: 130px;
    font-size: 20px;
    color: var(--clr-accent);
}


.text1:hover,
.text2:hover,
.text3:hover,
.text4:hover,
.text5:hover,
.text6:hover {
    transition:
        transform 750ms cubic-bezier(.5, 0, .5, 1),
        opacity 250ms linear;
    opacity: 20;
}

.link {
    text-decoration: none;
    color: var(--clr-accent);
    text-align: center;
}

.text1,
.text4 {
    margin-left: 7%;
}

.text2,
.text5 {
    margin-left: 38%;
}

.text3,
.text6 {
    margin-left: 69%;
}


.portfolio__item {
    overflow: hidden;
    text-decoration: none;
}


.portfolio__img {
    transition:
        transform 750ms cubic-bezier(.5, 0, .5, 1),
        opacity 250ms linear;
    border-radius: 8px;
    border-style: double;
    border-color: var(--clr-accent);
    border-width: 10px;
}

.portfolio__item:focus {
    position: relative;
    z-index: 2;
}


.portfolio__img:hover,
.portfolio__item:focus .portfolio__img {
    opacity: .5;
}

/* footer */

.footer {
    background: #111;
    color: var(--clr-accent);
    text-align: center;
    padding: 2.5em 0;
    font-size: var(--fs-h3);
}

.footer a {
    color: inherit;
    text-decoration: none;
}

.footer__link {
    font-weight: var(--fw-bold);
}

.footer__link:hover,
.social-list__link:hover {
    opacity: .7;
}

.footer__link:hover {
    text-decoration: underline;
}

.social-list {
    list-style: none;
    display: flex;
    justify-content: center;
    margin: 2em 0 0;
    padding: 0;
}

.social-list__item {
    margin: 0 .5em;
}

.social-list__link {
    padding: .5em;
}

/* Individual portfolio item styles */

.portfolio-item-individual {
    padding: 0 2em 2em;
    max-width: 1000px;
    margin: 0 auto;
}

.portfolio-item-individual p {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}
<!DOCTYPE html>
<html lang="en">

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Megan Portfolio Website</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.css"
        integrity="sha256-46qynGAkLSFpVbEBog43gvNhfrOj+BmwXdxFgVK/Kvc=" crossorigin="anonymous" />

    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:400,900|Source+Sans+Pro:300,900&display=swap"
        rel="stylesheet">

    <link rel="stylesheet" href="css/style.css">

</head>

<body>

    <!-- Canvas -->

    <section height=90vh>
        <canvas id="canvas" width="100%" height="100vh" z-index="-1">
            <header height=10vh z-index="6">
            </header>



            <!-- (anything in here like social icons etc give them higher z-index then 5) -->

            <header>
                <div class="logo">
                    <img src="img/DevMegan2.png" alt="">
                </div>

                <!-- NAVBAR -->
                <button class="nav-toggle" aria-label="toggle navigation">
                    <span class="hamburger"></span>
                </button>
                <nav class="nav">
                    <ul class="nav__list">
                        <li class="nav__item"><a href="#home" class="nav__link">Home</a></li>
                        <li class="nav__item"><a href="#services" class="nav__link">My Skills</a></li>
                        <li class="nav__item"><a href="#about" class="nav__link">About me</a></li>
                        <li class="nav__item"><a href="#work" class="nav__link">My Work</a></li>
                    </ul>
                </nav>
            </header>

            <!-- Introduction -->
            <section class="intro" z-index="1000" id="home">
                <h1 class="section__title section__title--intro">
                    Hi, I am <strong>Megan Lynn</strong>
                </h1>
                <p class="section__subtitle section__subtitle--intro">Full-Stack Developer</p>
                <img src="img/me.jpg" width="770" alt="a picture of Megan smiling" class="intro__img">
            </section>
        </canvas>
    </section>


    <!-- My services -->

    <section class="my-services" id="services">
        <h2 class="section__title section__title--services">My Skills</h2>
        <div class="services">
            <div class="service">
                <h3>Programming Languages</h3>
                <p>Skilled in programming with back-end languages such as Python, C#, and C++. Can manage data
                    held
                    in
                    relational
                    databases using SQL. Have experience in front-end programming with JavaScript, HTML, and
                    CSS.
                </p>
            </div> <!-- / service -->

            <div class="service">
                <h3>Tools & Technologies</h3>
                <p>Experienced in the operating systems, Windows, Linux, and macOS. Know how to use
                    shell scripting. Have experience with using frameworks in Visual Studio Code such as, .NET
                    and
                    ASP.NET
                    MVC. Have some experience using React. </p>
            </div> <!-- / service -->

            <div class="service">
                <h3>Full-Stack Development</h3>
                <p>Have a variety of different skills and enjoy utilizing the back and front end to create Full
                    Stack applications and programs. Have made projects that connect to a back-end API and
                    database
                </p>
            </div> <!-- / service -->
        </div> <!-- / services -->

        <a href="#work" class="btn">My Work</a>
    </section>


    <!-- About me -->
    <section class="about-me" id="about">
        <h2 class="section__title section__title--about">Who I am</h2>
        <p class="section__subtitle section__subtitle--about">Developer based out of the East Coast, US</p>

        <div class="about-me__body">
            <p>Hello! Thank you for visiting my page! My name is Megan and I am currently a student in college.
                I
                will
                be graduating with my Bachelor's degree in both Computer Science and CIT & Cybersecurity as a
                double
                major
                in December, 2022. I maintain a 4.0 GPA. I am pursuing a career as a Software
                Developer/Engineer.
            </p>
            <p>I genuinely enjoy programming and solving problems. I am passionate about Software Development. I
                spend
                all of my free time learning as much as I can about it. I am getting better by the day. Practice
                makes
                perfect! I am extremely motivated and I believe anybody can do or solve anything if you really
                put
                your
                mind
                to it!</p>
        </div>

        <img src="img/me2.jpg" class="about-me__img">
    </section>

    <!-- My Work -->
    <section class="my-work" id="work">
        <h2 class="section__title section__title--work">My Projects</h2>
        <p class="section__subtitle section__subtitle--work">A selection of my range of work</p>
        <div class="portfolio">
            <!-- Portfolio item 01 -->
            <a href="https://loancalculate.azurewebsites.net/Home/App" target="blank" class="portfolio__item">
                <header class="item-header1">
                    <h3>Loan Calculator</h3>
                </header>
                <img src="img/LoanCalc.PNG" height="300" width="400" alt="" class="portfolio__img">
            </a>
            <div class="text1"><a href="https://loancalculate.azurewebsites.net/Home/App" class="link"
                    target="_blank">Open
                    Project</a>
            </div>

            <!-- Portfolio item 02 -->
            <a href="https://github.com/meganlynn21/Palindrome_Checker" target="blank" class="portfolio__item">
                <header class="item-header2">
                    <h3>Palindrome Checker</h3>
                </header>
                <img src="img/palindrome.png" height="300" width="400" alt="" class="portfolio__img">
            </a>
            <div class="text2"><a href="https://github.com/meganlynn21/Palindrome_Checker" class="link"
                    target="_blank">Open
                    Project</a>
            </div>

            <!-- Portfolio item 03 -->
            <a href="https://github.com/meganlynn21/Password-Validator" target="blank" class="portfolio__item">
                <header class="item-header3">
                    <h3>Password Validator</h3>
                </header>
                <img src="img/psswrd-validator.PNG" height="300" width="400" alt="" class="portfolio__img">
            </a>
            <div class="text3"><a href="https://github.com/meganlynn21/Password-Validator" class="link"
                    target="_blank">Open
                    Project</a>
            </div>

            <!-- Portfolio item 04 -->
            <a href="https://github.com/meganlynn21/Real-Estate-Calculator" target="blank" class="portfolio__item">
                <header class="item-header4">
                    <h3>Real Estate Calculator</h3>
                </header>
                <img src="img/Real-Estate-Img.PNG" height="300" width="400" alt="" class="portfolio__img">
            </a>
            <div class="text4"><a href="https://github.com/meganlynn21/Real-Estate-Calculator" class="link"
                    target="_blank">Open
                    Project</a>
            </div>

            <!-- Portfolio item 05 -->
            <a href="https://github.com/meganlynn21/ATM" target="blank" class="portfolio__item">
                <header class="item-header5">
                    <h3>ATM</h3>
                </header>
                <img src="img/atm.png" height="300" width="400" alt="" class="portfolio__img">
            </a>
            <div class="text5"><a href="https://github.com/meganlynn21/ATM" class="link" target="_blank">Open
                    Project</a>
            </div>

            <!-- Portfolio item 06 -->
            <a href="https://github.com/meganlynn21/shopping_list" target="blank" class="portfolio__item">
                <header class="item-header6">
                    <h3>Shopping List</h3>
                </header>
                <img src="img/shopping-list.png" height="300" width="400" alt="" class="portfolio__img">
            </a>
            <div class="text6"><a href="https://github.com/meganlynn21/shopping_list" class="link" target="_blank">Open
                    Project</a>
            </div>
        </div>
    </section>


    <!-- Footer -->
    <footer class="footer">
        <!-- My email -->
        <a href="mailto:[email protected]" target="blank" class="footer__link">@rosettastone0203</a>
        <ul class="social-list">
            <li class="social-list__item"><a class="social-list__link"
                    href="https://www.linkedin.com/in/megan-keyes-a81146224" target="blank"><i
                        class="fab fa-linkedin fa-2x"></i></a>
            </li>
            <li class="social-list__item"><a class="social-list__link" href="https://twitter.com/meganlynn22"
                    target="blank"> <i class="fab fa-twitter-square fa-2x"></i></a></li>
            <li class="social-list__item"><a class="social-list__link" href="https://github.com/meganlynn21"
                    target="blank"><i class="fab fa-github fa-2x"></i></a></li>
        </ul>
    </footer>


    <script src="js/index.js"></script>

</body>

</html>

jQuery maphighlight polygons are blurry – how to fix this?

We are building a little website where you can highlight parts of an image using jquery.maphilight.js. The background image is an SVG file and we have a script that exports the correct polygon coordinates for the overlay-polygons into html. Unfortunately, the highlight-polygons all look blurry (not the SVG background image, that’s fine). Why is that, and what can we do about it?

Here is the html code:

<!DOCTYPE html>
<html>
  <head>
    <title> My First Website </title>
    
  <style>
    h1 {
      text-align: center;
    }
    h2 {
       text-align: center;
    }    
    p {
       text-align: center;
    } 
    div.map {
      display: block;
      margin-left: auto;
       margin-right: auto;
    }
  </style>
    
    <meta charset="UTF-8">
    // ...    
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="jquery.maphilight.js"></script>
    
    <script>
      
      $(function() {
        $('.map').maphilight({
            fillColor: '008800'
       });
        $('#abcde').click(function(e) {
            e.preventDefault();
            var data = $(this).mouseout().data('maphilight') || {};
            data.alwaysOn = !data.alwaysOn;
            $(this).data('maphilight', data).trigger('alwaysOn.maphilight');
        });
    });
    </script>
  
  </head>
  
   <h1><u>title...</u></h1>
   <h2>subtitle...</h2>
   <br>
<p>
 <img src="assets/background.svg" alt="background..." height="X" width="600" class="map" usemap="#features"> 
 <map name="features">
    <area id="abcde" shape="poly" coords="483.5,233.5,483.5,237.5,485.5,240.5,485.5,244.5,484.5,246.5,484.5,247.5,484.5,250.5,485.5,251.5,486.5,251.5,487.5,251.5,490.5,251.5,492.5,251.5,492.5,249.5,492.5,245.5,491.5,244.5,491.5,241.5,494.5,237.5,494.5,234.5,493.5,233.5,493.5,233.5,491.5,232.5,489.5,231.5,487.5,231.5,485.5,232.5" href="#" alt="left_hand_ip5" class="group" data-maphilight='{"strokeColor":"000000","strokeWidth":0,"fillColor":"000000","fillOpacity":1}'>
  // ...
  </map>
</p>
  </body>
</html>

The .5 offset of all the coordinates is just one of the things we have tried to get rid of the blurryness, but it doesn’t work this way, nor with round coordinates.

Note: We are complete beginners with javascript, html, and css.

Cannot get basic index.js to work in simple mocha test project

I have a simple project laid out like:

project
│   package.json    
│
└───productA
│   │
│   └───test
│       │   spec1.js
│   
└───common
    index.js
    │
    └───sharedFunction1
        │   auth.js
        │   index.js
      

In spec1.js, I can successfully import a function from auth.js like this:

import { some_function } from "../../common/sharedFunction1/auth.js"

However, I thought that I should be able to use index.js files so that I can import like this:

import { some_function } from "../../common"

The function I am trying to import is something like (just a simple example):

export function get_file_listing (folder) {
    var files = fs.readdirSync(folder);
    return files
}

and my index.js under sharedFunction1 looks like:

export * from './auth';

and my index.js under common looks like:

export * from "./sharedFunction1";

VSCode auto import in the spec file seems to think the import should be:

import { some_function } from "../../common";

But when I run my test with that I get:

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import ... is not supported resolving ES modules imported from ...

My package.json has:

  "type": "module",

I have read a hundred different pages trying to understand what I am doing wrong, but am stuck. Can anyone tell me what I am doing wrong or if this should even work?

AJAX: Can I POST an array/data from my GET request? (Flask)

I am tying to POST an array, specifically the songFiles array, I have pushed with data from my AJAX GET request. Is there any way I can do this in the same call or any solution at all? Been trying to rack my brain, any help is welcomed, thanks :).

[My first question here, so I might be missing something]

    function getTableData(callback) {
    $.ajax({
        method: 'GET',
        url: '/api/getSong',
        dataType: 'json',
        success: function(data) {
            createMusicTable();
            
            let indexObj = Object.keys(data.song).length;
            
            for (var i = 0; i < indexObj; i++) {
                var song = data.song[i]
                var id = data.song[i].song_id;
                var fileName = data.song[i].song_file + '.mp3';
                
                songFiles.push(fileName);
                appendMusic(song, id);
                
                songTitle.id = "s" + i;
                console.log("td-ok");
                callback(songFiles);
            }
        }
    });
}

function callback(result){
    return fileNames 
}

Swiper JS – Change state of current sliderIndex with onClick property in React

There is a property on Swiper API where can i change the actualIndex of the slide? Because i need to create a custom button (check code below), when i click it, the slide change to the right position.

    export default function DestinationComponents({ planetInfo }: Props) {
  const [sliderState, setSliderState] = React.useState(0);

  const handleSliderChange = (param: any) => {
    param.realIndex = sliderState;
    console.log(param);
  };

  const handleSwiper = (swiper: any) => {};

  const handleSlideIndex = () => {
    console.log(sliderState);
    setSliderState(3);
  };

  return (
    <DestinationContainer>
      <BackgroundContainer>
        <Image src={destinationImage} layout="fill" />
      </BackgroundContainer>

      <TitleMain title={"01 PICK YOUR DESTINATION"} />
      <UlPlanets>
        <UlLiPlanets>MOON</UlLiPlanets> //HERE I NEED TO PUT MY LOGIC, WHERE ONCLICK REDIRECT TO THE CURRENT SLIDE.
        <UlLiPlanets onClick={handleSlideIndex}>MARS</UlLiPlanets>
        <UlLiPlanets>EUROPA</UlLiPlanets>
        <UlLiPlanets>TITAN</UlLiPlanets>
      </UlPlanets>
      <Swiper
        spaceBetween={0}
        slidesPerView={"auto"}
        centeredSlides={true}
        pagination={{ clickable: true }}
        scrollbar={{ draggable: true }}
        onSlideChange={handleSliderChange}
        onSwiper={handleSwiper}
        watchSlidesProgress={true}
      >
        {planetInfo.map((planet: any, idx: number) => {
          const imageRoot = planet.images.png.slice(1, planet.length);
          return (
            <SwiperSlide key={idx}>
              <PlanetSlider
                planetImage={imageRoot}
                planetTitle={planet.name}
                planetDescription={planet.description}
                distance={planet.distance}
                time={planet.travel}
              />
            </SwiperSlide>
          );
        })}
      </Swiper>
    </DestinationContainer>
  );
}

I already tried but i don’t know how to do it.

How to save JavaScript sessionStorage to django

I have an Sdk to call which returns an applicationID that I need to store in my django application so that if the user is approved can then move to the next page. I trying to save in JS sessionStorage than pass the data to another html page where I’m using ajax to pass it to my django views, the problem is that I need to have this data unique for the user that is logged in. How can I link this data to the current user logged in and so on?

const widget = window.getidWebSdk.init({
apiUrl: ”,
sdkKey: ”,
containerId: “targetContainer”,
flowName: ”,

onComplete: (data) => { 
    
    console.log(JSON.stringify(data))
    let appId = data; 
    console.log(data)
    sessionStorage.setItem("appId", JSON.stringify(appId))
    window.location.href = "/kycsubmit";
return;

},
onFail: ({ code, message}) => { console.log(“something went wrong: ” + message )},

});

second html page

    let application = JSON.parse(sessionStorage.getItem("appId"));
    let kycStatus = application.applicationId


    $.ajax({
    type: "GET",
    dataType: "json",
    url: `api/application/${kycStatus}`,
    headers: {
         'Content-Type': 'application/json',
         'X-API-Key': '',
        },
       
        success: function(data)  {
            document.getElementById("test").innerHTML = data.overallResult.status
            document.getElementById("test-1").innerHTML = application.applicationId
            console.log(data.overallResult.status)
            
        }
     

})

why is state not being updated?

Slice

import { createSlice } from '@reduxjs/toolkit';

const initialState: { value: number } = { value: 0 };

export const testSlice = createSlice({
  name: 'test',
  initialState,
  reducers: {
    test: (state) => {
      state.value += 1;
    },
  },
});

export const { test } = testSlice.actions;

Combine

import { combineReducers } from '@reduxjs/toolkit';

import { authSlice } from './auth';
import { productsSlice } from './products';
import { testSlice } from './test';
import { userSlice } from './user';

export const rootReducer = combineReducers({
  user: userSlice.reducer,
  auth: authSlice.reducer,
  products: productsSlice.reducer,
  test: testSlice.reducer,
});

export type RootState = ReturnType<typeof rootReducer>;

Store

import { configureStore } from '@reduxjs/toolkit';
import storage from 'utils/storage';

import { rootReducer } from './rootReducer';

declare global {
  interface Window {
    store: any;
  }
}

const reHydrateStore = () => {
  if (storage.getToken() !== null) {
    return storage.getToken();
  }
  return false;
};

// !TODO add types
// @ts-ignore
const localStorageMiddleware = (store) => (next) => (action) => {
  if (action.type.match('auth')) {
    const result = next(action);
    storage.setToken(store.getState().auth.token);
    return result;
  }
  return next(action);
};

export const store = configureStore({
  reducer: rootReducer,
  preloadedState: {
    auth: {
      token: reHydrateStore() || '',
      loading: false,
    },
  },
  middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(localStorageMiddleware),
});

window.store = store.getState();

When I output store.test to the console, the value remains old, but auth reducer works correctly.
Also I see that the state after the update in the reducers is 0.

Why is state not being updated?Why is state not being updated?Why is state not being updated?Why is state not being updated?Why is state not being updated?Why is state not being updated?Why is state not being updated?Why is state not being updated?Why is state not being updated?Why is state not being updated?Why is state not being updated?