-
Notifications
You must be signed in to change notification settings - Fork 62
Refactor Limits page #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sarimrmalik
wants to merge
16
commits into
main
Choose a base branch
from
refactor/limits-page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor Limits page #296
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e3ce03b
Replace limits cards with inline limit and alert controls
sarimrmalik 151d688
Refactor each icon into its own file with a common wrapper for shared…
sarimrmalik e25ca40
Refactor Alert and Limit ASCII icons to use div wrappers instead of S…
sarimrmalik a2ec03e
Rollback icon refactor since out of scope of this branch
sarimrmalik adee037
Add ASCII icon components for alert and limit with styled text repres…
sarimrmalik 80f766d
Refactor billing limits management by removing the old LimitForm comp…
sarimrmalik f8c7998
Refactor dashboard limits management by removing the old limit-sectio…
sarimrmalik fa3856c
Enhance UsageAlertForm and UsageLimitForm to improve cancel functiona…
sarimrmalik a510283
Add SetUsageLimitDialog component for setting API usage limits
sarimrmalik 65c7b0c
Refactor UsageAlertForm and UsageLimitForm to use Input components fo…
sarimrmalik 262247b
Refactor RemoveUsageLimitDialog and UsageLimitForm to enhance user in…
sarimrmalik 039e670
Refactor UsageLimits component to improve loading state handling. Con…
sarimrmalik 7189e3d
Run biome format
sarimrmalik 85c4cc7
Add mount check in UsageAlertForm to prevent initial effect execution
sarimrmalik 307ef38
Add currency validation and formatting utilities with comprehensive t…
sarimrmalik 58f76f7
Refactor currency-related tests and forms for improved consistency an…
sarimrmalik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ next-env.d.ts | |
|
|
||
| # AI agents and related files | ||
| CLAUDE.md | ||
| .cursor | ||
| .agent | ||
|
|
||
|
|
||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { | ||
| CurrencyInputSchema, | ||
| formatCurrencyValue, | ||
| sanitizeCurrencyInput, | ||
| } from '@/lib/utils/currency' | ||
|
|
||
| describe('sanitizeCurrencyInput', () => { | ||
| it.each([ | ||
| ['$1,250', '1250'], | ||
| ['1250', '1250'], | ||
| ['abc', ''], | ||
| ['', ''], | ||
| ])('returns %p -> %p', (value: string, expected: string) => { | ||
| expect(sanitizeCurrencyInput(value)).toBe(expected) | ||
| }) | ||
| }) | ||
|
|
||
| describe('formatCurrencyValue', () => { | ||
| it.each([ | ||
| [1250, '1,250'], | ||
| [100, '100'], | ||
| [0, '0'], | ||
| [1000000, '1,000,000'], | ||
| ])('returns %p -> %p', (value: number, expected: string) => { | ||
| expect(formatCurrencyValue(value)).toBe(expected) | ||
| }) | ||
| }) | ||
|
|
||
| describe('CurrencyInputSchema', () => { | ||
| it.each(['100', '1', ' 100 ', '999999'])('accepts %p', (value: string) => { | ||
| expect(CurrencyInputSchema.safeParse(value).success).toBe(true) | ||
| }) | ||
|
|
||
| it.each([ | ||
| '', | ||
| ' ', | ||
| '12.50', | ||
| '1,250', | ||
| 'abc', | ||
| '0', | ||
| ])('rejects %p', (value: string) => { | ||
| expect(CurrencyInputSchema.safeParse(value).success).toBe(false) | ||
| }) | ||
| }) |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import type React from 'react' | ||
| import { cn } from '@/lib/utils/index' | ||
|
|
||
| const LINES = [ | ||
| ' ', | ||
| ' ', | ||
| ' ', | ||
| ' ', | ||
| ' -********- ', | ||
| ' -*-- -*- ', | ||
| ' -*- -*- ', | ||
| ' **- -** ', | ||
| ' -*- -*- ', | ||
| ' -**----------**- ', | ||
| ' ----**----**---- ', | ||
| ' -******- ', | ||
| ' ', | ||
| ' ', | ||
| ' ', | ||
| ' ', | ||
| ] | ||
|
|
||
| const TEXT_STYLE: React.CSSProperties = { | ||
| fontSize: '3.802px', | ||
| fontFamily: 'var(--font-mono)', | ||
| fontWeight: 600, | ||
| letterSpacing: '-0.038px', | ||
| lineHeight: '4px', | ||
| fontFeatureSettings: "'ss03' 1", | ||
| } | ||
|
|
||
| export const AlertAsciiIcon = ({ className }: { className?: string }) => ( | ||
| <div className={cn('relative size-[72px]', className)}> | ||
| <div | ||
| className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 whitespace-nowrap text-fg uppercase" | ||
| style={TEXT_STYLE} | ||
| > | ||
| {LINES.map((line, i) => ( | ||
| <p key={i} className="m-0 whitespace-pre"> | ||
| {line} | ||
| </p> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ) | ||
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import type React from 'react' | ||
| import { cn } from '@/lib/utils/index' | ||
|
|
||
| const LINES = [ | ||
| ' ', | ||
| ' ', | ||
| ' ', | ||
| ' ', | ||
| ' ---**--- ', | ||
| ' -**------**- ', | ||
| ' -**- - -**- ', | ||
| ' ** -**- ** ', | ||
| ' *- --- -* ', | ||
| ' ** ** ', | ||
| ' -**- -**- ', | ||
| ' -- -- ', | ||
| ' ', | ||
| ' ', | ||
| ' ', | ||
| ' ', | ||
| ] | ||
|
|
||
| const TEXT_STYLE: React.CSSProperties = { | ||
| fontSize: '3.802px', | ||
| fontFamily: 'var(--font-mono)', | ||
| fontWeight: 600, | ||
| letterSpacing: '-0.038px', | ||
| lineHeight: '4px', | ||
| fontFeatureSettings: "'ss03' 1", | ||
| } | ||
|
|
||
| export const LimitAsciiIcon = ({ className }: { className?: string }) => ( | ||
| <div className={cn('relative size-[72px]', className)}> | ||
| <div | ||
| className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 whitespace-nowrap text-fg uppercase" | ||
| style={TEXT_STYLE} | ||
| > | ||
| {LINES.map((line, i) => ( | ||
| <p key={i} className="m-0 whitespace-pre"> | ||
| {line} | ||
| </p> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.