How to show a custom button on kendo date picker

I have a custom date filter where I want the user to select a start and end Date.
Instead of showing date picker Icon I want to show a custom icon.
I am using kendo date picker.
HTML Code:

<kendo-daterange>
  <kendo-floatinglabel text="Start">
    <kendo-dateinput
      kendoDateRangeStartInput
      [(value)]="range.start"
    ></kendo-dateinput>
  </kendo-floatinglabel>
  <kendo-floatinglabel text="End">
    <kendo-dateinput
      kendoDateRangeEndInput
      [(value)]="range.end"
    ></kendo-dateinput>
  </kendo-floatinglabel>
</kendo-daterange>

Output:
Kendo Date Picker

Instead of showing Start and End seperately I want to show them on click of a calendar icon I have a custom div on click of which I want to show the calendar
Code:

<div (click)="getDateRange()" class="date-picker-icon">Select Date Range</div>

How do I use tailwindcss @apply directive inside a svelte component

This works:

<div class="list p-2" />

This doesn’t work:

<style lang="postcss">
  @tailwind base;
  @tailwind components;
  @tailwind utilities;

  @layer components {
    .list {
      @apply p-2;
    }
  }
</style>

I looked in Svelte’s docs, but it explains the process with SvelteKit, which I’m not using. How can I make it work?

webpack.config.js:

...
module: {
rules: [
  {
    test: /.css$/i,
    use: ['style-loader', 'css-loader', 'postcss-loader'],
  },

tailwind.config.js:

module.exports = {
  purge: [
    './*.html',
    './src/**/*.js',
    './src/**/*.svelte'
  ],
  darkMode: false, // or 'media' or 'class'
  theme: {
    extend: {},
  },
  variants: {
    extend: {},
  },
  plugins: [],
}

postcss.config.js:

module.exports = {
  plugins: [
    ['tailwindcss'],
    ['autoprefixer'],
  ],
};

GCP MetricServiceClient gets Error: 14 UNAVAILABLE

I have a Cloud function(node 10) that sends metrics using (@google-cloud/monitoring) MetricServiceClient.
I send 25 metrics using async-await syntax.

  const request = {
    name: client.projectPath(projectId),
    timeSeries: [timeSeriesData],
  };

  const options = {
    timeout: 120000
  };

  try {
    await client.createTimeSeries(request, options);
    return Promise.resolve();
  } catch (error) {
    console.error(error);
    throw error;

But from time to time I get an error on the environment(but can’t reproduce it locally)

{ Error: 14 UNAVAILABLE: Deadline expired before operation could complete.
at Object.callErrorFromStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call.js:31:26)
at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client.js:179:52)
at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:336:141)
at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:299:181)
at process.nextTick (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:145:78)
at process._tickCallback (internal/process/next_tick.js:61:11)
code: 14,
details: 'Deadline expired before operation could complete.', before operation could complete.',
metadata:
Metadata {internalRepr: Map { 'grpc-server-stats-bin' => [Array] }, options: {} } }

I checked different values for the timeout option but it seems that it isn’t connected:

  • this error can appear sooner than the specified timeout option (13 000 ms with 120 000 ms timeout value)
  • if we poot a really small timeout we will have a different error Error: 4 DEADLINE_EXCEEDED: Deadline exceeded that I tracked down by source code.

I assume error details probably go from server-side @grpc/grpc-js/src/call-stream.ts line 592.

if (this.internalError.code === 'ECONNRESET') {
                  code = Status.UNAVAILABLE;
                  details = this.internalError.message;

Does anyone know where it might come from?

How to get cypress code coverage for iframe?

I’m trying to generate cypress code coverage for iframe which is part of my application.
Cypress creates an object called __coverage__ for the instrumentation that is present in my iframe window(main content). But at the end of each spec, it shows the below message
enter image description here

Without an iframe, it’s generating the report.

I followed this link
https://github.com/cypress-io/code-coverage#instrument-your-application

Unintended CSS Reversing Animation

I’m trying to make an icon button to rotate on click, but every time i remove the class, it spins backwards, i wanted to do in a way that every time it’s clicked, it spins clockwise onl

const btn = document.querySelector('.reset-button');

btn.addEventListener("click", (e) => {
  btn.classList.add("rotate");
  setTimeout(() => {
    btn.classList.remove("rotate");
  }, 1500);
});
div {
  display: flex;
  flex-direction: row;
  justify-content: center;
}

.reset-button {
  transition: 1.5s;
}

.rotate{
  transform: rotate(720deg);
}
<link rel="stylesheet"
        href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" />
        
        <div>
        <button class="reset-button rotate"><span class="material-symbols-outlined">
                            refresh
                        </span></button>
                        </div>

Why getting 404 error in routing in next.js?

I have a Next.js application.Initially the homepage is loaded to the user and after a timer of 10 the user has to be redirected to a feedback page:

 const router=useRouter();
 if(timer==0)
  {
    router.push('/feedback');
    clearTimeout(time);
  }

However at the time of routing to feedback page , Im getting the following error:

404
This page could not be found.

Inspite of having a feedback page in the pages folder, Im getting this error.

Using navigator.share() to detect mobile users?

I’m trying to detect if a user visiting my webapp is a mobile user or not. I’ve seen various implementations (example1, example2, example3) but none of them seem to be foolproof or recommended.

I have never seen anyone mention checking if (navigator.share) as a method to determine if a user is on mobile or desktop. The if statement correctly distinguishes between desktop and mobile users in my app (source).

Can I rely on this if statement check? If not, what are the drawbacks to using this approach?

(Note: caniuse states that navigator.share only has 87% coverage, but what if I just assume that’s “good enough”?)

How to send two request with postman?

I send this with postman in the body :

{
“username”: “jeantille”,
“mail”: “[email protected]”,
“password”: “motdepasse”
}

I think that i have to send two request at different time but I can’t. Can you help me please.

controllers/user.js

exports.signup = (req, res, next) => {
    
    User.findOne({
        attributes: ['mail'],
        where: {  
            mail: req.body.mail
        }
    })
    .then(userExist => {
        if(!userExist) {
            bcrypt.hash(req.body.password, 10)
            .then(hash => {
                const user = User.build({
                    username: req.body.username,
                    mail: req.body.mail,
                    password: hash,
                    admin: 0
                });
                user.save()
                    .then(() => res.status(201).json({ message: 'Votre compte a bien été créé !' }))
                    .catch(error => res.status(400).json({ error: '⚠ Oops, une erreur s'est produite !' }));
            })
            .catch(error => res.status(500).json({ error: 'Une erreur s'est produite lors de la création de votre compte' }));
        } else {
            return res.status(404).json({ error: 'Cet utilisateur existe déjà' })
        }
    })
    .catch(error => res.status(500).json({ error: '⚠ Oops, une erreur s'est produite !' }));
};

I want to select value from react select

const [brand_id, setBrandId] = useState([])

const handleBrand=(e)=>{

    setBrandId(e.target.value);
    console.log('hii')
}

//this react select in a component

                                <SearchableSelect label={'Brand'}  important placeholder="Select Brand" value={brands} options={brand} handleChange={(e) => handleBrand(e)}/>

// Error is Cannot read properties of undefined (reading ‘value’)

how to add variable in jsx style attribute when there is already object?

I am trying to do text-align in textarea tag by writing logic with the variable name myStyle, so the logic is working but then when I made a toggle switch for dark mode and added more styling as object. Then myStyle stop working. So the question is how to add myStyle variable in style attribute when there is already a given object what is the correct format?


export default function TextForm(prop) {
  const [text, setText] = useState("Enter text here");

  const [myStyle, setMyStyle] = useState({
    textAlign:'left'
  })
  const textAlign = ()=>{
    if(myStyle.textAlign === 'left'){
      setMyStyle({
        textAlign: 'center'
      })
    }
    else if(myStyle.textAlign === 'center'){
      setMyStyle({
        textAlign:'right'
      })
    }
    else{
      setMyStyle({
        textAlign:'left'
      })
    }
  }

  return (
    <>
    <div className='container' style={{color: prop.mode==='light'?'Black':'white'}}>
        <h2>{prop.heading} </h2>
        <div className="mb-3">
        <textarea className="form-control " style={myStyle,{ backgroundColor:prop.mode==='light'?'white':'grey', color:prop.mode==='light'?'black':'white'}} value={text}  onChange= {handleOnChange}  id="myBox" rows="6"></textarea>
        </div>
        <button className="btn btn-primary mx-1" onClick={textAlign} >Change Text Align</button>
    </div>
    </>
  )
}

How do I use a fetch get response more than once?

I want to set both of these values in the state to be used later as variables.

  const [dollarGoal, setDollarGoal] = React.useState(0); 
  const [dollarValue, setDollarValue] = React.useState(0);
  //fetching donation value
  fetch('api', {
      method: 'GET',
    })
    .then(response => response.json())
    .then(r => setDollarValue(r.dollarValue))
    .then(r => setDollarGoal(r.dollarGoal));

But it gives the error:

Property 'dollarGoal' does not exist on type 'void'.

How do I fix this?

How to access object key which is saved with double quotes in javascript?

My data looks likes this,
Data Image Link

The keys that are not saved with double quotes can be accessed easily using obj[“key”] (For eg: data[“Désignation commerciale article”]) syntax but when I use the same syntax for the keys that are saved with double quotes, it is returning undefined(For eg:data[“Montant DEEE 2022 ↵en € HT “]). So how can I access those keys?

Is there a way to match 3 colors, alternating, to odd numbers

I am trying to create a list of 3 phase color coding. ex.)
Red: 1.
Black: 3.
Blue: 5.
Red: 7.
and so on and so fourth, until 100. Same thing on the even side of numbers.
Red: 2
Black: 4
Blue: 6
Red: 8.

How would I achieve this in javascript?

Thanks! (PS, I am new to coding and have never used stackoverflow yet so apologies)