mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-05 03:02:56 +00:00
dev day #77
This commit is contained in:
@@ -23,6 +23,8 @@ const PlayerDetailPage: React.FC = () => {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (isError || !data) {
|
||||
return (
|
||||
<MainLayout>
|
||||
@@ -73,7 +75,7 @@ const PlayerDetailPage: React.FC = () => {
|
||||
<Text><b>Národnost:</b> {translateNationality(data.nationality)}</Text>
|
||||
)}
|
||||
{data.date_of_birth && (
|
||||
<Text><b>Datum narození:</b> {new Date(data.date_of_birth).toLocaleDateString('cs-CZ')} — {calculateAge(data.date_of_birth)} let</Text>
|
||||
<Text><b>Datum narození:</b> {new Date(data.date_of_birth).toLocaleDateString('cs-CZ')} — {(() => { const a = calculateAge(data.date_of_birth); return a != null ? `${a} ${czYears(a)}` : '' })()}</Text>
|
||||
)}
|
||||
{(data.height || data.weight) && (
|
||||
<Text>
|
||||
@@ -81,10 +83,10 @@ const PlayerDetailPage: React.FC = () => {
|
||||
</Text>
|
||||
)}
|
||||
{data.email && (
|
||||
<Text><b>Email:</b> {data.email}</Text>
|
||||
<Text><b>Email:</b> <a href={`mailto:${data.email}`}>{data.email}</a></Text>
|
||||
)}
|
||||
{data.phone && (
|
||||
<Text><b>Telefon:</b> {data.phone}</Text>
|
||||
<Text><b>Telefon:</b> <a href={`tel:${normalizeTel(data.phone)}`}>{data.phone}</a></Text>
|
||||
)}
|
||||
{typeof data.team_id === 'number' && data.team_id > 0 && (
|
||||
<Text><b>Tým ID:</b> {data.team_id}</Text>
|
||||
@@ -95,10 +97,8 @@ const PlayerDetailPage: React.FC = () => {
|
||||
</VStack>
|
||||
</Container>
|
||||
|
||||
{/* Newsletter CTA */}
|
||||
<NewsletterCTA />
|
||||
|
||||
{/* Sponsors Section */}
|
||||
<SponsorsSection />
|
||||
</Box>
|
||||
</MainLayout>
|
||||
@@ -119,4 +119,25 @@ function calculateAge(iso: string): number | null {
|
||||
}
|
||||
}
|
||||
|
||||
function czYears(n: number): string {
|
||||
const mod100 = n % 100;
|
||||
if (mod100 >= 11 && mod100 <= 14) return 'let';
|
||||
const mod10 = n % 10;
|
||||
if (mod10 === 1) return 'rok';
|
||||
if (mod10 >= 2 && mod10 <= 4) return 'roky';
|
||||
return 'let';
|
||||
}
|
||||
|
||||
function normalizeTel(input: string): string {
|
||||
if (!input) return '';
|
||||
let s = String(input).trim();
|
||||
s = s.replace(/[\s\-()]/g, '');
|
||||
if (s.startsWith('00')) s = '+' + s.slice(2);
|
||||
s = s.replace(/(?!^)[^\d]/g, '');
|
||||
if (s[0] !== '+' && s.startsWith('+')) {
|
||||
// keep + if present
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
export default PlayerDetailPage;
|
||||
|
||||
Reference in New Issue
Block a user