Files
harheimertc/utils/team-display.js
Torsten Schulz (local) 2103e9c1e8
Some checks failed
Code Analysis and Production Deploy / analyze (push) Failing after 2m27s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Has been skipped
Refactor team name formatting and update version to 1.8.6
2026-08-26 10:22:08 +02:00

23 lines
803 B
JavaScript

/**
* Makes youth teams identifiable while retaining the team name supplied by
* click-TT. Age groups occur in a few forms, for example "Jugend 13",
* "Jugend 13 1. Kreisklasse", and "J13".
*/
export function youthTeamCode(teamAgeGroup, teamName = '') {
const ageGroup = String(teamAgeGroup || '').trim()
const name = String(teamName || '').trim()
const codeMatch = ageGroup.match(/\b(?:jugend\s*|j\s*)(\d{1,2})\b/i)
if (codeMatch) return `J${codeMatch[1]}`
if (/\bjugend\b/i.test(ageGroup) || /\bjugend\b/i.test(name)) return 'J'
return ''
}
export function formatTeamDisplayName(teamName, teamAgeGroup) {
const name = String(teamName || '').trim()
if (!name) return ''
const youthCode = youthTeamCode(teamAgeGroup, name)
return youthCode ? `(${youthCode}) ${name}` : name
}