diff --git a/app/src/pages/profile/ProfileInfo.tsx b/app/src/pages/profile/ProfileInfo.tsx index 0dc8093..73da5c6 100644 --- a/app/src/pages/profile/ProfileInfo.tsx +++ b/app/src/pages/profile/ProfileInfo.tsx @@ -1,7 +1,23 @@ import { useEffect, useRef, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useQueryClient } from '@tanstack/react-query'; -import { Check, Pencil, Plus, Search, Trash2 } from 'lucide-react'; +import { + ArrowRight, + AtSign, + Cake, + Check, + Clock, + Link2, + Pencil, + Phone, + Plus, + Ruler, + Search, + Sparkles, + Trash2, + User, + type LucideIcon, +} from 'lucide-react'; import { updateProfile, useFocusAreas, useFocusChain, useMe } from '../../api/queries'; import type { Availability, @@ -15,7 +31,6 @@ import { Button, Card, Field, - H3, Input, Loading, Modal, @@ -27,12 +42,14 @@ import { } from '../../components/ui'; import { useToast } from '../../components/toast'; import { AvailabilityEditor } from '../../components/AvailabilityEditor'; -import { SOCIAL_MEDIA_LABELS } from '../../lib/labels'; +import { MUSCLE_COLORS, MUSCLE_NAMES, SOCIAL_MEDIA_LABELS } from '../../lib/labels'; import { emptyAvailability, - formatAvailability, + formatAvailabilityParts, normalizeAvailability, } from '../../lib/availability'; +import { displayName } from '../../lib/format'; +import { Avatar } from '../../components/Avatar'; import { useTopbar } from '../../topbar'; type MuscleField = 'developMuscles' | 'canDoMuscles' | 'difficultMuscles' | 'avoidMuscles'; @@ -43,6 +60,9 @@ const MUSCLE_TONES = { active: 'bg-accent/15 text-accent-text border-accent/40', badge: 'green', text: 'text-accent-text', + /* podświetlenie grupy w karcie ciągu (bg + border lewy + kolor tekstu) */ + tint: 'border-accent/40 bg-accent/10', + dot: 'bg-accent', label: 'Co rozwija', chainPrefix: 'do rozwoju: ', }, @@ -50,6 +70,8 @@ const MUSCLE_TONES = { active: 'bg-info/15 text-info border-info/40', badge: 'blue', text: 'text-info', + tint: 'border-info/40 bg-info/10', + dot: 'bg-info', label: 'Co potrafi', chainPrefix: '', }, @@ -57,6 +79,8 @@ const MUSCLE_TONES = { active: 'bg-warn/15 text-warn border-warn/40', badge: 'yellow', text: 'text-warn', + tint: 'border-warn/40 bg-warn/10', + dot: 'bg-warn', label: 'Co trudne', chainPrefix: '', }, @@ -64,6 +88,8 @@ const MUSCLE_TONES = { active: 'bg-danger/15 text-danger border-danger/40', badge: 'red', text: 'text-danger', + tint: 'border-danger/40 bg-danger/10', + dot: 'bg-danger', label: 'Co unikać', chainPrefix: 'unikamy: ', }, @@ -102,15 +128,79 @@ interface MuscleFormState { avoidMuscles: string[]; } -function InfoRow({ label, value }: { label: string; value: string }) { +/* Płytka informacyjna: ikona w tonie akcentu + etykieta + wartość (spójna z + mini-statystykami przeglądu profilu). Puste wartości wyciszone. */ +function InfoTile({ + icon: Icon, + label, + value, +}: { + icon: LucideIcon; + label: string; + value: string; +}) { + const empty = value === '—'; return ( -
- {label} - {value} +
+ + + +
+
{label}
+
+ {value} +
+
); } +/* Płytki link społecznościowy: markowa kropka z inicjałem + nazwa + adres + strzałka. */ +const SOCIAL_BRAND: Record = { + INSTAGRAM: { color: 'linear-gradient(150deg,#f09433,#dc2743,#bc1888)', initial: 'i' }, + TIKTOK: { color: 'linear-gradient(150deg,#25f4ee,#000 60%,#fe2c55)', initial: 'T' }, + YOUTUBE: { color: 'linear-gradient(150deg,#ff5b4a,#c4302b)', initial: 'Y' }, + FACEBOOK: { color: 'linear-gradient(150deg,#5b8def,#1877f2)', initial: 'f' }, + X: { color: 'linear-gradient(150deg,#6b7280,#111)', initial: 'X' }, + OTHER: { color: 'linear-gradient(150deg,#8fa3b8,#5f7183)', initial: '·' }, +}; + +function hostOf(url: string): string { + try { + return new URL(url).hostname.replace(/^www\./, ''); + } catch { + return url; + } +} + +function SocialTile({ entry }: { entry: SocialMediaEntry }) { + const label = + entry.platform === 'OTHER' ? entry.label || 'Inne' : SOCIAL_MEDIA_LABELS[entry.platform]; + const brand = SOCIAL_BRAND[entry.platform]; + return ( + + + + {label} + {hostOf(entry.url)} + + + + ); +} + function MuscleChips({ areas, selected, @@ -219,33 +309,66 @@ function SocialMediaEditor({ ); } -/* Ciąg przyczynowo-skutkowy: 4 sekcje (rozwija / potrafi / trudne / unikać). */ +/* Ciąg przyczynowo-skutkowy: 4 kafelki w tonie grupy (kolor spójny z „Priorytety + i wykluczenia”); puste tony wyciszone. Nazwy mięśni ujednolicone z resztą aplikacji. */ function FocusChainCard({ chain }: { chain: FocusChain | undefined }) { return ( + + Ciąg przyczynowo-skutkowy + + } description="Ćwiczenia z aktywnego planu w kontekście Twoich celów i wykluczeń." /> {chain ? ( -
+
{(Object.keys(MUSCLE_TONES) as MuscleTone[]).map((tone) => { const entries = chain[tone] ?? []; + const t = MUSCLE_TONES[tone]; return ( -
-

{MUSCLE_TONES[tone].label}

+
0 ? t.tint : 'border-line bg-input/40' + }`} + > +
+ 0 ? t.dot : 'bg-dim/40' + }`} + aria-hidden="true" + /> + 0 ? t.text : 'text-dim' + }`} + > + {t.label} + +
{entries.length === 0 ? ( - — + brak akcentów w planie ) : ( -
+
{entries.map((e) => (
-
{e.name}
-
+
+ + {MUSCLE_NAMES[e.muscle] ?? e.name} + + {(e.exercises ?? []).length > 0 && ( + + {(e.exercises ?? []).length} + + )} +
+
{(e.exercises ?? []).length > 0 - ? `${MUSCLE_TONES[tone].chainPrefix}${(e.exercises ?? []) - .map((x) => x.name) - .join(', ')}` + ? `${t.chainPrefix}${(e.exercises ?? []).map((x) => x.name).join(', ')}` : 'brak w aktywnym planie'}
@@ -433,50 +556,98 @@ export default function ProfileInfo() { ); } + const name = displayName(user ?? {}); + const availabilityParts = formatAvailabilityParts(user?.availability); + return ( <> } actions={ navigate('/profile')} />} /> - {/* Karta 1: podstawowe dane */} + {/* Karta 1: podstawowe dane — siatka płytek z ikonami + dostępność jako chipy */} -
- - - - - - - +
+ + + + + + +
+
+
+ + Dostępność +
+ {availabilityParts.length > 0 ? ( +
+ {availabilityParts.map((p) => ( + + {p} + + ))} +
+ ) : ( + Brak ustawionej dostępności + )}
- {/* Karta 2: priorytety i wykluczenia (4 grupy mięśni) */} + {/* Karta 2: priorytety i wykluczenia — 4 kafelki w tonie grupy */} -
+
{(Object.keys(MUSCLE_TONES) as MuscleTone[]).map((tone) => { const musclesList = user?.[MUSCLE_FIELD_BY_TONE[tone]] ?? []; + const t = MUSCLE_TONES[tone]; return ( -
-
- {MUSCLE_TONES[tone].label} +
0 ? t.tint : 'border-line bg-input/40' + }`} + > +
+ 0 ? t.dot : 'bg-dim/40' + }`} + aria-hidden="true" + /> + 0 ? t.text : 'text-dim' + }`} + > + {t.label} + + {musclesList.length > 0 && ( + + {musclesList.length} + + )}
{musclesList.length > 0 ? ( musclesList.map((m) => ( {areaName(m)} )) ) : ( - — + nic nie dodano )}
@@ -485,26 +656,21 @@ export default function ProfileInfo() {
- {/* Karta 3: social media */} + {/* Karta 3: social media — kafelki linków z markową kropką i domeną */} -
- {(user?.socialMedia ?? []).length > 0 ? ( - (user?.socialMedia ?? []).map((s, i) => ( - - {s.platform === 'OTHER' ? s.label || 'Inne' : SOCIAL_MEDIA_LABELS[s.platform]} - - )) - ) : ( - — - )} -
+ {(user?.socialMedia ?? []).length > 0 ? ( +
+ {(user?.socialMedia ?? []).map((s, i) => ( + + ))} +
+ ) : ( +
+ + Brak dodanych profili. +
+ )}