- Add Plan and PlanFeatures TypeScript interfaces - Add Profile type with plan relationship - Create plan utility functions with Italian labels - Add formatPrice, formatFeatureValue, getPlanBadgeColor helpers
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { PlanFeatures } from '@/types/database'
|
|
|
|
export const PLAN_DISPLAY_ORDER = ['free', 'creator', 'pro'] as const
|
|
|
|
// Feature display names in Italian
|
|
export const FEATURE_LABELS: Record<keyof PlanFeatures, string> = {
|
|
posts_per_month: 'Post al mese',
|
|
ai_models: 'Modelli AI',
|
|
social_accounts: 'Account social',
|
|
image_generation: 'Generazione immagini',
|
|
automation: 'Automazione',
|
|
}
|
|
|
|
export function formatFeatureValue(
|
|
key: keyof PlanFeatures,
|
|
value: PlanFeatures[keyof PlanFeatures]
|
|
): string {
|
|
if (typeof value === 'boolean') {
|
|
return value ? 'Incluso' : 'Non incluso'
|
|
}
|
|
|
|
if (Array.isArray(value)) {
|
|
return value.length.toString()
|
|
}
|
|
|
|
if (key === 'automation') {
|
|
if (value === 'manual') return 'Solo manuale'
|
|
if (value === 'full') return 'Completa'
|
|
return 'Non inclusa'
|
|
}
|
|
|
|
return value.toString()
|
|
}
|
|
|
|
export function formatPrice(cents: number): string {
|
|
if (cents === 0) return 'Gratis'
|
|
return `${(cents / 100).toFixed(0)}/mese`
|
|
}
|
|
|
|
export function getPlanBadgeColor(planName: string): string {
|
|
switch (planName) {
|
|
case 'pro':
|
|
return 'bg-purple-100 text-purple-800 border-purple-200'
|
|
case 'creator':
|
|
return 'bg-blue-100 text-blue-800 border-blue-200'
|
|
default:
|
|
return 'bg-gray-100 text-gray-800 border-gray-200'
|
|
}
|
|
}
|