|
90 | 90 |
|
91 | 91 | let credits = $state(0); |
92 | 92 | let creditsUsed = $state(0); |
| 93 | + let enforcedCreditLimit = $state(0); |
| 94 | +
|
| 95 | + let monthlyCredits = $state(0); |
| 96 | + let dailyCredits: number | null = $state(null); |
| 97 | +
|
93 | 98 | let showSupport = $state(false); |
94 | 99 | let activeTheme = $state($app.theme); |
95 | 100 | let shouldAnimateThemeToggle = $state(false); |
|
130 | 135 |
|
131 | 136 | const usage = await sdk.forConsole.billing.listUsage(org.$id, startDate, endDate); |
132 | 137 | creditsUsed = usage.imagineCreditsTotal; |
133 | | - const creditsLimit = plan?.limits?.credits ?? 0; |
134 | 138 |
|
135 | | - credits = Math.max(0, creditsLimit - creditsUsed); |
| 139 | + monthlyCredits = plan?.limits?.credits ?? 0; |
| 140 | + dailyCredits = plan?.limits?.dailyCredits ?? null; |
| 141 | + enforcedCreditLimit = dailyCredits ?? monthlyCredits ?? 0; |
| 142 | +
|
| 143 | + credits = Math.max(0, enforcedCreditLimit - creditsUsed); |
136 | 144 | } |
137 | 145 |
|
138 | 146 | beforeNavigate(() => (showAccountMenu = false)); |
|
307 | 315 | >{credits} Credit(s) left |
308 | 316 | </Layout.Stack> |
309 | 317 | <svelte:fragment slot="more"> |
310 | | - <ProgressBar |
311 | | - maxSize={plan.limits.credits ?? 0} |
312 | | - data={[ |
313 | | - { |
314 | | - size: credits, |
315 | | - color: 'var(--bgcolor-neutral-invert)' |
316 | | - } |
317 | | - ]} /> |
| 318 | + <Layout.Stack> |
| 319 | + <ProgressBar |
| 320 | + maxSize={enforcedCreditLimit} |
| 321 | + data={[ |
| 322 | + { |
| 323 | + size: credits, |
| 324 | + color: 'var(--bgcolor-neutral-invert)' |
| 325 | + } |
| 326 | + ]} /> |
| 327 | + |
| 328 | + {#if dailyCredits !== null} |
| 329 | + <Typography.Caption> |
| 330 | + {dailyCredits} daily and {monthlyCredits} monthly |
| 331 | + credits |
| 332 | + </Typography.Caption> |
| 333 | + {/if} |
| 334 | + </Layout.Stack> |
318 | 335 | </svelte:fragment> |
319 | 336 | </ActionMenu.Item.Anchor> |
320 | 337 | <Divider /> |
|
0 commit comments