From 37dcb46e2eff7e6c25cf82499e5a9e532a1ee031 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 20 Aug 2024 11:11:17 +0200 Subject: [PATCH] fix expiry --- src/pages/paras/renewal.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pages/paras/renewal.tsx b/src/pages/paras/renewal.tsx index 66ea00a6..eae0850f 100644 --- a/src/pages/paras/renewal.tsx +++ b/src/pages/paras/renewal.tsx @@ -38,7 +38,7 @@ const Renewal = () => { state: { activeAccount, activeSigner }, } = useAccounts(); const { status, parachains } = useRenewableParachains(); - const { saleInfo, saleStatus, status: saleInfoStatus } = useSaleInfo(); + const { saleInfo, saleStatus, status: saleInfoStatus, phase } = useSaleInfo(); const { state: { api: relayApi, apiState: relayApiState }, @@ -57,7 +57,7 @@ const Renewal = () => { const [working, setWorking] = useState(false); const [expiryTimestamp, setExpiryTimestamp] = useState(0); - const formatDuration = humanizer({ units: ['w', 'd'], round: true }); + const formatDuration = humanizer({ units: ['w', 'd', 'h'], round: true }); const handleRenew = () => { if (!activeAccount || !coretimeApi || !coretimeApiState || !activeSigner) @@ -116,7 +116,13 @@ const Renewal = () => { parachains[activeIdx].when, timeslicePeriod ); - setExpiryTimestamp(expiry - now); + + if (expiry - now < 0) { + setExpiryTimestamp(phase.endpoints.fixed.end - now); + } else { + setExpiryTimestamp(expiry - now); + } + setLoading(false); }; @@ -131,6 +137,7 @@ const Renewal = () => { timeslicePeriod, saleInfoStatus, saleStatus, + phase, ]); useEffect(() => {