/opt/canhelp/apps/web/src/lib
Edit: /opt/canhelp/apps/web/src/lib/taskLocale.ts (941B)
import type { Task } from '@canhelp/shared'
import type { Locale } from './translations'
export function taskTitle(task: Task, locale: Locale): string {
if (locale === 'el' && task.titleEl) return task.titleEl
if (locale === 'en' && task.titleEn) return task.titleEn
if (locale === 'ru' && task.titleRu) return task.titleRu
return task.title
}
/** Display a price without decimal cents: 100.00 → 100, 99.5 → 100 */
export function formatPrice(value: number | string | null | undefined): string {
if (value === null || value === undefined || value === '') return ''
return Math.round(Number(value)).toString()
}
export function taskDescription(task: Task, locale: Locale): string {
if (locale === 'el' && task.descriptionEl) return task.descriptionEl
if (locale === 'en' && task.descriptionEn) return task.descriptionEn
if (locale === 'ru' && task.descriptionRu) return task.descriptionRu
return task.description
}