Using firestore timestamp to save the date of birth

I am using firestore timestamp for storing the date of birth of a user.
I want to store the date as 6/25/1982 using
firestore.Timestamp.fromDate(new Date(6/25/1982));

Date is visible in firebase document as June 24, 1982 at 5:00:00 PM UTC-7 in USA and June 25, 1982 at 05:30:00 AM in India.

How to make the date same while showing the date of birth.

How to implement remember me functionality in react js

I’m making a simple login signup form with remember me functionality in react js along with redux, thunk and redux-persist.
Th for

my approach is:

if – remember me button is ticked then I want to persist the access token (received from api) in local storage

and if- remember me button is not ticked then I want to store the access token in session storage

can someone help me to implement this or correct my approach if it is wrong.

How to set up Vue 3 parent component to emit event to child component

I am attempting to set up a button in a Vue 3 Tailwind parent component to trigger a HeadlessUI transition event in a child component. My goal is to enable the button in the parent to emit an event, while the child component “watches” for the event before triggering the transition event as part of the callback function in the watch. So far, I have the parent component set up to trigger the emit, while the child component is set up to watch for the “transition” event. However, the event is not being executed. I’m afraid I don’t have the watch in the child component set up correctly, so as to watch for the button click in the parent component. How can I go about enabling the child component to watch for the click of the button in the parent component?

Here is my code so far:

Parent:

<!-- This example requires Tailwind CSS v2.0+ -->
<template>
  <div class="min-h-full">
    <Disclosure as="nav" class="bg-gray-800">
      <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="flex items-center justify-between h-16">
          <div class="flex items-center">
            <div class="hidden md:block">
              <div class="ml-10 flex items-baseline space-x-4">
                <button type="button" @click="transition" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800">Click to transition</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </Disclosure>

    <main>
      <div class="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
        <!-- Replace with your content -->
        <div class="px-4 py-6 sm:px-0">
          <HelloWorld />
        </div>
        <!-- /End replace -->
      </div>
    </main>
  </div>
</template>

<script setup>
import { Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
import { BellIcon, MenuIcon, XIcon } from '@heroicons/vue/outline'
import HelloWorld from './components/HelloWorld.vue'
import { getCurrentInstance } from 'vue'
const { emit } = getCurrentInstance()

const transition = (e) => {
  emit('transition', e.target.value)
}

</script>

Child:

<template>
  <div class="flex flex-col items-center py-16">
    <div class="w-96 h-96">
      <TransitionRoot
        appear
        :show="isShowing"
        as="template"
        enter="transform transition duration-[400ms]"
        enter-from="opacity-0 rotate-[-120deg] scale-50"
        enter-to="opacity-100 rotate-0 scale-100"
        leave="transform duration-200 transition ease-in-out"
        leave-from="opacity-100 rotate-0 scale-100 "
        leave-to="opacity-0 scale-95 "
      >
        <div class="w-full h-full bg-gray-400 rounded-md shadow-lg" />
      </TransitionRoot>
    </div>
  </div>
</template>

<script setup>
import { ref, watch } from 'vue'
import { TransitionRoot } from '@headlessui/vue'

const isShowing = ref(true)

watch('transition', () => {
  isShowing.value = false

  setTimeout(() => {
    isShowing.value = true
  }, 500)
})
</script>

How to change the way that String or Number cast a class in JavaScript?

How can I change the way String or Number casts a class?

For example, I have the class User:

class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
  }
}

How do I convert a class object to String and get the name attribute back when I convert it to String. And if I want to convert the object of the class to Number, it returns the age attribute.

Like this:

const user = new User('Kevin', 23);

console.log(String(user)) // Kevin
console.log(Number(user)) // 23

Thanks!

Why safari browser show large font size compare to other browsers like chrome

When I checked on chrome its font-size look good as I have added on my CSS but when I checked on safari browser font size of privacy policy and terms of use is larger than chrome browser.

Here is my Html

     <div class="term-condition-section">
        <a class="term-condition-btn" target="_blank" href="#">Privacy Policy/</a>
        <a class="term-condition-btn" target="_blank" href="#">Terms of Use</a>
     </div>

Here is my Css

.term-condition-section {
   display: flex;
   padding: 0.25rem 0.5rem;
}

.term-condition-section .term-condition-btn {
   display: block;
   width: fit-content;
   clear: both;
   font-weight: 400;
   font-size: 10px;
   color: blue;
   text-align: inherit;
   white-space: nowrap;
   background-color: transparent;
   border: 0;
}

Please help

Fetch | API- Method DELETE

What’s up Folks !!

I am having an issue with my javaScript … almost there as I need to fix only one error that I am not able too here ‘s my code and the error message in the DevTool

const init = () => {


document.querySelector("#newTask").addEventListener("click", addNewTask);
//document.querySelector("#deleteTask").addEventListener("click", deleteData);
getDataa();

};

const getDataa = (test) => {

console.log("get Data")

const url = "https://ghu8xhzgfe.execute-api.us-east-1.amazonaws.com/tasks/2877332";
fetch(url, {
        method: "GET",
        withCredentials: true,
        headers: {
            "x-api-key": "Itcheui2tB58SlUGe8rrP8mskudGsNDT9nfKKG9S",
            "Content-Type": "application/json"
        }


    })
    .then(resp => resp.json())
    .then(function(data) {
        console.log(data);
        // Loop to access all rows




        for (i = 0; i <= data.ScannedCount; i++) {

            let text = "";

            //const items = data.Items[i].Description;

            Array.from(data.Items).forEach(myFunction);


            // display the data to the end user and link it to the index page
            document.getElementById("displayTable").innerHTML = text;

            function myFunction(item, index) {
                text += ' <button type="button" class="btn" id="task" onclick="deleteData()"><i class="fa fa-trash"></i></button>' + "  " + data.Items[index].Description + "<br>";




            }

        }

    })
    .catch(function(error) {
        console.log(error);
    });

}

async function deleteData() {

console.log("deleteing data");

//let deleteDescription = document.querySelector("#task").value;
let xhr = new XMLHttpRequest();
let url = "https://ghu8xhzgfe.execute-api.us-east-1.amazonaws.com/tasks/";
let studentId = "2877332";



let taskDescription = document.querySelector("#task").value;
fetch(url, {
        method: 'DELETE',

        headers: {
            "Content-Type": "application/json",
            "x-api-key": "Itcheui2tB58SlUGe8rrP8mskudGsNDT9nfKKG9S",

        },

        body: JSON.stringify({
            'StudentId': studentId,
            'Description': taskDescription,
            'version': 'JSON',
        })
    })
    .then(res => res.json()).then(console.log);
console.log(studentId);

}

const addNewTask = () => {
console.log(“Adding a new task…”);

let xhr = new XMLHttpRequest();
let url = "https://ghu8xhzgfe.execute-api.us-east-1.amazonaws.com/tasks";
let apiKey = "Itcheui2tB58SlUGe8rrP8mskudGsNDT9nfKKG9S";
let studentId = "2877332";
let taskDescription = document.querySelector("#task").value;
let params = {
    StudentId: studentId,
    Description: taskDescription
};
xhr.open("post", url);

xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("x-api-key", apiKey);



xhr.onreadystatechange = () => {

    if (xhr.readyState == 4) {
        console.log(taskDescription);



    }
}
xhr.send(JSON.stringify(params));

};
window.onload = init;

How to use the npm module gs1-barcode-parser?

I want to extract the price value from the GS1 data martix QR code value using Nodejs.
Using the module

npm i gs1-barcode-parser

Tried the below throwing “parseBarcode” is not a function

const { parseBarcode } = require('gs1-barcode-parser');
let barcode = 'u001d01093393871222863922001405u001d1522030631030006691095751410';
console.log(parseBarcode(barcode));

How to make Categories button functional

I got my current website displaying hard coded data from my data.js file. I implemented firebase as my database and I want to have my categories button work with the firbase database. FYI, I’m fairly new to developing websites and apps. I’m going to attach my app.js and categories.js file.

Here is my code so far.

const allCategories = ["all", ...new Set(items.map((item) => item.category))];

const MenuApp = () => {
  const [menuItems, setMenuItems] = useState(items);
  const [activeCategory, setActiveCategory] = useState("");
  const [categories, setCategories] = useState(allCategories);

  const filterItems = (category) => {
    setActiveCategory(category);
    if (category === "all") {
      setMenuItems(items);
      return;
    }
    const newItems = items.filter((item) => item.category === category);
    setMenuItems(newItems);
  };
  
  return (
    <main>
      <section className="menu section">
        <div className="title">
          <img src={logo} className="logo" />
          <h2>Menu List</h2>
          <div className="underline"></div>
        </div>
        <Categories
          categories={categories}
          activeCategory={activeCategory}
          filterItems={filterItems}
        />
        <Menu items={menuItems} />
      </section>
    </main>
  );
}

export default App;
const Categories = ({ categories, filterItems, activeCategory }) => {
  return (
    <div className="btn-container">
      {categories.map((category, index) => {
        return (
          <button
            type="button"
            className={`${
              activeCategory === category ? "filter-btn active" : "filter-btn"
            }`}
            key={index}
            onClick={() => filterItems(category)}
          >
            {category}
          </button>
        );
      })}
    </div>
  );
};

export default Categories;

I attched screenshots of how my menu page looks like.

How to execute a function after the web page reaches the desired section or element

In my project, there should be a counter. I have used the “reveal function”. I want the counter to start when it goes to “reveal function”. And when the bottom-up scrolling is done again, the “reveal function” will be performed again. Given that I used the “reveal function”, but when the scroll moves from bottom to top, the counter does not start again. In the code I wrote, the counter runs when the page loads and the “reveal function” has no effect. I used the scroll event and offsetTop until the scroll value of the web page equals the counter section, the counter function is activated and starts working. However, the counter function starts when the web page is loaded, not when the user scrolls to the counter section.

How can I solve this problem? Thanks in advance for your guidance.

window.addEventListener('scroll', function(){
    var section = document.getElementById('business');
    var place = document.body.scrollTop;
    var alertOn = document.getElementById('business').offsetTop;
    console.log(alertOn);
    if(alertOn >= place){
        section.classList.add('open');
        const counter = (EL) => {
            const duration = 4000; 
            const start = parseInt(EL.textContent, 10); 
            const end = parseInt(EL.dataset.counter, 10); 
            if (start === end) return; 
            const range = end - start;
            let curr = start; 

            const loop = (raf) => {
              if (raf > duration) raf = duration; 
              const frac = raf / duration; 
              const step = frac * range; 
              curr = start + step; 
              EL.textContent = parseInt(curr, 10); 
              if (raf < duration) requestAnimationFrame(loop); 
            };

            requestAnimationFrame(loop);
        };

    document.querySelectorAll("[data-counter]").forEach(counter);
    }else{
        section.classList.remove('open');
    }
});
.container{
   overflow-y: scroll;
}
.pre-reveal{
  width: 100%;
  height: 80vh;
  border: 1px solid red;
}
<div class="container">
  <div class="pre-reveal"></div>
  <section id="business" class="counter">
    <span>A: </span>
    <span data-counter="10">0</span>
    <br>
    <span>B: </span>
    <span data-counter="2022">1000</span>
    <br>
    <span>C: </span>
    <span data-counter="0">9999</span>
    <br>
    <span>D: </span>
    <span data-counter="-1000">1000</span>
    <br>
    <span>E: </span>
    <span data-counter="666">0</span>
    <br>
  </section>
</div>

Passing argument to async / await function returns “undefined”

When posting data to an API and get a response, if I hardcode the body data inside the fetch call (body: “XYZ12345”) it works fine, this is an example:

            const vatValidationRequest =
                fetch(
                    '/api/vies/validateVAT.php', {
                        method: 'POST',
                        body: "XYZ12345",
                        headers: {
                            'Content-Type': 'application/text'
                        }
                    })
                .then((response) => response.text())
                .then((responseText) => {
                    return responseText;
                });


            const validateVAT = async () => {
                const viesResponse = await vatValidationRequest;
                console.log(viesResponse);
            };

            validateVAT();

However, if I try to pass the body data as an argument (body: vatNumber), the validateVAT() function returns “undefined”. This is what’s not working:

            const vatValidationRequest = (vatNumber) => {
                fetch(
                    '/api/vies/validateVAT.php', {
                        method: 'POST',
                        body: vatNumber,
                        headers: {
                            'Content-Type': 'application/text'
                        }
                    })
                .then((response) => response.text())
                .then((responseText) => {
                    return responseText;
                });
            }


            const validateVAT = async (vatNumber) => {
                const viesResponse = await vatValidationRequest(vatNumber);
                console.log(viesResponse);
            };

            validateVAT("XYZ12345");

Any clues about how to pass the argument to the async function? thanks!

I need help in creating an interactive Web Page where users can compute and budget their travel and tour expenses for the tour packages

I am new to Javascript and I want to try to create a webpage where users can compute and budget their travel I do not know how to output I need help and I am open to critics Thank you in advance

and tour expenses
The computation I want to use is this
• Adult traveler – 1,500.00 per day
• Children Traveler (12 & below) – 1,100.00 per day
• Duration (No. of days)
and I want to learn how to output the following
• Contact Person’s Name and Number
• Cost of the entire tour (Number of travelers and duration)
• Breakdown of expenses

<html>
<style>
body {font-family: Arial;}
.pk1    {background-color: lime; border-size:2px; text-align:center; font-size:26px}
.pk2    {background-color: powderblue; border-size:2px; text-align:center; font-size:26px}
.pk3    {background-color: pink; border-size:2px; text-align:center; font-size:26px}
.tb1    { font-size:20px}
</style>

<script>


</script>


<body>
<h1>Welcome to Baguio!<h1>
<h3>Go for and Adventure while you still can<h3>
<p>Short description of your Travel and Tours Web page</p>
<h3>Services</h3>
<table>
<tr>
    <td class="pk1">Package 1</td>
    <td class="pk1">Package 2</td>
    <td class="pk1">Package 3</td>  
</tr>

<tr>
    <td class="pk2">Discover thriving arts scene and visit popular museums with this tour package that focuses on artisans in their element, starting off with Ili-Likha Artist Village, a food and art hub founded by film director “Kidlat Tahimik”, followed by a visit to the Easter Weaving Room, where weavers using traditional.</td>
    <td class="pk2">Famous for its temperate climate, scenic mountain views, and delicious strawberries, the summer capital is the perfect place to go “forest bathing” along with other tour inclusions like ghost-hunting at the Diplomat Hotel, trying out locally brewed craft beers at Craft 1945, and indulging in a 2 and a half-hour massage </td>
    <td class="pk2">day tour to popular sites inside and around the city, such as The Mansion, Mines View Park, Ibay's Silver Craft, the Baguio Museum, Burnham Park, and the Our lady of Lourdes Grotto on Mirador Hill. Museum tour includes places like the Tam-awan Village, the Baguio Museum, Museo Kordilyera, and BenCab Museum.</td>   
</tr>
<tr>
    <td class="pk3">Artistic Escapade tour </td>
    <td class="pk3">Culinary Experience tour </td>
    <td class="pk3">Staycation Package</td> 
</tr>
</table>

<br>
<table class="tb1">
    <tr>        <td cosplan=2> Please enter the following details: <td> </tr>
    <tr>        <td>Contact Person's Name           </td> <td><input type="text"> </td></tr>
    <tr>        <td>Contact Person's Phone Number   </td> <td><input type="text"> </td></tr>
    <tr>        <td>No. of Adult travelers(s)       </td> <td><input type="text"> </td></tr>
    <tr>        <td>No. of Children traveler(s)     </td> <td><input type="text"> </td></tr>
    <tr>        <td>Duration of Stay                </td> <td><input type="text"> </td></tr>
    <tr>        <td>Day tour Package                </td> <td><input type="text"> </td></tr>
    <tr>        <td cosplan=2> <input type="button" value="Compute"> <td>   </tr>
</table>

</body>
</html>