feat: add computePriceChange helper for key price percentage change - #435
feat: add computePriceChange helper for key price percentage change#435Ghadaffijr wants to merge 1 commit into
Conversation
- Add computePriceChange(current: bigint, previous: bigint) in src/utils/priceChange.utils.ts
- Returns { percent: number, direction: 'up' | 'down' | 'flat' }
- Returns flat when previous is zero or current equals previous
- 7 unit tests covering: price up, price down, no change, zero previous, both zero
Closes accesslayerorg#429
✅ Deploy Preview for accesslayer ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@Ghadaffijr 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! 🚀 |
|
👋 Hey @Ghadaffijr, thanks for your contribution! This PR is targeting Please close this PR and reopen it with Closing this PR automatically. See you in |
Closes #429
Summary
i. Adds computePriceChange(current: bigint, previous: bigint) in src/utils/priceChange.utils.ts as a shared helper for computing key price movement across the creator list and creator detail pages
ii. Returns { percent: number, direction: 'up' | 'down' | 'flat' } so formatting and sign logic are consistent wherever price change is displayed
iii. Returns flat with percent: 0 in both edge cases: when previous is zero (undefined division) and when current equals previous (no movement)
iv. Converts bigint inputs to number at the division boundary only, preserving precision for the comparison logic
Closes #429
Testing
-[x] pnpm lint
-[x] pnpm build
-[x] 7 unit tests added covering: price increase, price decrease, large increase, large decrease, equal values, zero previous, both zero
Checklist
-[x] Linked issue or backlog item
-[x] Scope is limited to the stated change
-[x] Updated docs if behavior or setup changed
-[ ] Added screenshots for UI changes when relevant — N/A, pure utility function with no UI