-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathotpGenerationLWCDemo.js
More file actions
38 lines (31 loc) · 1.03 KB
/
Copy pathotpGenerationLWCDemo.js
File metadata and controls
38 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* eslint-disable no-unused-vars */
/* eslint-disable @lwc/lwc/no-async-operation */
import { LightningElement } from 'lwc';
export default class OtpGenerationLWCDemo extends LightningElement {
SentOTP=''
OTPLength = 6
disableOTP = false
showTimerText =''
timeRemaining = 5
showTimer =false
generateOTP(){
let otpArray =[]
for(let genOTP=0;genOTP<=this.OTPLength;genOTP++){
otpArray.push(Math.floor(Math.random() * 10));
}
this.SentOTP = otpArray.join('')
this.disableOTP = true
this.showTimer = true
let showTimeRemaining = this.timeRemaining
let timerInterval = setInterval(() => {
showTimeRemaining--;
this.showTimerText =`Generated OTP will get expired in ${showTimeRemaining} seconds.`;
if(showTimeRemaining<=0){
clearInterval(timerInterval);
this.disableOTP =false
this.showTimer=false
this.SentOTP=''
}
}, 1000); //1000 ms is equal to 1 sec
}
}