feat: enhance dashboard and canvas components with credit management features
- Integrated CreditOverview and RecentTransactions components into the dashboard for better credit visibility. - Updated canvas toolbar to display current credit balance using CreditDisplay. - Improved AI image and prompt nodes to show credit costs and handle credit availability checks during image generation. - Added new queries for fetching recent transactions and monthly usage statistics to support dashboard features. - Refactored existing code to streamline credit-related functionalities across components.
This commit is contained in:
@@ -7,6 +7,8 @@ export interface AiModel {
|
||||
tier: "budget" | "standard" | "premium";
|
||||
description: string;
|
||||
estimatedCost: string; // human-readable, e.g. "~€0.04"
|
||||
/** Credits pro Generierung — gleiche Einheit wie Convex reserve/commit (Euro-Cent). */
|
||||
creditCost: number;
|
||||
minTier: "free" | "starter" | "pro" | "business"; // minimum subscription tier
|
||||
}
|
||||
|
||||
@@ -17,6 +19,7 @@ export const IMAGE_MODELS: AiModel[] = [
|
||||
tier: "standard",
|
||||
description: "Fast, high-quality generation",
|
||||
estimatedCost: "~€0.04",
|
||||
creditCost: 4,
|
||||
minTier: "free",
|
||||
},
|
||||
// Phase 2 — uncomment when model selector UI is ready:
|
||||
|
||||
20
lib/format-time.ts
Normal file
20
lib/format-time.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Formatiert einen Timestamp als relative Zeitangabe.
|
||||
* Beispiele: "Just now", "5m ago", "3h ago", "2d ago", "12. Mär"
|
||||
*/
|
||||
export function formatRelativeTime(timestamp: number): string {
|
||||
const now = Date.now();
|
||||
const diff = now - timestamp;
|
||||
const minutes = Math.floor(diff / 60000);
|
||||
const hours = Math.floor(diff / 3600000);
|
||||
const days = Math.floor(diff / 86400000);
|
||||
|
||||
if (minutes < 1) return "Just now";
|
||||
if (minutes < 60) return `${minutes}m ago`;
|
||||
if (hours < 24) return `${hours}h ago`;
|
||||
if (days < 7) return `${days}d ago`;
|
||||
return new Date(timestamp).toLocaleDateString("de-DE", {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user