refactor: consolidate timelineProgress calculation into vaultLifecycl… - #986
Merged
1nonlypiece merged 2 commits intoJul 29, 2026
Merged
Conversation
…e utility with robust error handling and tests
|
@A-one-tech Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Hi @A-one-tech, closing this for now — I don't see it linked to an issue that's assigned to you. Feel free to reopen (or open a fresh PR) once you're assigned to the issue it addresses. |
# Conflicts: # src/pages/Dashboard.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#Closes
#743
PR: Extract shared
timelineProgresshelper and guard equal timestampsSummary
Extracts the duplicate
timelineProgress(created, deadline)utility function intosrc/utils/vaultLifecycle.tsand replaces the inline module-level implementations in bothsrc/pages/Dashboard.tsxandsrc/pages/VaultDetail.tsx.Also resolves an unguarded divide-by-zero issue where equal
createdanddeadlinetimestamps resulted in(end - start) === 0and returnedNaN.Motivation & Problem Statement
Dashboard.tsx(line 42) andVaultDetail.tsx(line 51) maintained self-acknowledged identical implementations oftimelineProgress.created === deadline,(end - start)equaled0, leading to((now - start) / 0) * 100 => NaNwhich propagated throughMath.max/Math.mininto UI progress bar rendering.Key Changes
1.
src/utils/vaultLifecycle.tstimelineProgress(created: string, deadline: string, now: number = Date.now()): number.end <= start(returns100ifnow >= start, else0) to preventNaNdivide-by-zero errors.0).2.
src/pages/Dashboard.tsx&src/pages/VaultDetail.tsxtimelineProgressfunctions.timelineProgressfrom../utils/vaultLifecycle.3.
src/utils/__tests__/vaultLifecycle.test.tscreated === deadline) returning100/0withoutNaN.deadline < created).Verification & Testing
Automated Test Execution
Test Results
vaultLifecycle.test.ts: 11 passed (5 stages tests + 6 timelineProgress tests)Dashboard.test.tsx: 3 passedVaultDetail.test.tsx: 19 passedChecklist
timelineProgresshelper intosrc/utils/Dashboard.tsxandVaultDetail.tsxCloses #743