uniradar/src/utils/persianNumbers.ts

107 lines
3.0 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.

import { Horizon, Category, ForceType, PersonaType } from '../types/futures';
export const toPersianDigits = (num: number | string | null | undefined): string => {
if (num === null || num === undefined) return '';
const str = String(num);
const persianDigits = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
return str.replace(/[0-9]/g, (w) => persianDigits[parseInt(w, 10)]);
};
export const getHorizonLabelFa = (horizon: Horizon): string => {
switch (horizon) {
case 'now':
return 'اکنون (۱۴۰۳-۱۴۰۵)';
case 'near':
return 'افق نزدیک (۱۴۰۵-۱۴۰۸)';
case 'mid':
return 'میان‌مدت (۱۴۰۸-۱۴۱۱)';
case 'long':
return 'بلندمدت (۱۴۱۱-۱۴۱۵)';
default:
return horizon;
}
};
export const getHorizonShortFa = (horizon: Horizon): string => {
switch (horizon) {
case 'now':
return 'اکنون';
case 'near':
return 'نزدیک';
case 'mid':
return 'میان‌مدت';
case 'long':
return 'بلندمدت';
default:
return horizon;
}
};
export const getCategoryLabelFa = (cat: Category): string => {
switch (cat) {
case 'trend':
return 'روندها (Trends)';
case 'technology':
return 'فناوری‌ها (Tech)';
case 'policy':
return 'سیاست‌ها (Policies)';
case 'weak_signal':
return 'سیگنال‌های آینده (Signals)';
default:
return cat;
}
};
export const getCategoryColor = (cat: Category): string => {
switch (cat) {
case 'trend':
return '#38bdf8'; // Blue/Sky
case 'technology':
return '#00d4aa'; // Teal/Emerald
case 'policy':
return '#fbbf24'; // Amber
case 'weak_signal':
return '#f43f5e'; // Rose/Coral
default:
return '#94a3b8';
}
};
export const getForceLabelFa = (type: ForceType): string => {
switch (type) {
case 'pull':
return 'کشش آینده (Pull)';
case 'push':
return 'فشارهای حال (Push)';
case 'weight':
return 'وزن گذشته (Weight)';
default:
return type;
}
};
export const getPersonaLabelFa = (p: PersonaType): { title: string; subtitle: string } => {
switch (p) {
case 'president':
return {
title: 'ریاست و هیئت رئیسه دانشگاه',
subtitle: 'دیدگاه راهبردی کلان و تصمیم‌گیری سازمانی'
};
case 'researcher':
return {
title: 'پژوهشگر آینده‌پژوهی و تحلیل‌گر علم',
subtitle: 'کاوش سیگنال‌های ضعیف و شواهد تجربی'
};
case 'planner':
return {
title: 'برنامه‌ریز راهبردی و تحول آموزشی',
subtitle: 'سنجش شکاف قابلیت‌ها و نقشه راه ۱۴۱۵'
};
case 'admin':
return {
title: 'مدیر ارشد سامانه هوشمندی',
subtitle: 'مدیریت داده‌ها و کالیبراسیون شاخص‌ها'
};
}
};