diff --git a/src/components/PingPongComponent/PingPongComponent.tsx b/src/components/PingPongComponent/PingPongComponent.tsx index 55e93b22..3f52e647 100644 --- a/src/components/PingPongComponent/PingPongComponent.tsx +++ b/src/components/PingPongComponent/PingPongComponent.tsx @@ -76,7 +76,14 @@ export const PingPongComponent = ({ return; } - const secondsRemaining = await getTimeToPong(); + const msRemaining = await getTimeToPong(); + + // If backend now returns milliseconds, convert to whole seconds + const secondsRemaining = + msRemaining == null + ? msRemaining + : Math.max(0, Math.floor(msRemaining / 1000)); + const { canPing, timeRemaining } = setTimeRemaining(secondsRemaining); setHasPing(canPing); @@ -147,6 +154,9 @@ export const PingPongComponent = ({ return ; } + const isPingDisabled = !hasPing || hasPendingTransactions; + const isPongDisabled = !pongAllowed || hasPing || hasPendingTransactions; + return (
@@ -185,8 +195,8 @@ export const PingPongComponent = ({
{ + const pingAmount = useGetPingAmount(); const { sendPingTransactionFromAbi, sendPongTransactionFromAbi } = useSendPingPongTransaction(); - const pingAmount = useGetPingAmount(); const handlePingTransaction = async (payload: PingTransactionPayloadType) => { if (payload.amount) { diff --git a/src/pages/Dashboard/widgets/PingPongService/helpers/getTimeToPong.ts b/src/pages/Dashboard/widgets/PingPongService/helpers/getTimeToPong.ts index cd4e9317..b8bb168e 100644 --- a/src/pages/Dashboard/widgets/PingPongService/helpers/getTimeToPong.ts +++ b/src/pages/Dashboard/widgets/PingPongService/helpers/getTimeToPong.ts @@ -11,9 +11,14 @@ export const getTimeToPong = async () => { } ); + if (data.timeToPong == null) { + // no timeToPong field → no cooldown + return 0; + } + return data.timeToPong; } catch (err) { console.error(err); - return null; + return 0; } };