Skip to content

Commit

Permalink
fix expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Aug 20, 2024
1 parent 5126daf commit 37dcb46
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/pages/paras/renewal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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)
Expand Down Expand Up @@ -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);
};

Expand All @@ -131,6 +137,7 @@ const Renewal = () => {
timeslicePeriod,
saleInfoStatus,
saleStatus,
phase,
]);

useEffect(() => {
Expand Down

0 comments on commit 37dcb46

Please sign in to comment.