fix(3690): removed nested ternary

This commit is contained in:
sam-keen
2023-05-10 16:34:38 +01:00
parent 8d82f4873c
commit fda1ef9bbd
@@ -50,14 +50,20 @@ export const useTranches = create<TranchesStore>()((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 {