|
| 1 | +'use client'; |
| 2 | + |
| 3 | +import { useRouter } from 'next/navigation'; |
| 4 | +import { ArrowLeft, MapPin, Building2 } from 'lucide-react'; |
| 5 | +import { getCountryName } from '@/lib/utils'; |
| 6 | +import { NETWORK_CARD } from '@/lib/constants'; |
| 7 | +import type { NetworkWithStations } from '@/types'; |
| 8 | + |
| 9 | +interface StationsHeaderProps { |
| 10 | + network: NetworkWithStations; |
| 11 | +} |
| 12 | + |
| 13 | +export function StationsHeader({ network }: StationsHeaderProps) { |
| 14 | + const router = useRouter(); |
| 15 | + const { name, location, company } = network; |
| 16 | + |
| 17 | + const handleBack = () => { |
| 18 | + if (window.history.length > 1) { |
| 19 | + router.back(); |
| 20 | + } else { |
| 21 | + router.push('/'); |
| 22 | + } |
| 23 | + }; |
| 24 | + const visibleCompanies = company.slice(0, NETWORK_CARD.MAX_VISIBLE_COMPANIES); |
| 25 | + const remainingCount = company.length - NETWORK_CARD.MAX_VISIBLE_COMPANIES; |
| 26 | + const companiesText = visibleCompanies.join(', '); |
| 27 | + |
| 28 | + return ( |
| 29 | + <div className="relative flex flex-col gap-6 px-10 py-8 min-h-[252px]"> |
| 30 | + {/* Background image with gradient fade */} |
| 31 | + <div className="absolute inset-0 bg-[linear-gradient(rgba(0,0,0,0.25),rgba(0,0,0,0.25)),url('/stations_header.jpg')] bg-cover bg-center"> |
| 32 | + <div className="absolute inset-0 bg-gradient-to-t from-torea-bay-800 from-0% via-torea-bay-800/25 via-45% to-transparent to-100%" /> |
| 33 | + </div> |
| 34 | + |
| 35 | + {/* Back button */} |
| 36 | + <button |
| 37 | + onClick={handleBack} |
| 38 | + className="relative z-10 inline-flex w-fit items-center gap-2 text-sm font-medium text-grenadier-400 cursor-pointer" |
| 39 | + > |
| 40 | + <div className="flex h-10 w-10 items-center justify-center rounded-full bg-white"> |
| 41 | + <ArrowLeft className="h-5 w-5" /> |
| 42 | + </div> |
| 43 | + </button> |
| 44 | + |
| 45 | + {/* Network info */} |
| 46 | + <div className="relative z-10 flex flex-col gap-3"> |
| 47 | + <h1 className="text-2xl font-bold text-white">{name}</h1> |
| 48 | + |
| 49 | + {/* Location */} |
| 50 | + <div className="flex items-center gap-2 text-sm"> |
| 51 | + <div className="flex h-6 w-6 items-center justify-center"> |
| 52 | + <MapPin className="h-4 w-4 text-white" /> |
| 53 | + </div> |
| 54 | + <span className="text-white"> |
| 55 | + {location.city}, {getCountryName(location.country)} |
| 56 | + </span> |
| 57 | + </div> |
| 58 | + |
| 59 | + {/* Companies */} |
| 60 | + {company.length > 0 && ( |
| 61 | + <div className="flex items-center gap-2 text-sm"> |
| 62 | + <div className="flex h-6 w-6 items-center justify-center"> |
| 63 | + <Building2 className="h-4 w-4 text-white" /> |
| 64 | + </div> |
| 65 | + <span className="text-white">{companiesText}</span> |
| 66 | + {remainingCount > 0 && ( |
| 67 | + <span className="shrink-0 rounded border border-white/50 px-1.5 py-0.5 text-xs text-white"> |
| 68 | + +{remainingCount} |
| 69 | + </span> |
| 70 | + )} |
| 71 | + </div> |
| 72 | + )} |
| 73 | + </div> |
| 74 | + </div> |
| 75 | + ); |
| 76 | +} |
0 commit comments