From fda1ef9bbd44d1813dd29f1148ffe426cf3c1cc8 Mon Sep 17 00:00:00 2001 From: sam-keen Date: Wed, 10 May 2023 16:34:38 +0100 Subject: [PATCH] fix(3690): removed nested ternary --- .../src/lib/tranches/tranches-store.tsx | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/apps/governance/src/lib/tranches/tranches-store.tsx b/apps/governance/src/lib/tranches/tranches-store.tsx index 475851a79..6336e8719 100644 --- a/apps/governance/src/lib/tranches/tranches-store.tsx +++ b/apps/governance/src/lib/tranches/tranches-store.tsx @@ -50,14 +50,20 @@ export const useTranches = create()((set) => ({ ?.map((t) => { const tranche_progress = t.duration !== 0 ? (now - t.cliff_start) / t.duration : 0; - const lockedDecimal = - t.duration !== 0 - ? tranche_progress < 0 - ? 1 - : 1 - tranche_progress - : now < t.cliff_start - ? 1 - : 0; + let lockedDecimal; + if (t.duration !== 0) { + if (tranche_progress < 0) { + lockedDecimal = 1; + } else { + lockedDecimal = 1 - tranche_progress; + } + } else { + if (now < t.cliff_start) { + lockedDecimal = 1; + } else { + lockedDecimal = 0; + } + } const clampedLockedDecimal = Math.max(0, Math.min(1, lockedDecimal)); return {