React TypeError: Cannot read properties of undefined (reading ‘map’)

I am not sure what is going on here but it saying that the data is undefined, I have checked and the data is there in the redux store and can be console loged on the APP.js file

App.js

import React, { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import axios from "axios";

import "./App.css";
import { setAbsences } from "./store/absence/absences.action";
import { selectAbsences } from "./store/absence/absences.selectors";

function App() {
  const absence = useSelector(selectAbsences);
  const dispatch = useDispatch();

  useEffect(() => {
    const getAbsences = async () => {
      try {
        const result = await axios.get(
          `https://front-end-kata.brighthr.workers.dev/api/absences`
        );

        dispatch(setAbsences(result.data));
      } catch (error) {
        console.error("Error fetching absences:", error);
      }
    };
    getAbsences();
  }, []);

  return (
    <div className="App">
      <h1>List of absences</h1>

      {absence && absence?.absence?.length > 0 ? (
        absence?.absence.map((i) =>
          Object.entries(i).map((abs) =>
            abs[1].employee.map((n) => (
              <div className="card" key={i.id}>
                <>
                  <p>First Name: {n.firstName}</p>
                  <p>Last Name: {n.lastName}</p>
                </>
                <p>ID: {i.startDate}</p> <p>Start Date: {i.startDate}</p>{" "}
                <p>Days: {i.days}</p>
                <p>absenceType: {i.absenceType}</p>
                <p>Status: {i.approved}</p>
              </div>
            ))
          )
        )
      ) : (
        <p>No data Found</p>
      )}
    </div>
  );
}

export default App;

any help would be greatly appreciated, I have attached picture of my console.enter image description here

Disordered layout of form elements after displaying an error message

The problem is that when the form validation displays an error message under one of the inputs, the layout of elements on the page becomes disordered. Specifically, the error message causes the input field and “submit” button to move down only for that one field, resulting in the buttons not being aligned in a single horizontal line. Initial layout: We have two input fields with “submit” buttons next to each other. Initially, the layout looks aesthetically pleasing because both buttons are at the same height. Validation: When a user clicks the “submit” button and one of the input fields fails validation, an error message appears under that input field. Misaligned elements: Because the error message appears only under one input field, the height of that container increases, causing the “submit” button to move down only for that one field. As a result, the buttons are no longer aligned in a single line, which looks unsightly. How should I approach this?
https://codepen.io/dcielak/pen/ExzoENq

            <div class="inputs">
              <div>
                <div>
                  <input type="text" name="email" placeholder="Wpisz adres e-mail..." />
                </div>

                <div class="hidden">Podany e-mail jest błędny, wpisz poprawny adres</div>

                <div>
                  <button href="#">
                    <div>
                      <div>
                        send
                      </div>
                    </div>
                  </button>
                </div>
              </div>

              <div>
                <div>
                  <input type="text" name="email" placeholder="Wpisz adres e-mail..." />
                </div>

                <div hidden">Podany e-mail jest błędny, wpisz poprawny adres</div>

                <div>
                  <button href="#">
                    <div>
                      <div>
                        send
                      </div>
                    </div>
                  </button>
                </div>
              </div>
            </div>

Sphere coordinates display discontinuous images

As the title says, the program uses threejs
code below:

  const mouse = new THREE.Vector2();
  const pointer = new THREE.Vector2();
  window.addEventListener( 'mousemove', onMouseMove );
  function onMouseMove(ev) {
    mouse.x = ev.clientX / window.innerWidth;
    mouse.y = ev.clientY / window.innerHeight;
    ev.preventDefault();
    pointer.x = (ev.clientX / window.innerWidth) * 2 - 1;
    pointer.y = -(ev.clientY / window.innerHeight) * 2 + 1;
  }

  function animate() {
    requestAnimationFrame(animate)
    lightHandle()
    operate()
    render()
    stats.update()
  }

  function render() {
    camera.position.x = observer.x + v.x
    camera.position.y = observer.y + v.y
    camera.position.z = observer.z + v.z
    camera.lookAt(observer)
    renderer.render(scene, camera)
  }

  function operate() {
    omega.x = .5 * Math.PI * (-mouse.x + .5)
    omega.y = .5 * Math.PI * (mouse.y - .5)
    omega.z = .5 * Math.PI * (mouse.x - .5)
    v.x = Math.cos(theta.y + omega.y) * Math.sin(theta.x + omega.x) * .5
    v.y = Math.sin(theta.y + omega.y) * .5
    v.z = Math.cos(theta.y + omega.y) * Math.cos(theta.x + omega.x) * .5
  }

  function motion() { 
    theta.x = (theta.x + omega.x * .1) % (2 * Math.PI)
    theta.y = (theta.y + omega.y * .1) % (2 * Math.PI)
    theta.z = (theta.z + omega.z * .1) % (2 * Math.PI)
  }

  init()
  animate()

Mouse movement animation will jump unnaturally like below

The animation in the video is not continuous

The following video :

https://drive.google.com/file/d/1fpFu89KlFGR-9zxzq1iqYdk60JPJKkxX/view?usp=sharing

animation display smooth and natural.

crousal effect not working in loop for the text section, it keeps on getting stuck on 4th section, not coming back on first again

This is my code. I set the carousel for both the texts container and images container. The images section is working perfectly fine but the same functionality is not working for the text section. The text carousel section stops after it reaches the last part, but I want it to keep going in loop like it goes for the images. I can’t seem to find the problem.

import { useRef, useEffect } from 'react';

const Marc = () => {
    const textSections = [
        {
            id: 1,
            heading: "Garbage in energy out: what you need to know when developing waste-to-energy projects",
            subheading: "Resource management and circular economy",
            paragraph: "Rapid urbanisation in Southeast Asia means increased waste that needs to be managed. While this is clearly a challenge given that the regions population Rapid urbanisation in Southeast Asia means increased waste that needs to be managed. While this is clearly a challenge given that the regionpopulation is exis expected to rise from about 686.825 million to 724.664 million..."
        },
        {
            id: 2,
            heading: "The importance of recycling: how it helps our environment",
            subheading: "Sustainability and the future",
            paragraph: "Recycling plays a crucial role in managing waste and preserving natural resources. It helps reduce pollution and conserves materials that can be reused in new products.Rapid urbanisation in Southeast Asia means increased waste that needs to be managed. While this is clearly a challenge given that the regionopulation is ex"
        },
        {
            id: 3,
            heading: "Innovative approaches to waste management",
            subheading: "Modern solutions",
            paragraph: "Innovation in waste management includes new technologies and practices that aim to reduce waste and increase efficiency in waste handling and recycling processes.Rapid urbanisation in Southeast Asia means increased waste that needs to be managed. While this is clearly a challenge given that the regionpopulation is ex"
        },
        {
            id: 4,
            heading: "Circular economy: a model for sustainable development",
            subheading: "Economic and environmental benefits",
            paragraph: "A circular economy promotes the reuse, repair, refurbishment, and recycling of materials to create a closed-loop system, minimizing waste and making the most of available resources.Rapid urbanisation in Southeast Asia means increased waste that needs to be managed. While this is clearly a challenge given that the regionpulation is ex"
        },
    ];

    const imageSections = [
        {
            src: "sec1.jpg",
            alt: "Building 1"
        },
        {
            src: "sec2.jpg",
            alt: "Building 2"
        },
        {
            src: "sec3.jpg",
            alt: "Building 3"
        },
        {
            src: "sec4.jpg",
            alt: "Building 4"
        }
    ];

    const textScrollRef = useRef(null);
    const imageScrollRef = useRef(null);

    const scrollTextCarousel = () => {
        if (textScrollRef.current) {
            const { scrollLeft, clientWidth, scrollWidth } = textScrollRef.current;
            if (scrollLeft + clientWidth >= scrollWidth) {
                setTimeout(() => {
                    textScrollRef.current.scrollTo({ left: 0, behavior: 'smooth' });
                }, 1000);
            } else {
                textScrollRef.current.scrollBy({ left: clientWidth, behavior: 'smooth' });
            }
        }
    };

    const scrollImageCarousel = () => {
        if (imageScrollRef.current) {
            const { scrollLeft, clientWidth, scrollWidth } = imageScrollRef.current;
            if (scrollLeft + clientWidth >= scrollWidth) {
                setTimeout(() => {
                    imageScrollRef.current.scrollTo({ left: 0, behavior: 'smooth' });
                }, 1000);
            } else {
                imageScrollRef.current.scrollBy({ left: clientWidth, behavior: 'smooth' });
            }
        }
    };

    useEffect(() => {
        const textInterval = setInterval(scrollTextCarousel, 3000);
        const imageInterval = setInterval(scrollImageCarousel, 3000);

        return () => {
            clearInterval(textInterval);
            clearInterval(imageInterval);
        };
    }, []);

    return (
        <div className="h-screen relative flex">
            {/* Text Carousel */}
            <div className="text-background-container absolute w-[42%] ml-10 h-screen bg-gray-300 z-10 overflow-hidden" ref={textScrollRef}>
                <div className="flex">
                    {textSections.map((section) => (
                        <div key={section.id} className=" w-full h-full relative p-8 bg-transparent z-10 flex-shrink-0 mt-28">
                            <h2 className="subheading text-xl my-14 text-balance">{section.subheading}</h2>
                            <h1 className="heading text-4xl mb-16 text-balance">{section.heading}</h1>
                            <p className="paragraph text-lg mr-20 font-normal text-balance">
                                {section.paragraph}
                            </p>
                        </div>
                    ))}
                </div>
            </div>

            {/* Image Carousel */}
            <div className="image-container absolute top-1/4 right-[160px] w-[50%] h-[62vh] bg-gray-500 z-20 overflow-hidden" ref={imageScrollRef}>
                <div className="flex">
                    {imageSections.map((image, index) => (
                        <div key={index} className="w-full h-full relative flex-shrink-0">
                            <img src={image.src} alt={image.alt} className="w-full h-full object-cover" onError={() => console.error(`Error loading image ${image.src}`)} />
                        </div>
                    ))}
                </div>
            </div>
        </div>
    );
};

export default Marc;

React. When calling useNavigate, redirection happens, but components do not load

Here is my simple authentication component LoginServiceProvider.tsx:

import { useState } from "react";
import {auth, googleProvider} from "../../config/firebase";
import "./Login.css";
import {saveUserType} from "../../service/profile-repository";
import {UserType} from "../../constants/UserType";
import {Link, useNavigate} from "react-router-dom";

const LoginServiceProvider = () => {
    const [email, setEmail] = useState("");
    const [password, setPassword] = useState("");
    const navigate = useNavigate();

    const signIn = async () => {
        try {
            await signInWithEmailAndPassword(auth, email, password);
            navigate('/');
        } catch (error) {
            console.log(error);
        }
    }
    const signUpWithGoogle = async () => {
        try {
            const user: UserCredential = await signInWithPopup(auth, googleProvider);
            await saveUserType(user.user.uid, UserType.SERVICE_PROVIDER)
            navigate('/');
        } catch (error) {
            navigate('/error');
        }
    }

    return (
        <div className="container">
            <div className="header">Service Provider Sign In</div>
            <input
                className="input"
                placeholder="Email.."
                onChange={(e) => setEmail(e.target.value)}
            />
            <input
                type="password"
                className="input"
                placeholder="Password.."
                onChange={(e) => setPassword(e.target.value)}
            />
            <button className="button" onClick={signIn}>Sign In</button>
            <button className="button google-button" onClick={signUpWithGoogle}>Sign In With Google</button>
            <p>Don't have an account? <Link to="/signup">Sign Up</Link></p>
        </div>
    )
}

export default LoginServiceProvider;

Here is my router configuration:

import ReactDOM from 'react-dom/client';
import './index.css';
import reportWebVitals from './reportWebVitals';
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import { AuthProvider } from "./contexts/AuthContext";
import {Login} from "./views/authentication/Login";
import LoginServiceProvider from "./views/authentication/LoginServiceProvider";
import {LoginClient} from "./views/authentication/LoginClient";
import SignUp from "./views/authentication/SignUp/SignUp";
import SignUpServiceProvider from "./views/authentication/SignUp/SignUpServiceProvider";
import SignUpClient from "./views/authentication/SignUp/SignUpClient";
import ServiceProviderProfile from "./views/user/ServiceProviderProfile";
import OrderPage from "./views/order-page/OrderPage";
import ErrorPage from "./views/error/ErrorPage";
import ProfileForm from "./components/profile-form/ProfileForm";
import MyOrders from "./views/my-orders/MyOrders";
import Messages from "./views/messages/Messages";
import Navbar from "./components/navbar/Navbar";
import MyOrder from "./views/my-order/MyOrder";
import App from "./views/app/App";


const root = ReactDOM.createRoot(
    document.getElementById('root') as HTMLElement
);
root.render(
    <React.StrictMode>
        <AuthProvider>
                <Router>
                    <Navbar/>
                    <Routes>
                        <Route path="/" element={<App/>} />
                        <Route path="/login" element={<Login />} />
                        <Route path="/login-service-provider" element={<LoginServiceProvider />} />
                        <Route path="/login-client" element={<LoginClient />} />
                        <Route path="/signup" element={<SignUp />} />
                        <Route path="/signup-service-provider" element={<SignUpServiceProvider />} />
                        <Route path="/signup-client" element={<SignUpClient />} />
                        <Route path="/profile/serviceProvider/:id" element={<ServiceProviderProfile />} />
                        <Route path="/profile/client" element={<ProfileForm />} />
                        <Route path="/messages" element={<Messages />} />
                        <Route path = "/my-orders" element={<MyOrders/>} />
                        <Route path = "/my-orders/:orderId" element={<MyOrder/>} />
                        <Route path="/new-order/:orderName" element={<OrderPage />} />
                        <Route path="/error" element={<ErrorPage />} />
                        <Route path="*" element={<ErrorPage />} />
                    </Routes>
                </Router>
        </AuthProvider>
    </React.StrictMode>
);

reportWebVitals();

Here is AuthContext:

import { auth } from "../config/firebase";
import {getUserType} from "../service/profile-repository";
import {UserType} from "../constants/UserType";
import {SocketProvider} from "./SocketContext";


export interface CurrentUser {
    firebaseUser: any|null,
    loading: boolean,
    userType: string | null,
}

const AuthContext = createContext<any>(undefined)
export const useAuth = () => useContext(AuthContext);

export const AuthProvider = ({ children } : any) => {
    const [firebaseUser, setFirebaseUser] = useState<any>(null)
    const [loading, setLoading] = useState<boolean>(true)
    const [userType, setUserType] = useState<string|null>(null)


    useEffect(() => {
        const unsubscribe = auth.onAuthStateChanged(async fbUser => {
            setFirebaseUser(fbUser)
            if(fbUser) {
                const user = await getUserType(fbUser.uid)
                if(user){
                    setUserType(user.userType)
                } else {
                    setUserType(null)
                }
            }

            setLoading(false)
        })
        return unsubscribe
    }, [])

    const value: CurrentUser = {
        firebaseUser: firebaseUser,
        loading: loading,
        userType: userType,
    }

    return (
        <AuthContext.Provider value={value}>
            {firebaseUser ? (
                <SocketProvider>
                    {children}
                </SocketProvider>
            ) : children}
        </AuthContext.Provider>
    )
}

And finally, when I navigate to “/” I just want to load App component once I have successfully logged in:

const App = () => {
    console.log('Inside app');
    return (
        <div>
            <h1>App Component</h1>
        </div>
    );
};

export default App;

So when I log in with google account, I call the navigate, the path in URL changes to “/”, however the App component is not loaded, the login window stays as it is (find the attached screenshots). Any suggestions, feedback will be highly appreciated. Thank you very much for your attention.

enter image description here

When choice one section go to content current section in elementor widget development

Hell, my Bro
I have developed a widget for Elementor.
My widget have two section.

$this->start_controls_section(
'section1',
[
'label' => 'Section 1',
'tab' => ElementorControls_Manager::TAB_CONTENT,
]
);
//The Content 1
$this->end_controls_section();
$this->start_controls_section(
'section2',
[
'label' => 'Section 2',
'tab' => ElementorControls_Manager::TAB_CONTENT,
]
);
//The Content 2
$this->end_controls_section();

i want when click section2 in elementor go to content 2.

how do i do?

when click section2 don’t go content 2 and stay in content 2.

please help me…
thank’s

How do I get the value for a color picker in ShinyR?

In my ShinyR APP I am trying to get value from color picker. Using onevent I can get and put value in input control but when I am pressing save button (which triggers onclick event), I am receiving just “null” or empty value from the input control. Why input[['titleColorChart']] gives me “null” or empty instead of right value.

library(shiny)
library(shiny)
library(shinyjs)
library(DT)
library(shinyjqui)

ui <- fluidPage(
  useShinyjs(),  # Set up shinyjs
  extendShinyjs(text = jsCode, functions = c("updateColorTagValue")),
  div(tags$input(id = str_c("titleColorChart","1"),
                 name = str_c("titleColorChart","1"),
                 selector = str_c("titleColorChart","1"),
                 type = "color",
                 `data-role` = "color-selector",
                 value = "",
                 class = "form-control input-xs",
                 style = "width: 20px;padding: 0;border: none;/* margin: 0; */"),
      tags$input(id = str_c("titleColorChart"),
                 name = str_c("titleColorChart"),
                 selector = str_c("titleColorChart"),
                 type = "text",
                 value = "",
                 class = "form-control input-xs",
                 style = "padding: 0;border: none;/* margin: 0; */")
  ),
  tags$button(id = "save",
              type = "button",
              class = "tool-button",
              span("Save"))
  
)

server <- function(input, output, session) {
  jsCode <- "

shinyjs.updateColorTagValue= function(params){ 
var colorString;
colorString = JSON.stringify($('#' + params[0] + '1').val());  
colorString =  colorString.substring(1, colorString.length-1);
alert(colorString)
$('#' + params[0] + '1' ).attr('value',colorString);
$('#' + params[0]).attr('value',colorString);
 Shiny.setInputValue('#' + params[0] + '', colorString);
Shiny.onInputChange(params[0],params[1]);     
}


" 
nameOfDropDownList <- "titleColorChart"
observeEvent(input[[str_c(nameOfDropDownList,"1")]], {
   input[[nameOfDropDownList]] <- input[[str_c(nameOfDropDownList,"1")]]
 
})
observe({
  input[[str_c(nameOfDropDownList,"1")]]
  output[[nameOfDropDownList]] <- renderText({
    input[[str_c(nameOfDropDownList,"1")]]
  })
})
observeEvent(input$save, {
  updateColourInput(session, "titleColorChart",
                    value = input$titleColorChart1
                    )
})


onevent("change", str_c(nameOfDropDownList,"1") ,js$updateColorTagValue(nameOfDropDownList, input$titleColorChart))
onclick("save",alert(input[["titleColorChart"]]))


}

shinyApp(ui, server)

Modal Transition Issues Vue

‏‏‎

I’ve been trying to make my modal slowly come into view after being trigger but it just jumps into view. I suspect it has to do with my stylings but I can’t seem to find where I went wrong. Do I need to have the transition property in the CSS stylings or no? I’m suspecting that might be a reason but when I changed it, I still did not get the expected result.

Any help would be appreciated. Thanks!
[Removed script section since triggering occurs as expected]

<template>
  <div class="header">
    <p :class="{ selected: selectedTitle === 'Chem Viz' }" @click="toggleTo('Chem Viz')">Chem Viz</p>
    <p :class="{ selected: selectedTitle === 'Stories' }" @click="toggleTo('Stories')">Stories</p>
    <p :class="{ selected: selectedTitle === 'About' }" @click="toggleTo('About')">About</p>
    <p><img src="../assets/logo.png" width="100" height="100"></p>
  </div>
  <div class="row">
    <TransitionGroup name="slide" mode="out-in">
      <div class="box" v-for="item in showBlocks" :key="item" @click="toggleExpand(item)">
        <div v-if="expandedItem === item">
          <button @click.stop="closeExpanded">Close</button>
          <component :is="expandedComponent"></component>
        </div>
        <div v-else>
          {{ item }}
        </div>
      </div>
    </TransitionGroup>
  </div>
  <transition name="modal-overlay">
    <div v-if="expandedItem" class="modal-overlay" @click="closeExpanded">
      <transition name="modal-content">
        <div class="modal-content" @click.stop v-if="expandedComponent">
          <component :is="expandedComponent"></component>
          <button class="close-button" @click="closeExpanded">Close</button>
        </div>
      </transition>
    </div>
  </transition>
</template>


<style scoped>
  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 72px;
    font-size: 30px;
    font-weight: 300;
    padding: 20px;
  }
  .header p {
    cursor: pointer;
    transition: font-size 0.3s ease-in-out, font-weight 0.3s ease-in-out;
    min-height: 72px;
    margin: 0;
    align-items: center;
  }
  
  .header p.selected {
    font-size: 72px;
    font-weight: 500;
  }
  
  .row {
    text-align: center;    
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .box {
    width: calc(50% - 60px);
    height: 600px;
    border: 1px solid blue;
    padding: 10px;
    margin: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-sizing: border-box;
    transition: transform 0.7s ease, opacity 0.7s ease;
    cursor: pointer;
  }

  .slide-enter-active, .slide-leave-active {
    transition: transform 0.7s ease, opacity 0.7s ease;
    position: relative;
  }
  
  .slide-enter {
    opacity: 0;
    transform: translateX(-100%);
    position: absolute;
  }

  .slide-enter-to {
    opacity: 0;
    transform: translateX(-100%);
  }
  
  .slide-leave-to {
    opacity: 0;
    transform: translateX(100%);
  }

  .modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 1;
  transition: transform 0.7s ease, opacity 0.7s ease;
  }

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  width: 100%;
  max-height: 100%;
  overflow: auto;
  opacity: 1;
  transition: transform 0.7s ease, opacity 0.7s ease;
}

.close-button {
  position: absolute; 
  top: 10px;
  right: 10px;
  cursor: pointer;
}

.modal-overlay-enter-active,
.modal-overlay-leave-active {
  transition: opacity 0.7s ease;
}

.modal-overlay-enter,
.modal-overlay-leave-to {
  opacity: 0;
}

.modal-content-enter,
.modal-content-leave-to {
  transform: scale(0.7); 
  opacity: 0; 
}

.modal-content-enter-active,
.modal-content-leave-active {
  transition: transform 0.7s ease, opacity 0.7s ease; /* Smooth transform and opacity transition */
}

</style>

How to perform a case-insensitive search based on a specific field value in Firestore?

I am trying to perform a query in Firestore where the field name and value should be matched irrespective of the case.
For example:
fruit = manGo , value = mango

code which considers case :

 const q = query(collection(db, 'CollectionName'), where(fruit, '==', value));

How can I perform case-insensitive queries in Firestore, and are there alternative solutions or best practices beyond storing and querying a lowercase version of the field?

querySelectorAll doesn’t select all objects

I want to save data from cards.I am saving data from card inputs with contain the same name. Cards added dynamically. querySelectorAll contains data from first card only without data from dynamically added cards.
Selecting cards

document.querySelectorAll('.cards').forEach((card) => {
        
        let term = card.querySelector('input[name="term"]').value.trim();
        let definition = card.querySelector('input[name="definition"]').value.trim();
        if (term && definition) {
            cards.push({Term: term, Definition: definition});
        }
    })

View

        <form asp-controller="Cards" asp-action="Create" method="post" class="cards">
            <div class="card mt-6" id="card">
                <div class="header d-flex justify-content-between p-3">
                    <h4 class="card-counter">1</h4>
                </div>
                <div class="card-body row">
                    <div class="term col">
                        <h3>Term</h3>
                        <input class="form-control w-100" name = "term" >
                    </div>
                    <div class="definition col">
                        <h3>Definition </h3>
                        <input class="form-control w-100" name = "definition"  >
                    </div>
                </div>
            </div>

            <input type="submit" value="Create" id="create-cards" class="btn btn-primary mt-2"/>
        </form>
        <button class="new-card w-100 d-flex justify-content-center align-items-center mt-4 mt-s rounded-2" style="height: 5rem"  type="button">
            <h3>+ Add card</h3>
        </button>

Function adding new Cards

function addCard() {

    let termInput = document.querySelector('.term input');
    let definitionInput = document.querySelector('.definition input');

    /*    const cardData = {
            Term: termInput.value.trim(),
            Definition: definitionInput.value.trim(),
        };*/
    currentCardNumber++;
    let newCardHTML = `
                    <div class="header d-flex justify-content-between p-3">
                        <h4 class="card-counter">${currentCardNumber}</h4>
                    </div>
                    <div class="card-body row">
                        <div class="term col">
                            <h3>Term</h3>
                            <input class="form-control w-100" name = "term" >
                        </div>
                        <div class="definition col">
                            <h3>Definition </h3>
                            <input class="form-control w-100" name="definition" >
                        </div>
                    </div>
            </div> `;
    let newCard = document.createElement('div');
    newCard.classList.add('card');
    newCard.classList.add('mt-3');
    newCard.innerHTML = newCardHTML;

    let addNewCard = document.querySelector('.cards');
    let referenceNode = document.getElementById('create-cards');
    addNewCard.insertBefore(newCard, referenceNode);
    saveCardsHTML();
    updateCounter();

}
document.addEventListener('DOMContentLoaded', function () {
    let newCard = document.querySelector('.new-card');
    newCard.addEventListener('click', function () {
        addCard();
    });
});

I believe the issue may be related to the addition of dynamic cards.

I can’t create server with discord-selfbot-v13

When i call function client.guilds.create i have this error:

C:Usersdsnode_modulesdiscord.js-selfbot-v13srcrestRequestHandler.js:415
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Unknown Message
    at RequestHandler.execute (C:Usersdsnode_modulesdiscord.js-selfbot-v13srcrestRequestHandler.js:415:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async RequestHandler.push (C:Usersdsnode_modulesdiscord.js-selfbot-v13srcrestRequestHandler.js:63:14)
    at async GuildManager.create (C:Usersdsnode_modulesdiscord.js-selfbot-v13srcmanagersGuildManager.js:228:18) {
  method: 'post',
  path: '/guilds',
  code: 10008,
  httpStatus: 403,
  requestData: {
    json: {
      name: 'Test',
      icon: null,
      verification_level: undefined,
      default_message_notifications: undefined,
      explicit_content_filter: undefined,
      roles: [],
      channels: [],
      afk_channel_id: undefined,
      afk_timeout: undefined,
      system_channel_id: undefined,
      system_channel_flags: undefined
    },
    files: [],
    headers: undefined
  },

I’ve tried it on another accounts, same results. Error doesn’t help too.

javascript_importmap_tags is creating a link to “application.js” with error

I am working on adding javascript handling to a rails 7 app. I want to use import maps to import external libraries for turbo and stimulus. The current issue I’m having trouble with is that javascript_importmap_tags is adding an unusable link to my application:

<link rel="modulepreload" href="/application.js">

This gives me this error :

GET http://localhost:3000/application.js net::ERR_ABORTED 404 (Not Found)

I have an application.js file in app/javascript. I don’t understand why the call to javascript_importmap_tags is creating a link to a nonexistent javascript file at the application root. I think I must be missing a step somewhere. What do I need to do to make the application.js file load?

This is my importmap.rb file:

pin "application"

and my application.js file is currently just comments:

// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails

// import "stimulus.min.js"
// import "stimulus-loading.js"
// import "controllers"
// import "@hotwired/turbo-rails"

Please feel free to look at the source for the application here:
https://github.com/fredwillmore/climate-control

How to correctly iterate over childs in slot and interact with them?

I want to create a component in Vue like the Ribbon component in Microsoft Office applications. (This: https://en.wikipedia.org/wiki/Ribbon_%28computing%29)

The usage of the component in templates should be like putting components in components.
Like you place a <RibbonComponent> ... </RibbonComponent>, and inside that component’s “tag” you write <RibbonTab>‘s.

This is what I mean about the usage of the component:

<RibbonComponent>
    <RibbonTab title="Edit" />
    <RibbonTab title="Selection" />
    <RibbonTab title="Help" />
</RibbonComponent>

See my code in the Vue SFC playground (not working)

I’m just doing it with a <slot> defined in the RibbonComponent, and the RibbonTab‘s are actually just multiple children on the top level in the hierarchy inside that slot.

For the tab buttons on top, I just iterate over the childs in the slot and render buttons in a template loop inside the RibbonComponent template.

When one of those buttons is clicked, I have to switch the visibility of the corresponding RibbonTab. The way I’m trying to do this doesn’t work and seems to be cumbersome at all. All manipulations to the childs of the slot don’t have any effect. See data field tabs in the RibbonComponent. When I console.log that tabs, I see an array of objects which are probably something like copies of vnodes.

When I peek at existing component libraries, I see a template markup exactly as I want. See this example of an existing component library. As you can see, the template code is like:

<template>
  <ejs-ribbon id="ribbon">
    <e-ribbon-tabs>
      <e-ribbon-tab header="Home">
        <e-ribbon-groups>
          <e-ribbon-group header="Clipboard" orientation="Row"></e-ribbon-group>
        </e-ribbon-groups>
      </e-ribbon-tab>
    </e-ribbon-tabs>
  </ejs-ribbon>
</template>

<script>
import { RibbonComponent, RibbonTabDirective, RibbonTabsDirective, RibbonGroupDirective, RibbonGroupsDirective } from "@syncfusion/ej2-vue-ribbon";
export default {
  components: {
    'ejs-ribbon': RibbonComponent,
    'e-ribbon-tab': RibbonTabDirective,
    'e-ribbon-tabs': RibbonTabsDirective,
    'e-ribbon-groups': RibbonGroupsDirective,
    'e-ribbon-group': RibbonGroupDirective
  }
};
</script>

But when reading that code, I actually don’t understand how it works. The <e-ribbon-tabs> gets my attention, because that imported component’s name has something to do with a directive but when I think of what directives are in Vue, I don’t understand if it even relates to that.

Function that use Sliding Window isn`t working

The function should return the length of the maximum substring in which there are no duplicate characters, but the program runs for an infinite amount of time

function findMaxLength(str) {
  let right = 0;
  let left = 0;
  let answer = 0;
  let arr = [];

  while (right < str.length) {
    let ch = str.split("")[right];
    if (!arr.includes(ch)) {
      arr.push(ch);
      answer = Math.max(answer, (right - left + 1));
      right++;
    } else {
      while (arr.includes(ch)) {
        arr.splice(left, 1);
        left++;
      }
    }
  }

  return answer;
}