Unable to get the expected result for merging the array inside of an array of objects in react js

I am having an array consists of 2 objects and each object again consists of an array of objects. I need to combine those inside array of objects.
please find the code below.

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

export const data = [
  {
    accountNo: '1xxx',
    consolidateddata: [
      { name: 'Paypal', expiry: '05/13/2023' },
      { name: 'phonepay', expiry: '05/19/2023' },
    ],
  },
  {
    accountNo: '2xxx',
    consolidateddata: [{ name: 'Paytm', expiry: '05/25/2023' }],
  },
];
export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      DataRows: [],
    };
    this.ProfileDetails = this.ProfileDetails.bind(this);
  }

  ProfileDetails = (profileData, index) => {
    const newData =
      profileData.consolidateddata &&
      profileData.consolidateddata.map((obj) => {
        return obj;
      });
    this.setState({ DataRows: newData });
  };

  componentDidMount() {
    data && data.forEach(this.ProfileDetails);
  }

  render() {
    console.log(this.state.DataRows);

    return (
      <div className="App">
        <h1>sample</h1>
      </div>
    );
  }
}

currently I am getting only one object(second row object array) in an array instead of 3 objects. can anybody suggest on this to get 3 combined objects like this

[ { name: 'Paypal', expiry: '05/13/2023' },
{ name: 'phonepay', expiry: '05/19/2023' }, { name: 'Paytm', expiry: '05/25/2023' } ]

stackblitz link https://stackblitz.com/edit/react-drpgcx?file=src%2FApp.js

open this page in “iTunes”?

enter image description here

I have a web based ipa distribution application that I wrote using javascript and angular. Try the warning in the image when I press download via Safari. I don’t want to see this warning. Anyone have information on the subject?

an example of my url schema: itms-services:///?action=download-manifest&url=

I tried bypassing the popup but with no results

Am I trying to make a on-page option filter for a little website project

My website design came out good but the script didn’t execute. I couldn’t find the problem and tried reviewing my code but still nothing yet. Could you please help me? My last resorts all did not work out but when I checked the source it worked so I do not know what I did wrong. I tried removing and adding a few elements but for some reason the hide element didn’t work at all so I have no other way but to ask for advice in here.

Here’s the code:

<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web test</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<link href="style.css" rel="stylesheet">
</head>
<body>
<!-- Start your code here -->

  <div class="wrapper">
    <div id="buttons">
      <button class="button-value" onclick="filterSchool('all')">All</button>
      <button class="button-value" onclick="filterSchool('Catholic')">Catholic School</button>
      <button class="button-value" onclick="filterSchool('Regular')">Regular School</button>
      <button class="button-value" onclick="filterSchool('University')">University</button>
      <button class="button-value" onclick="filterSchool('College')">College</button>
    </div>
    <div id="schools"></div>
  </div>
  
<!-- End your code here -->
<script src="script.js"></script>
</body>
</html>




*{
  padding: 0;
  margin: 0;
  box-sizing:  border-box;
  border: none;
  outline: none;
  font-family: 'Poppins', sans-serif;
}

body{
  background-color: white;
}

button{
    cursor: pointer;
}

.wrapper{
    position: absolute;
    top: 5%;
    left: 20%;
    width: 95%;
    margin: 0 auto;
}

.button-value{
  border: 2px solid black;
  padding: 0.5px 10px;
  border-radius: 3em;
  background-color: transparent;
  transition: 0.3s ease-in-out;
}

.button-value:focus{
    background-color: black;
    color: white;
}

#schools{
    display: grid;
    grid-template-columns: auto auto auto;
    grid-column-gap: 1.5em;
    padding: 2em 0;
}

.card{
    background-color: white;
    max-width: 18em;
    margin-top: 1em;
    padding: 1em;
    border-radius: 5px;
    box-shadow: 1em 2em 2.5em rgba(0,0,0,0.19);
}

.image-container{
    text-align: center;
}

img{
    max-width: 100%;
    object-fit: contain;
    height: 15em;
}

.container{
    padding-top: 1em;
    color: black;
}

@media screen and (max-width: 720px){
    img{
        max-width: 100%;
        object-fit: contain;
        height: 10em;
    }
    
    .card{
        max-width: 10em;
        margin-top: 1em;
    }
    
    #schools{
        grid-template-columns: auto auto;
        grid-column-gap: 1em;
    }
}



let schools = {
    data:[
    {
            schoolName: "Edmonton Catholic School District",
            category: "Catholic",
            image: "ecsd.png"   
    },
    {
            schoolName: "Edmonton Public School",
            category: "Regular",
            image: "publicimg.jpg"  
    },
    {
            schoolName: "Northern Alberta Institution of Technology",
            category: "College",
            image: "NAIT.png"   
    },
    {
            schoolName: "University of Alberta",
            category: "University",
            image: "University-of-Alberta.png"  
    },
    ],
};

for(let i of schools.data){
    //Create Card
    let card = document.createElement("div");
    
    //Card category and should be hidden
    card.classList.add("card", i.category, "hide");
    
    //Image div
    let imgContainer = document.createElement("div");
    imgContainer.classList.add("image-container");
    
    //img tag
    let image = document.createElement("img");
    image.setAttribute("src", i.image);
    imgContainer.appendChild(image);
    card.appendChild(imgContainer);
    
    //container
    let container = document.createElement("div");
    container.classList.add("container");
    
    //School name
    let name = document.createElement("h5");
    name.classList.add("school-name");
    name.innerText = i.schoolName.toUpperCase();
    container.appendChild(name);
    
    card.appendChild(container);
    document.getElementById("schools").appendChild(card);
}

function filterSchool(value){
    
    let elements = document.querySelectorAll(".card");
    elements.forEach((element) => {
        if(value == "all"){
            element.classList.remove("hide");
        }else{
            if(element.classList.contains(value)){
                element.classList.remove("hide");
            }else{
                element.classList.add("hide");
            }
        }
    });
}

windows.onload = () => {
    filterSchool("all");
}

Fetch distinct id’s based on few criteria in Angular

In Angular, I am trying to fetch distinct id’s based on few condition. Below are the details

JSON data

 {
         "id":1,
         "fname":"Tes1",
         "lname":"Testname1",
         "personaldata":{
            "bloodgroup":A,
            "country":IN,
            "email":[email protected]
         }
 },
 {
         "id":12,
         "fname":"Tes2",
         "lname":"Testname2",
         "personaldata":{
            "bloodgroup":B,
            "country":US,
            "email":[email protected]
         }
 },
 {
         "id":13,
         "fname":"Tes3",
         "lname":"Testname3",
         "personaldata":{
            "bloodgroup":AB,
            "country":IN,
            "email":[email protected]
         }
 }

If “bloodgroup” is “A” and “county” is “IN” fetch
distinct “id”

OUTPUT

{"id":1},
{"id":3}

Passing html input values to js using JQuery

I am trying to pass html values to js using JQuery but when it comes to selected option value, its failing to pass:

Html:

<div>
  <input type="hidden" id="key" name="key" value="558444368">
  <select id="selected-value" name="selected-value">
  <option value="1">a</option>
  <option value="2">b</option>
  <option value="3">c</option>
  </select>
  <button class="my_button" type="submit" id="send-data">Send</button>
</div>

Js:

$(document).on('click', '#send-data', function(){
    var my_key = $('#key').val();
    console.log(my_key);
    var selected_value = $('#selected-value option:selected').val();
    console.log(selected_value);
});

key value is being passed fine to my JS function but selected option value is failing to pass. I don’t want to use onchange method..

I have tried both and it failed:

var selected_value = $('#selected-value option:selected').val();
var selected_value = $('#selected-value').val();

How in svelte import store.js?

I have a svelte project stackblitz

store.js:

import { writable } from 'svelte/store';

export const currentFilter = writable('');

Item.js:

<script>
  import Icon from 'svelte-icons-pack/Icon.svelte';
  export let filter;
  import {curentFilter} from '../store.js';

  let isActive = false;

    const unsubscribe = curentFilter.subscribe(value => {
        isActive = value === filter.name;
    });
</script>

<button
  class:active={isActive}
  class="item"
  on:click={() => {
    curentFilter.set(filter.name);
    console.log(curentFilter)
  }} >
  <div class="icon" style="background-color: {filter.bg}">
    <Icon src={filter.icon} size="24" color={filter.color} />
  </div>
  <div class="name">
    {filter.name}
  </div>
</button>

Button click should toggle active class.

Question: How to properly use store in svelte and import it?

i upload image then this error was show error:URL.createObjectURL: Argument 1 is not valid for any of the 1-argument overloads on this code

Uncaught TypeError: URL.createObjectURL: Argument 1 is not valid for any of the 1-argument overloads.
onChange Profile-edit.js:27
React 23
js index.js:6
factory react refresh:6
Webpack 3

 <div className='border- border-black'
                        onClick={() => document.querySelector(".input-img").click()}>
                        <input type="file" accept='image/*' className='input-img' hidden 
                        onChange={({ target: files }) => {
                            files[0] && setFileName(files[0].name)
                            if (files) {
                                setImage(URL.createObjectURL(files[0]))
                            }
                        }} />
                        {image ? <img src={image} height={60} width={60} alt={fileName} /> :
                            <><MdCloudUpload color='#1475cf' size={60} /><p>Upload Photo</p></>}
                    </div>

I can connect to ws://localhost:8088/ari/events?api_key=user:user&app=hello-world, but i can’t connect to ws://localhost:8088/ws. Why?

Iam using laravel and javascript to presend live data of a call center dashboard, how can i control the realtime data with laravel endpoints and websockets, I do not want to access asterisk ari with javascript directly but first with laravel and do some calculations and proccess the outcome from ARI then return the outcome from laravel to javascript, I tried to access the call laravel endpoints with javascript websockets with the specific port 8088 but it returned an error

How to get list of only one property form list of object in javascript jquery [duplicate]

I get following json data from webAPI

{"data":[{"id":1,"wastageName":"BOPP at printing"},
{"id":3,"wastageName":"BOPP Production wastage"},
{"id":18,"wastageName":"LDPEE at leminatign"}]}

How can I get only list of wastageName from this data using JavaScript Or JQuery

I think we can apply Loop / each() to solve this problem.

$( "data" ).each(function( index ) {
  console.log( index + ": " + $( this ).text() );
});

How to create display Date options in dropdown based on year selection Angular

I have a year picker dropdown in which i am displaying all the years like 2021,2022,2023 so on, i am passing selected year inside createHalfYearOptions function.

i am expecting below output in createHalfYearOptions functions.

Expected output –

If i will pass 2021 in createHalfYearOptions, than it will generate below options
H1 - Jan-Jun(2021)
H2 - July-Dec(2021)


If i will pass 2022 in createHalfYearOptions, than it will generate below options
H1 - Jan-Jun(2022)
H2 - July-Dec(2022)

Can anyone help me to get this result..below is my code

chosenYearHandler(dateVal) {
    const minDate = moment(dateVal.date).format('YYYY');
    this.createHalfYearOptions(minDate);
  }

I tried below code to create my expected output bt not giving the proper result.

createHalfYearOptions(minDate) {    
    const d =  new Date();
    this.maxDate = new Date(d.getFullYear());
    for(let i=this.minDate; i<=this.maxDate.getFullYear(); i++){
      this.dateArry.push({date: new Date(i)});
    }
    this.dateArry.reverse();
}

How can I make wmslayer single tile with geoserver and remove white area?

enter image description here

I render tif image to react-leaflet map using geoserver wmslayer
I want that image single tiled because it looks crack when i zoom in
and i don’t want render white area if i zoom in it remove but when zoom out white area come.
i think image is tiled so empty area looks white

https://gis.stackexchange.com/questions/220546/removing-white-background-from-geotiff-in-geoserver
I tried this action but it can’t solve my problem

Can we write a generic type in TypeScript that converts a Record to a type that we get when we specify `as const`?

Let’s say, I have const foo = { myKey: 'myValue' } as const

Then, typeof foo is { readonly myKey: 'myValue' }

If I have type MyType = Record<string, string>, I want to write a modifier (let’s say Modify ) which does follows…

type ModifiedMyType = Modify<MyType>

const foo: ModifiedMyType = { myKey: 'myValue' }

In this case, I have NOT specified it as const like before. But, I want typeof foo to be
{ readonly myKey: 'myValue' }

Normal time to military time conversion without use of libraries or in-built functions in Javascript

This is my code that outputs perfectly converted military time in hh-mm-ss format when a string is passed as the normal time in hh-mm-ss-am/pm format. Note: The program is written such that the string passed as an input is strictly of the format (hh-mm-ss-am/pm) as cited above and does not throw exceptions if found any special characters or white spaces.

function timeConversion(s) {
    let militaryTime = new String();
    let hourCatcher = s.substr(0,2);
    let hourChecker = parseInt(hourCatcher);
    let hourChanger="";
    let amPmCatcher = s.slice(-2);
    if(amPmCatcher === "AM" || amPmCatcher === "am")
    {   
        if(hourCatcher === "12")
        {
            hourChanger = s.replace(hourCatcher, "00");
            militaryTime = hourChanger.replace(amPmCatcher,"");    
        }
        else
        militaryTime = s.replace(amPmCatcher,"");
        
    }
    else if(amPmCatcher === "PM" ||amPmCatcher === "pm")
    {
        if(hourCatcher === "12")
        {
            hourChanger = s.replace(hourCatcher, "12");
            militaryTime = hourChanger.replace(amPmCatcher,"");
        }
        else
        {
            hourChanger = s.replace(hourCatcher,hourChecker+12);
            militaryTime = hourChanger.replace(amPmCatcher,"");
        }
    }
    return militaryTime;
}

I know that the string.substr() method has been deprecated but it was the only way I could muster my requisite result.

Do assist me, if there could be a way to code this in a more efficient way.
Regards

How to center this card?

I am facing an issue with cards, which I had made it with swiperjs. I am trying to center the card in mobile screen but i couldn’t. Please help me to fix it.

enter image description here

var swiper = new Swiper(".slide-content", {
  slidesPerView: 3,
  spaceBetween: 30,
  loop: true,
  centerSlide: 'true',
  fade: 'true',
  grabCursor: 'true',
  pagination: {
    el: ".swiper-pagination",
    clickable: true,
  },
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev",
  },
});

Error when hosting CSS bundle with Firebase – MiniCSSExtractPlugin Webpack

I previously posted a question Webpack bundle served to Firebase hosting incomplete, no issue using Webpack server regarding an error when serving a Webpack bundle to Firebase, where the index.js code does not execute and throws an error like

caught (in promise) TypeError: c[e] is not a function

The issue was resolved when I removed the import of ‘./style.css’: which is loaded by the miniCSSExtractPlugin to output a CSS bundle into the public folder.

It seems that there is an issue with this import -> such that the rest of index.js does not execute when it is served with Firebase. However, I can’t remove the import as it’s necessary for Webpack to bundle it into the public folder. Could this be an issue with the config of MiniCSSExtractPlugin when served publicly?

My config file looks like

plugins: [
    new MiniCssExtractPlugin(
      { filename: '[name].[contenthash].css' },
    ),

There are no issues with any of the other types of bundled files such as images and html.