How to get the data from an object in react

I have a form where the user fills up a form for one employee with data like father’s name etc..
Now i have another form where the user can change these data incase of an error or sth.
I want to get the value of these variables sth like fathersname or mothersname etc.. and show their value in the proper input element. So the user can see the previous value and change it if needed.

So in conclusion i have the Employee component, another Component named Employees where i show all the employees in chart, in which i pass each employee with the help of usecontext hook, and then at last i have the DataChange component which i pass the employee obj through Employees as a variable (not through usecontext hook) and from there i am trying to get each one’s values

What i have tried is sth like this in the Employee Component :

function handleAddYpallilos() {
        const NewYpallilos = {
            Yname: name,
            Yepitheto: epitheto,
            Ycode: code,
            Yfathername: fathername
        };
        setYpalliloi(prevYpalliloi => [...prevYpalliloi, NewYpallilos]);
    }
 <div className="mb-3">
      <label htmlFor="formEmployeeFathername" className="form-label">Όνομα Πατέρα</label>
     <input type="text" className="form-control" id="formEmployeeFathername" placeholder="" 
value={fathername} onChange={handleFathernameChange} />
    </div>

Employees “ignore the modals”

<DataChange
                showModal2={showModal2}
                setShowModal2={setShowModal2}
                ypallilos={selectedYpallilos} // Πέρασμα του επιλεγμένου υπαλλήλου
            />

and lastly the DataChange component

    const [name, setName] = useState(ypallilos.Yname);
<div className="mb-3">
 <label htmlFor="formEmployeeFathername" className="form-label">Όνομα Πατέρα</label>
 <input type="text" className="form-control" id="formEmployeeFathername" value={fathername} placeholder="" />
     </div>

How to Apply a default attribute to an angular component

I’m trying to format some fields into neat rows and columns, and because I have to match some other components with very specific formatting, the html that works looks like this:

<div fxLayout="column" style="margin-right: -30px">
  <div fxLayout="row" fxLayoutGap="10px" style="margin-bottom: 3px">
    <div fxFlex="92" fxLayout="row column" fxLayoutAlign="space-between start">
      <some-component-1
        fxFlex="45"
        fxFlex.sm="90"
        fxFlex.xs ="90"
      ></some-component-1>
      <some-component-2
        fxFlex="45"
        fxFlex.sm="90"
        fxFlex.xs ="90"
      ></some-component-2>
    </div>
  </div>
</div>

This is a lot to either type out or copy and paste, so I want to abstract some of these fxLayout divs away into an angular component so that it looks something like this:

<my-row>
  <my-column>
    <some-component-1></some-component-1>
  </my-column>
  <my-column>
    <some-component-2></some-component-2>
  </my-column>
</my-row>

I was able to create the my-row component like this:

row.component.html:

<div fxLayout="column" style="margin-right: -30px">
  <div fxLayout="row" fxLayoutGap="10px" style="margin-bottom: 3px">
    <div fxFlex="92" fxLayout="row column" fxLayoutAlign="space-between start">
      <ng-content></ng-content>
    </div>
  </div>
</div>

Which allows me to do this:

<my-row>
  <some-component-1
    fxFlex="45"
    fxFlex.sm="90"
    fxFlex.xs ="90"
  ></some-component-1>
  <some-component-2
    fxFlex="45"
    fxFlex.sm="90"
    fxFlex.xs ="90"
  ></some-component-2>
</my-row>

Still, I would like to not have to include these fxFlex attributes for each of the nested components. When I try to create the my-column component, I’m unable to apply the fxFlex fields to this component by default.

I’ve tried the following to no avail:

column.component.html:

<ng-container
  fxFlex="45"
  fxFlex.sm="90"
  fxFlex.xs ="90"
>
  <ng-content></ng-content>
</ng-container>

and

<ng-container>
  <ng-content 
    fxFlex="45"
    fxFlex.sm="90"
    fxFlex.xs ="90"
  ></ng-content>
</ng-container>

Is there a way to automatically apply these fxFlex attributes to the my-column component?

How to call an external API in Oracle Apex?

I’m having the following problem:

I have an application in Oracle APEX and I need to make a call to an external API when I click the button.

The solution I thought of was to create a dynamic action on the button that executes JavaScript code when clicked (code below).

But when the code is executed, I receive the following error in my console:

Access to fetch at ‘https://api.rd.services/platform/events?event_type=sale’ from origin ‘http://minha-url.com.br’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

My code:

let options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${accessToken}`,
  },
  body: JSON.stringify({
    event_type: 'SALE',
    event_family: 'CDP',
    payload: {
      email: '[email protected]',
      funnel_name: 'default',
      value: 999
    }
  })
};

fetch('https://api.rd.services/platform/events?event_type=sale', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

I consulted the API documentation, and it contains the following information:

The RD Station Marketing APIs that use the access_token to authorize requests only allow requests coming from the backend of your application. This is because the token used in this API cannot be exposed in the browser, as it allows access to private information about the contacts in your account.

How could I resolve this error with CORS?

I need to make a POST request to the external API when clicking the button.

increasing height of a div moves it downwards, and vice versa

so i was experimenting with some js and maths.. i wanted to create a x,y-axis and a line that rotates as per the mouse location and i wanted it to increase its height as per the distance from my origin or the center of the axis.. now when i try to increase the height of the div.. it moves downwards and whenever i try to decrease its height it goes upwards.. how can i fix this??

html:

<div class="line">
  <div class="angle"></div>
</div>

css:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
}

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

.line {
  height: 75%;
  width: 2px;
  background: #000;
  position: absolute;
}

.line::before {
  content: '';
  position: absolute;
  height: 100%;
  width: 100%;
  background: #000;
  rotate: 90deg;
}

.angle {
  height: 190px;
  rotate: 45deg;
  transform-origin: bottom;
  width: 2px;
  background: red;
}

and js:

let x = document.body.clientWidth / 2;
let y = ( document.body.clientHeight || document.documentElement.clientHeight ) / 2;

let ang = document.querySelector(".angle");

document.addEventListener("mousemove",(e)=>{
  let thetaRadians = Math.atan2(e.clientY - y, e.clientX - x);
  let thetaDegrees = thetaRadians * (180 / Math.PI);
  ang.style.rotate = `${thetaDegrees + 90}deg`;
  
  const distance = Math.floor(Math.sqrt(Math.pow((e.clientX - x),2) + Math.pow((e.clientY - y),2)));
  ang.style.height = `${distance}px`;
});

Why can’t I detect memory reallocation of arrays in javascript? [duplicate]

let arr= [];
let ref = arr;
for(let i = 0;i<100;i++){//I do not know the size at which the first reallocation happnes
    arr.push(1);
    if(arr!==ref){//it should break when the first reallocation happens for e.g. at i =10?
        console.log("reallocation happened");
        break;
    }
}
if(i==100) console.log("reallocation didn't happen");

After enough times arr.push() runs, reallocation should happen so arr should hold the reference for the new array in memory and ref should hold the old array and they shouldn’t be referentially equal, but the condition if(arr!==ref) if always false, so does it mean the reallocation didn’t happen, but that shouldn’t be possible . {SOURCE – CHATGPT}

I tried to push upto 100,000 elements in the array, still the same result. I tried searching on the internet but couldn’t find relevant information as to how the interpreter actually assigns memory in the context of my question.

What is replacement for Vuetify 2 v-date-picker in Vuetify 3? For only month and year

In vue2 you could specify the type as month and it would create a date picker which would only allow year and month to be changed:
enter image description here

<v-date-picker
    v-model="date"
    type="month"
    :min="minDate"
    :max="maxDate"
    no-title
    scrollable
    @change="handleDateChange"
/>

However in vue3 the type prop has been removed. Is it possible to recreate the vue2 functionallity in vue3.

I already look for existing answers, but they do not work in vue3

Vuetify 3 – Implementing date picker
(the first solution requires you to still enter a day, the second solution is a decent work around – however this is a quite messy solution realtive to vue2’s original solution)
v-date-picker with only month and year selection
(does not work in vue3)

how to include import map in JavaScript debugging in Nodel.js?

I’m currently debugging a local Node.js solution and I was wondering, is it possible to add an importmap to Node.js so I can use Import with resource name?

My import map:

<script type="importmap">
{
    "imports": {
        "options": "https://assets.sltech.no/SHARED/JS/OptionsFactory.js",
        "webrequest": "https://assets.sltech.no/SHARED/JS/WebRequest.js",
        "utility": "https://assets.sltech.no/SHARED/JS/Utility.js",
        "logger": "https://assets.sltech.no/SHARED/JS/Logger.js",
        "resources": "https://assets.sltech.no/SHARED/JS/ResourceAccessor.js"
    }
}

Tow to Implement a Dropdown for a Tableau Parameter in JavaScript Embedding API

I’m embedding a Tableau dashboard into a web page using the Tableau Embedding API. I’m trying to implement a dropdown menu to allow users to interact with a parameter called “Moeda” (a text parameter in Tableau, not a filter).

I’ve already implemented a similar dropdown for filters, but I’m struggling to figure out how to properly load and update a parameter in the dashboard via the dropdown. My goal is to:

Display the available values for the “Moeda” parameter as options in a dropdown.
Update the parameter in Tableau when a user selects a new value from the dropdown.

What I’ve Tried:
Here’s what I’ve done so far in JavaScript based on the Tableau Embedding API documentation:

async function loadMoedaParameter() {
  const sheet = viz.workbook.activeSheet;

  try {
    // Get the list of parameters from the workbook
    let parameters = await viz.workbook.getParametersAsync();

    // Find the "Moeda" parameter
    let moedaParam = parameters.find((p) => p.name === "Moeda");

    // Check if the parameter exists
    if (!moedaParam) {
      console.error("Parameter 'Moeda' not found!");
      return;
    }

    // Create a dropdown for the "Moeda" parameter
    let dropdown = document.createElement("select");
    dropdown.style.border = "none";
    dropdown.style.fontFamily = "Space Grotesk";
    dropdown.style.outline = "none";
    dropdown.style.width = "100%";
    dropdown.style.height = "40px";
    dropdown.style.backgroundColor = "#FFFFFF";
    dropdown.id = "optMoeda"; // Dropdown ID

    // Populate the dropdown with allowable values of the parameter
    moedaParam.allowableValues.forEach((value) => {
      let option = document.createElement("option");
      option.text = value.formattedValue;
      option.value = value.value;
      dropdown.appendChild(option);
    });

    // Set the current value of the dropdown
    dropdown.value = moedaParam.currentValue.value;

    // Add an event listener to update the parameter in Tableau when the user changes the selection
    dropdown.addEventListener("change", async (e) => {
      const selectedMoeda = e.target.value;
      try {
        // Update the Tableau parameter
        await viz.workbook.changeParameterValueAsync("Moeda", selectedMoeda);
        console.log("Moeda changed to:", selectedMoeda);
      } catch (error) {
        console.error("Error changing the Moeda parameter:", error);
      }
    });

    // Append the dropdown to the container in the HTML
    const moedaContainer = document.getElementById("Moeda-container-desktop");
    moedaContainer.appendChild(dropdown);
  } catch (error) {
    console.error("Error loading the Moeda parameter:", error);
  }
}

I’m calling this function after the dashboard has been fully loaded using:

viz.addEventListener(TableauEventType.FirstInteractive, loadMoedaParameter);

The container where I want the dropdown to appear is:

<div id="Moeda-container-desktop"
     style="
       width: 300px;
       height: 50px;
       background: #FFFFFF;
       border-radius: 35px;">
</div>``` 

I get an empty dropdown. No matter what I try. The rest of the code is working perfectly, i have filters working perfectly, but for this parameter, I can't make it work.
If you have something simpler than this, or any suggestion I'd appreciate

setting js cookie then accessing with php in same page – undefined till page is refreshed

Is it possible to set this cookie with js then access it later in the body with php? No matter where I put my script when I echo with php it is always undefined until I refresh the page. I can put it in the head, above html, etc… doesn’t matter. What I want to be able to achieve is having that cookie set for use in my page – with php – without the refresh needed. Example case would be the initial page visit from a user on my site. The session.php is what starts the session.

test.php :

<?php
require $_SERVER['DOCUMENT_ROOT'].'/assets/functions/session.php';
?>

<!DOCTYPE html>
<html class="no-js" lang="en">

<!-- BEGIN HEAD -->
<head>
    <script>
            //returns browser timezone or defaults to UTC
            var tz = Intl.DateTimeFormat().resolvedOptions().timeZone ?? 'UTC';

            //store as cookie so you can use it with php
            //document.cookie = "test_Timezone="+tz+"; expires=0; path=/; domain=test.com; secure; samesite=lax";
            document.cookie = "test_Timezone="+tz+"; expires=0; path=/; domain=test.bs5; samesite=lax";

    </script>
</head>
<!-- END HEAD -->

<!-- BEGIN BODY -->
<body>

    <?php
        echo 'timezone is : '.$_COOKIE['test_Timezone'];
    ?>
</body>
<!-- END BODY -->
</html>

How to fix image comparison slider position on landscape mode in react native?

I am trying to the build the image comparison slider on react native like this https://www.npmjs.com/package/react-compare-slider. I almost build the component in portrait mode. But, when I tried to do the same in landscape mode means, the slider dragging is not working as expected.

Here’s the code

import React, {useState, useEffect} from 'react';
import {
  View,
  Image,
  PanResponder,
  Animated,
  StyleSheet,
  Dimensions,
  ActivityIndicator,
} from 'react-native';
import Orientation from 'react-native-orientation-locker';
// import {CompareSlider} from 'react-native-compare-slider';

const ImageComparisonSlider = ({
  leftImage,
  rightImage,
  initialPosition = 0.5,
}) => {
  const [sliderPosition, setSliderPosition] = useState(
    new Animated.Value(initialPosition * Dimensions.get('window').width),
  );
  const [leftImageLoaded, setLeftImageLoaded] = useState(false);
  const [rightImageLoaded, setRightImageLoaded] = useState(false);
  const [isDeviceRotated, setisDeviceRotated] = useState(false);

  const panResponder = PanResponder.create({
    onStartShouldSetPanResponder: () => true,
    onPanResponderMove: (_, gestureState) => {
      const newPosition = Math.max(
        0,
        Math.min(gestureState.moveX, Dimensions.get('window').width),
      );

      sliderPosition.setValue(newPosition);
    },
  });

  const renderImage = (imageUri, onLoadEnd, style) => (
    <Image
      source={{uri: imageUri}}
      style={style}
      resizeMode="cover"
      onLoadEnd={onLoadEnd}
    />
  );

  const bothImagesLoaded = leftImageLoaded && rightImageLoaded;

  const onOrientationDidChange = orientation => {
    if (orientation == 'LANDSCAPE-LEFT' || orientation == 'LANDSCAPE-RIGHT') {
      setisDeviceRotated(true);
    } else {
      setisDeviceRotated(false);
    }
  };

  useEffect(() => {
    Orientation.addOrientationListener(onOrientationDidChange);
    return () => Orientation.removeOrientationListener(onOrientationDidChange);
  }, []);

  return (
    <View
      style={{
        width: isDeviceRotated ? '50%' : '100%',
        height: !isDeviceRotated ? '50%' : '100%', // Adjust as needed
        position: 'relative',
      }}>
      {!bothImagesLoaded && (
        <View style={styles.loaderContainer}>
          <ActivityIndicator size="large" color="#0000ff" />
        </View>
      )}
      {bothImagesLoaded && (
        <>
          {renderImage(rightImage, () => {}, styles.image)}
          <Animated.View
            style={[
              styles.leftImageContainer,
              {
                width: sliderPosition,
              },
            ]}>
            {renderImage(leftImage, () => {}, styles.leftImage)}
          </Animated.View>
          <Animated.View
            style={[styles.sliderLine, {left: sliderPosition}]}
            {...panResponder.panHandlers}>
            <View style={styles.sliderHandle} />
          </Animated.View>
        </>
      )}
      <Image
        source={{uri: leftImage}}
        style={styles.hiddenImage}
        onLoad={() => setLeftImageLoaded(true)}
      />
      <Image
        source={{uri: rightImage}}
        style={styles.hiddenImage}
        onLoad={() => setRightImageLoaded(true)}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  image: {
    width: '100%',
    height: '100%',
  },
  leftImageContainer: {
    position: 'absolute',
    top: 0,
    left: 0,
    bottom: 0,
    overflow: 'hidden',
  },
  leftImage: {
    width: Dimensions.get('window').width,
    height: '100%',
  },
  sliderLine: {
    position: 'absolute',
    top: 0,
    bottom: 0,
    width: 3,
    backgroundColor: 'white',
  },
  sliderHandle: {
    position: 'absolute',
    top: '50%',
    left: -10,
    width: 20,
    height: 20,
    borderRadius: 10,
    backgroundColor: 'white',
    transform: [{translateY: -10}],
  },
  loaderContainer: {
    ...StyleSheet.absoluteFillObject,
    justifyContent: 'center',
    alignItems: 'center',
  },
  hiddenImage: {
    width: 0,
    height: 0,
  },
});

export default ImageComparisonSlider;


Please check this as well: https://www.loom.com/share/4dc8d887fe1449268c8c944aa25f6dbd

It will be very helpful if I got the solution and Please let me know if there are any other packages out there to fix this issue

Thanks in advance!

Handling keyboard focus tabbing on dynamically populated content

I have a list of blog posts with a load more button. For accessibility, I would like to change the positioning of keyboard focus once new posts are added so that instead of skipping to the elements below the post list, hitting tab after loading more posts will focus the first post in the new posts that were added in to the list.

My thought was to get the last article in the list, when the load more button is pressed, and then focus the link within it after the additional posts are loaded in. That way when the user clicks tab again, it will move to the next post in the list (the fourth post in my example). This is not working, I’m assuming because the entire HTML of the post container is being replaced. Is there a way to go about this considering all of the HTML is populated dynamically every time the load more button is pressed?

let additionalPosts = `
  <article>
    <a href="#">
      <h3>Fourth Post</h3>
      <p>Lorem ipsum dolor sit amet</p>
    </a>
  </article>
  <article>
    <a href="#">
      <h3>Fifth Post</h3>
      <p>Lorem ipsum dolor sit amet</p>
    </a>
  </article>
  <article>
    <a href="#">
      <h3>Sixth Post</h3>
      <p>Lorem ipsum dolor sit amet</p>
    </a>
  </article>
`;


$(function() {
  $('.load-more').click(function() {
    const $lastPost = $('.post-container article').last();
    //console.log($lastPost);
    $('.post-container').html($('.post-container').html() + additionalPosts);
    $('a', $lastPost).focus();
    $(this).hide();
  });
});
.post-container {
  display:flex;
  gap:1.5rem;
  flex-wrap:wrap;
  margin-bottom:3rem;
}

article {
  max-width:33%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<h1>Post List</h1>
<div class="post-container">
  <article>
    <a href="#">
      <h3>First Post</h3>
      <p>Lorem ipsum dolor sit amet</p>
    </a>
  </article>
  <article>
    <a href="#">
      <h3>Second Post</h3>
      <p>Lorem ipsum dolor sit amet</p>
    </a>
  </article>
  <article>
    <a href="#">
      <h3>Third Post</h3>
      <p>Lorem ipsum dolor sit amet</p>
    </a>
  </article>
</div>

<button class="load-more" href="#">Load More</button>

<div>
  <h3>Some additional links</h3>
  <a href="#">Another Link</a>
  <a href="#">Another Link</a>
  <a href="#">Another Link</a>
</div>

Svelte styles are not applied to scope

I have a problem with adding styles in my Svelte components. I want to make sure that my styles are only applied within a specific component, but it doesn’t work.

Here is an example of a component. There is the <style> inside the component tag, so it will be applied globally (this works – all elements of type button in the entire application get red):

<script>
    import { Button } from "flowbite-svelte";
</script>

<div>
    <Button>Test Button</Button>

    <style>
        button {
            background-color: red;
        }
    </style>
</div>

According to the Svelte documentation, I should be able to place the <style> tag outside of the HTML Elements in the file to apply the style only to the current component.

Here is my updated code:

<script>
    import { Button } from "flowbite-svelte";
</script>

<div>
    <Button>Test Button</Button>
</div>

<style>
    button {
        background-color: red;
    }
</style>

However, I get the following error:

Unused CSS selector "button"svelte(css-unused-selector)

How can I ensure that my styles are restricted locally to the component?

Need help setting user meta data when a user submits auth0 forms

I have a custom auth0 form that is displayed when a user signs up to my react application. I created a custom flow that is intended to save some of the input details from the form as a user metadata eg: state, zipcode etc. The issue i am having is that i have been unable to set the user meta data when the sign up form is submitted. I have followed the tutorials on the website and still no progress at all. On further investigation, when i navigated to the executions tabs, in the flows section of the form i found the following (see images below):
executions tab 1

executions tab 2

I do not understand why i am getting this error because i set up a vault connection that connects to my M2M application for this flow.
Please i would be very grateful if anyone can assist me in resolving this error

How to integrate app download bottom sheet in web?

App download BottomSheet

I have my web application in Nuxt + Vue. I want to integrate this type of app download bottomsheet(please refer attached image) on a button click.

If we see it is the facebook app and when someone clicks on the pocket FM facebook ad, it pops up the google play store popup to download pocket FM app without leaving the facebook app. I want this experience on the web. Is it feasible?

I explored on google but couldn’t find anything relevant.