Commit History

  1. when clicking on the card it should show information of the match: like this: <section id="matchDetail" class="mb-12 hidden"> <button id="backToMatches" class="mb-4 flex items-center text-blue-600 hover:text-blue-800"> <i class="fas fa-arrow-left mr-2"></i> Back to Matches </button> <div class="bg-white rounded-xl shadow-lg overflow-hidden"> <div id="matchHeader" class="p-4 bg-blue-900 text-white"> <!-- Match header will be populated by JavaScript --> </div> <div class="p-6"> <div class="flex justify-center items-center mb-6"> <div class="text-center w-1/3"> <div class="text-2xl font-bold" id="homeTeamName">Home Team</div> <div class="text-sm text-gray-600" id="homeTeamCoach">Coach: Unknown</div> </div> <div class="text-center mx-4"> <div class="text-5xl font-bold bg-gray-100 px-8 py-4 rounded-lg" id="matchScore">0 - 0</div> <div class="text-sm mt-2" id="matchStatus">Full Time</div> </div> <div class="text-center w-1/3"> <div class="text-2xl font-bold" id="awayTeamName">Away Team</div> <div class="text-sm text-gray-600" id="awayTeamCoach">Coach: Unknown</div> </div> </div> <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div> <h4 class="font-semibold mb-2 text-lg">Match Events</h4> <div class="bg-gray-50 p-4 rounded-lg"> <ul class="space-y-3" id="matchEvents"> <!-- Match events will be populated by JavaScript --> </ul> </div> </div> <div> <h4 class="font-semibold mb-2 text-lg">Match Statistics</h4> <div class="bg-gray-50 p-4 rounded-lg"> <div class="space-y-4"> <div> <div class="flex justify-between mb-1"> <span class="text-sm font-medium" id="possessionHome">Home: 50%</span> <span class="text-sm font-medium">Possession</span> <span class="text-sm font-medium" id="possessionAway">Away: 50%</span> </div> <div class="w-full bg-gray-200 rounded-full h-2.5"> <div class="bg-blue-600 h-2.5 rounded-full" style="width: 50%"></div> </div> </div> <div> <div class="flex justify-between mb-1"> <span class="text-sm font-medium" id="shotsHome">Home: 0</span> <span class="text-sm font-medium">Shots</span> <span class="text-sm font-medium" id="shotsAway">Away: 0</span> </div> <div class="w-full bg-gray-200 rounded-full h-2.5"> <div class="bg-blue-600 h-2.5 rounded-full" style="width: 50%"></div> </div> </div> <div> <div class="flex justify-between mb-1"> <span class="text-sm font-medium" id="shotsOnTargetHome">Home: 0</span> <span class="text-sm font-medium">Shots on Target</span> <span class="text-sm font-medium" id="shotsOnTargetAway">Away: 0</span> </div> <div class="w-full bg-gray-200 rounded-full h-2.5"> <div class="bg-blue-600 h-2.5 rounded-full" style="width: 50%"></div> </div> </div> <div> <div class="flex justify-between mb-1"> <span class="text-sm font-medium" id="cornersHome">Home: 0</span> <span class="text-sm font-medium">Corners</span> <span class="text-sm font-medium" id="cornersAway">Away: 0</span> </div> <div class="w-full bg-gray-200 rounded-full h-2.5"> <div class="bg-blue-600 h-2.5 rounded-full" style="width: 50%"></div> </div> </div> <div> <div class="flex justify-between mb-1"> <span class="text-sm font-medium" id="foulsHome">Home: 0</span> <span class="text-sm font-medium">Fouls</span> <span class="text-sm font-medium" id="foulsAway">Away: 0</span> </div> <div class="w-full bg-gray-200 rounded-full h-2.5"> <div class="bg-blue-600 h-2.5 rounded-full" style="width: 50%"></div> </div> </div> </div> </div> </div> </div> </div> <div class="p-6 bg-gray-50 border-t border-gray-200"> <h4 class="font-semibold mb-4 text-lg">Lineups</h4> <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div> <h5 class="font-medium mb-2" id="homeLineupTitle">Home Team</h5> <div class="bg-white p-4 rounded-lg shadow"> <ul class="space-y-2" id="homeLineup"> <!-- Home team lineup will be populated by JavaScript --> </ul> </div> </div> <div> <h5 class="font-medium mb-2" id="awayLineupTitle">Away Team</h5> <div class="bg-white p-4 rounded-lg shadow"> <ul class="space-y-2" id="awayLineup"> <!-- Away team lineup will be populated by JavaScript --> </ul> </div> </div> </div> </div> </div> </section> My card: import { Fixture } from '@/types/Fixture'; import React from 'react'; import '/resources/js/pages/custom.css'; interface MatchCardProps { fixture: Fixture; match_week: number; } export const MatchCardList: React.FC<MatchCardProps> = ({ fixture, match_week }) => { const date = new Date(fixture.match_date); const formattedDate = date.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric', }); const formattedTime = date.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', }); const matchTime = date.getTime(); const now = Date.now(); const isLive = matchTime <= now && now <= matchTime + 2 * 60 * 60 * 1000; const handleMatchClick = () => { const matchDetail = document.getElementById('matchDetail'); const matches = document.getElementById('matches'); if (matchDetail && matches) { matchDetail.classList.remove('hidden'); matches.classList.add('hidden'); } // Populate match detail const setText = (id: string, text: string) => { const el = document.getElementById(id); if (el) el.textContent = text; }; setText('homeTeamName', fixture.home_club.name); setText('awayTeamName', fixture.away_club.name); setText('homeTeamCoach', `Coach: ${fixture.home_club.head_coach ?? 'Unknown'}`); setText('awayTeamCoach', `Coach: ${fixture.away_club.head_coach ?? 'Unknown'}`); setText('matchScore', `${fixture.home_score} - ${fixture.away_score}`); setText('matchStatus', fixture.status); setText('matchWeekTitle', `Matchweek ${match_week} - Premier League`); }; return ( <div className="mb-1 cursor-pointer rounded-lg bg-white" onClick={handleMatchClick}> <div className="tab-content active"> <div className="border-b border-gray-200 last:border-b-0"> <div className="match-card rounded-b-lg bg-white p-4 transition duration-300"> <div className="mb-3 flex items-center justify-between"> <span className="text-sm text-gray-500"> {formattedDate} . {formattedTime} {isLive && ( <span className="ml-2 inline-flex items-center rounded-full bg-red-500 px-2 py-1 text-xs text-white">LIVE</span> )} <span className="ml-2 inline-flex items-center rounded-full bg-gray-400 px-2 py-1 text-xs text-white"> {new Date(fixture.match_date).getTime() < Date.now() ? 'Finished' : 'Upcoming'} </span> </span> </div> <div className="flex items-center justify-between text-gray-800"> <div className="flex w-1/3 items-center justify-end"> <span className="mr-3 text-right font-medium">{fixture.home_club.name}</span> <img src={fixture.home_club.crest_image || '/default-club-crest.png'} alt={fixture.home_club.name} className="team-logo h-8 w-8 rounded-full" /> </div> <div className="rounded-lg bg-gray-100 px-4 py-2 text-center"> <div className="text-2xl font-bold"> {fixture.home_score} - {fixture.away_score} </div> <div className="text-xs text-gray-500">{fixture.status}</div> </div> <div className="flex w-1/3 items-center justify-start"> <img src={fixture.away_club.crest_image || '/default-club-crest.png'} alt={fixture.away_club.name} className="team-logo h-8 w-8 rounded-full" /> <span className="ml-3 text-left font-medium">{fixture.away_club.name}</span> </div> </div> <div className="mt-4 flex justify-center space-x-4"> <span className="text-sm font-medium text-purple-900 hover:underline"> <i className="fas fa-info-circle mr-1"></i> Match Details </span> <span className="text-sm font-medium text-purple-900 hover:underline"> <i className="fas fa-chart-line mr-1"></i> Stats </span> </div> </div> </div> </div> </div> ); }; export default MatchCardList; to show in index: import Footer from '@/components/Footer'; import AppLayout from '@/layouts/app-layout'; import { BreadcrumbItem } from '@/types'; import { Fixture } from '@/types/Fixture'; import { Standing } from '@/types/Standing'; import '@fortawesome/fontawesome-free/css/all.min.css'; import { Head, router } from '@inertiajs/react'; import TopTeamStanding from '../standings/TopTeamStanding'; import MatchCardList from './MatchCardList'; import MatchFeatures from './MatchFeatures'; import '/resources/js/pages/custom.css'; interface Props { fixtures: Fixture[]; standing: Standing[]; match_week: number; max_week: number; } const breadcrumbs: BreadcrumbItem[] = [ { title: 'Fixtures', href: '/fixtures', }, ]; function Index({ fixtures, standing, match_week, max_week }: Props) { const currentWeek = Number(match_week); const handlePrevious = () => { if (currentWeek > 1) { router.get(route('fixtures.index'), { match_week: currentWeek - 1 }); } }; const handleNext = () => { if (currentWeek < max_week) { router.get(route('fixtures.index'), { match_week: currentWeek + 1 }); } }; const minDate = new Date(Math.min(...fixtures.map((f) => new Date(f.match_date).getTime()))).toLocaleDateString('en-US', { month: 'short', day: 'numeric', }); const maxDate = new Date(Math.max(...fixtures.map((f) => new Date(f.match_date).getTime()))).toLocaleDateString('en-US', { // Sat month: 'short', // Feb day: 'numeric', year: 'numeric', }); return ( <AppLayout breadcrumbs={breadcrumbs}> <Head title="Fixtures" /> <div className="gradient-bg py-12 text-start text-white"> <div className="container mx-auto px-4"> <h1 className="mb-4 text-4xl font-bold md:text-5xl">Premier League Matches</h1> <p className="mb-6 max-w-2xl text-xl">Follow all the action from the 2024/25 Premier League season</p> <div className="flex flex-col items-start justify-between space-y-4 md:flex-row md:items-center md:space-y-0"> <div className="flex items-center space-x-2"> <button onClick={handlePrevious} className="bg-opacity-20 hover:bg-opacity-30 cursor-pointer rounded-full bg-white p-2 hover:bg-gray-400" > <i className="fa-solid fa-chevron-left text-black"></i> </button> <span className="font-medium">Matchweek {currentWeek}</span> <button onClick={handleNext} disabled={currentWeek === max_week} className={`rounded-full p-2 transition ${ currentWeek === max_week ? 'bg-gray-300 text-gray-500' : 'cursor-pointer bg-white text-black hover:bg-gray-400' }`} > <i className="fa-solid fa-chevron-right" /> </button> <span className="ml-4 text-sm">{minDate === maxDate ? minDate : `${minDate} - ${maxDate}`}</span> </div> </div> </div> </div> {/* Match Tabs */} <div className="container mx-auto px-4 py-8"> <div className="mb-8 rounded-lg bg-white shadow-md"> <div className="gradient-bg flex rounded-t-lg border-b border-gray-200"> <button className="tab-btn active px-6 py-4 font-medium text-white">All Matches</button> {/* <button className="tab-btn px-6 py-4 font-medium text-white">Live Now</button> */} <button className="tab-btn px-6 py-4 font-medium text-white">Upcoming</button> <button className="tab-btn px-6 py-4 font-medium text-white">Results</button> </div> {/* Match contents */} <div className="container"> {fixtures.map((fixture) => ( <MatchCardList key={fixture.id} fixture={fixture} match_week={match_week} /> ))} </div> </div> {/* Feature */} <div className="mb-8 rounded-lg bg-white shadow-md"> <div className="gradient-bg rounded-t-lg p-4 text-white"> <h2 className="flex items-center text-xl font-bold"> <i className="fas fa-table mr-2"></i> Featured Match: Manchester City vs Chelsea </h2> </div> {/* Table */} <div className="container"> <MatchFeatures /> </div> </div> {/* Standing */} <div className="mb-8 rounded-lg bg-white shadow-md"> <div className="gradient-bg rounded-t-lg p-4 text-white"> <h2 className="flex items-center text-xl font-bold"> <i className="fas fa-table mr-2"></i> Matchweek {currentWeek} Standings </h2> </div> {/* Table */} <div className="container"> <TopTeamStanding standing={standing} /> </div> </div> </div> <Footer /> </AppLayout> ); } export default Index; - Initial Deployment

    Verified signature
    d0c7ef9
  2. initial commit

    Verified signature
    2e5931d