steelforesight/src/data/plans.ts

109 lines
3.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export type PlanCtaVariant = 'outline' | 'filled' | 'paper';
export interface Plan {
id: string;
name: string;
price: number;
priceLabel: string;
period: string;
features: string[];
badge?: string;
featured: boolean;
ctaLabel: string;
ctaVariant: PlanCtaVariant;
}
export const plans: Plan[] = [
{
id: 'individual',
name: 'فردی',
price: 350000,
priceLabel: '۳۵۰,۰۰۰ تومان',
period: 'ماهانه',
features: [
'دسترسی به تمام گزارش‌های پایه',
'دانلود ۵ گزارش در ماه',
'دریافت خبرنامه هفتگی',
'دسترسی به داده‌های قیمت لحظه‌ای',
'آرشیو ۱۲ ماه گذشته',
],
featured: false,
ctaLabel: 'شروع اشتراک',
ctaVariant: 'outline',
},
{
id: 'organizational',
name: 'سازمانی',
price: 1200000,
priceLabel: '۱,۲۰۰,۰۰۰ تومان',
period: 'ماهانه',
features: [
'دسترسی کامل به تمام گزارش‌ها',
'دانلود نامحدود گزارش',
'دسترسی برای ۵ کاربر همزمان',
'گزارش‌های ویژه و تحلیل‌های فوری',
'آرشیو کامل از ابتدای تأسیس',
'مشاوره تلفنی ماهانه با تحلیلگران',
'داشبورد اختصاصی تحلیل بازار',
],
badge: 'پرطرفدار',
featured: true,
ctaLabel: 'شروع اشتراک',
ctaVariant: 'filled',
},
{
id: 'ministry',
name: 'وزارتخانه',
price: 0,
priceLabel: 'تماس بگیرید',
period: 'سالانه',
features: [
'دسترسی نامحدود برای تمام کارکنان',
'سفارش گزارش‌های تحلیلی اختصاصی',
'نشست‌های تخصصی حضوری با تیم پژوهشی',
'پشتیبانی اولویت‌دار ۲۴/۷',
'داشبورد تصمیم‌گیری یکپارچه',
'API اتصال به سیستم‌های داخلی',
'آموزش و کارگاه‌های تخصصی دوره‌ای',
'گزارش‌دهی سفارشی برای سیاست‌گذاران',
],
featured: false,
ctaLabel: 'درخواست مشاوره',
ctaVariant: 'paper',
},
];
const PANEL_API =
(import.meta as ImportMeta & { env?: Record<string, string> }).env?.VITE_PANEL_API ||
'http://localhost:3001';
export async function bootstrapPlans(): Promise<void> {
try {
const res = await fetch(`${PANEL_API}/api/plans`);
if (!res.ok) return;
const fetched = await res.json();
if (!Array.isArray(fetched) || fetched.length === 0) return;
plans.length = 0;
plans.push(
...fetched.map((p: Record<string, unknown>) => {
const price = Number(p.price) || 0;
const featured = Boolean(p.isFeatured);
return {
id: String(p.id),
name: String(p.nameFa ?? ''),
price,
priceLabel: price > 0 ? `${price.toLocaleString('fa-IR')} تومان` : 'تماس بگیرید',
period: String(p.periodFa ?? ''),
features: Array.isArray(p.features) ? (p.features as string[]) : [],
badge: (p.badgeFa as string) || undefined,
featured,
ctaLabel: String(p.ctaFa ?? 'شروع اشتراک'),
ctaVariant: (featured ? 'filled' : price === 0 ? 'paper' : 'outline') as PlanCtaVariant,
};
}),
);
} catch {
/* panel offline → keep static fallback */
}
}