import React from 'react' import { Ic } from '@/icons' import { SERVICE_LANGUAGES, type ServiceLanguageCode, type ServiceLanguageMeta, type ServiceTranslationProps, } from './types' export function ServiceTranslation({ activeLang, onLangChange, completedLangs, dirtyLangs, primaryLang, title = 'زبان ترجمه و محتوا', showDirectionBadge = true, showGlobeIcon = true, required = false, className = '', variant = 'grid', children, }: ServiceTranslationProps) { const currentLang = SERVICE_LANGUAGES.find((l) => l.code === activeLang) || SERVICE_LANGUAGES[0] const isCompleted = (code: ServiceLanguageCode): boolean => { if (!completedLangs) return false if (Array.isArray(completedLangs)) { return completedLangs.includes(code) } return Boolean(completedLangs[code]) } const isDirty = (code: ServiceLanguageCode): boolean => { if (!dirtyLangs) return false if (Array.isArray(dirtyLangs)) { return dirtyLangs.includes(code) } return Boolean(dirtyLangs[code]) } return (
{/* هدر انتخاب زبان و نمایش دایرکشن */}
{showDirectionBadge && (
جهت متن: {currentLang.dir.toUpperCase()}
)}
{/* تب‌های انتخاب زبان */} {variant === 'pills' ? (
{SERVICE_LANGUAGES.map((lang) => { const isSelected = activeLang === lang.code const hasData = isCompleted(lang.code) const dirty = isDirty(lang.code) const isBase = primaryLang ? primaryLang === lang.code : lang.code === 'ar' return ( ) })}
) : (
{SERVICE_LANGUAGES.map((lang) => { const isSelected = activeLang === lang.code const hasData = isCompleted(lang.code) const dirty = isDirty(lang.code) const isBase = primaryLang ? primaryLang === lang.code : lang.code === 'ar' return ( ) })}
)} {/* اگر کامپوننت حاوی فرزند بود، اینجا قرار می‌گیرد */} {children}
) }