add minue and second in text useCountDown
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
AUTH_PAGE_ELEMENT as AUTH_PAGE_ELEMENTS
|
||||
} from '@/enums'
|
||||
import clsx from 'clsx'
|
||||
import { formatCountdown } from '@/hooks/useCountdown'
|
||||
import Image from 'next/image'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
@@ -22,15 +23,6 @@ type Props = {
|
||||
pending?: boolean | undefined
|
||||
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'id'>
|
||||
|
||||
const formatCountdown = (seconds: number) => {
|
||||
const mins = Math.floor(seconds / 60)
|
||||
const secs = seconds % 60
|
||||
if (mins > 0) {
|
||||
return `${mins}:${String(secs).padStart(2, '0')}`
|
||||
}
|
||||
return String(seconds)
|
||||
}
|
||||
|
||||
function StepEnterOtp ({
|
||||
onChange,
|
||||
onClick,
|
||||
@@ -96,7 +88,7 @@ function StepEnterOtp ({
|
||||
<div>
|
||||
{timerRunning ? (
|
||||
<div>
|
||||
{t('OTP.TimerRunning', { time: formatCountdown(secondsLeft) })}
|
||||
{t('OTP.TimerRunning', { time: formatCountdown(secondsLeft, t) })}
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
|
||||
@@ -14,6 +14,7 @@ import { setRefreshToken, setToken } from '@/lib/api/func'
|
||||
import { useSearchParams } from 'next/navigation'
|
||||
import { AUTH_PAGE_ELEMENT } from '@/enums'
|
||||
import clsx from 'clsx'
|
||||
import { formatCountdown } from '@/hooks/useCountdown'
|
||||
|
||||
type Props = {
|
||||
phone: string
|
||||
@@ -24,15 +25,6 @@ type Props = {
|
||||
isResendPending?: boolean
|
||||
}
|
||||
|
||||
const formatCountdown = (seconds: number) => {
|
||||
const mins = Math.floor(seconds / 60)
|
||||
const secs = seconds % 60
|
||||
if (mins > 0) {
|
||||
return `${mins}:${String(secs).padStart(2, '0')}`
|
||||
}
|
||||
return String(seconds)
|
||||
}
|
||||
|
||||
const StepOtp = ({ phone, slug, timerRunning, secondsLeft, onResend, isResendPending }: Props) => {
|
||||
const searchParams = useSearchParams()
|
||||
const redirectUrl = searchParams.get('redirect')
|
||||
@@ -126,7 +118,7 @@ const StepOtp = ({ phone, slug, timerRunning, secondsLeft, onResend, isResendPen
|
||||
<div className='text-center w-full pt-6 text-xs'>
|
||||
{timerRunning ? (
|
||||
<div>
|
||||
{t('OTP.TimerRunning', { time: formatCountdown(secondsLeft) })}
|
||||
{t('OTP.TimerRunning', { time: formatCountdown(secondsLeft, t) })}
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user