mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Remove nested git repository from bugulma/frontend/.git - Add all frontend files to main repository tracking - Convert from separate frontend/backend repos to unified monorepo - Preserve all frontend code and development history as tracked files - Eliminate nested repository complexity for simpler development workflow This creates a proper monorepo structure with frontend and backend coexisting in the same repository for easier development and deployment.
71 lines
2.9 KiB
TypeScript
71 lines
2.9 KiB
TypeScript
/**
|
|
* Maps backend sector names to frontend translation keys
|
|
* If a sector doesn't have a mapping, returns the raw sector name
|
|
*/
|
|
|
|
/**
|
|
* Maps a backend sector name to a frontend translation key
|
|
* Returns the translation key if a mapping exists, otherwise returns the raw sector name
|
|
*/
|
|
export function mapBackendSectorToTranslationKey(sector: string): string {
|
|
const sectorMap: Record<string, string> = {
|
|
// Capitalized sectors (legacy)
|
|
Construction: 'sectors.list.construction',
|
|
Production: 'sectors.list.production',
|
|
'Recreation & Services': 'sectors.list.recreation',
|
|
Logistics: 'sectors.list.logistics',
|
|
|
|
// Map backend sectors to closest frontend sectors
|
|
'Food & Beverage': 'sectors.list.production', // Food production
|
|
'Retail & Commerce': 'sectors.list.logistics', // Commerce/logistics
|
|
Healthcare: 'sectors.list.recreation', // Services
|
|
Automotive: 'sectors.list.production', // Manufacturing
|
|
'Financial Services': 'sectors.list.recreation', // Services
|
|
'Furniture & Interior': 'sectors.list.production', // Manufacturing
|
|
'Beauty & Wellness': 'sectors.list.recreation', // Services
|
|
'Business Services': 'sectors.list.recreation', // Services
|
|
'Other Services': 'sectors.list.recreation', // Services
|
|
|
|
// Lowercase sectors from current API
|
|
restaurant: 'sectors.list.recreation', // Restaurant services
|
|
clinic: 'sectors.list.recreation', // Healthcare services
|
|
theatre: 'sectors.list.recreation', // Cultural services
|
|
hotel: 'sectors.list.recreation', // Hospitality services
|
|
shop: 'sectors.list.logistics', // Retail
|
|
cafe: 'sectors.list.recreation', // Food services
|
|
pharmacy: 'sectors.list.recreation', // Healthcare
|
|
school: 'sectors.list.recreation', // Education
|
|
bank: 'sectors.list.recreation', // Financial services
|
|
museum: 'sectors.list.recreation', // Cultural
|
|
library: 'sectors.list.recreation', // Education
|
|
hospital: 'sectors.list.recreation', // Healthcare
|
|
factory: 'sectors.list.production', // Manufacturing
|
|
warehouse: 'sectors.list.logistics', // Logistics
|
|
office: 'sectors.list.recreation', // Business services
|
|
store: 'sectors.list.logistics', // Retail
|
|
};
|
|
|
|
return sectorMap[sector] || 'sectors.list.recreation'; // Default to recreation/services
|
|
}
|
|
|
|
/**
|
|
* Gets the translated sector name
|
|
* If the sector has a translation key, uses it; otherwise returns the raw sector name
|
|
*/
|
|
export function getTranslatedSectorName(sector: string, t: (key: string) => string): string {
|
|
const translationKey = mapBackendSectorToTranslationKey(sector);
|
|
|
|
// If it's a translation key (starts with 'sectors.'), translate it
|
|
if (translationKey.startsWith('sectors.')) {
|
|
const translated = t(`${translationKey}.name`);
|
|
// If translation failed (returned the key), fall back to raw sector name
|
|
if (translated === `${translationKey}.name`) {
|
|
return sector;
|
|
}
|
|
return translated;
|
|
}
|
|
|
|
// Otherwise, return the raw sector name
|
|
return sector;
|
|
}
|