Live demo - https://srikanth-kandi.github.io/react-ipl-dashboard/
In this project, let's build an IPL Dashboard App by applying the concepts we have learned till now.
Click to view
- Extra Small (Size < 576px) and Small (Size >= 576px) - Home
- Extra Small (Size < 576px) and Small (Size >= 576px) - Team Matches
- Medium (Size >= 768px), Large (Size >= 992px) and Extra Large (Size >= 1200px) - Home
- Medium (Size >= 768px), Large (Size >= 992px) and Extra Large (Size >= 1200px) - Team Matches
Click to view
- Download dependencies by running
pnpm install
- Start up the app using
pnpm start
- Build and run with Docker Compose:
docker-compose up --build
- Or run with Docker directly:
docker run -d --name ipl-dashboard -p 3000:80 srikanthkandi/react-ipl-dashboard:latest
- Access the app at
http://localhost:3000
-
Build and push to Docker Hub:
# Windows .\build-and-push.bat v1.0.1 srikanthkandi # Linux/Mac ./build-and-push.sh v1.0.1 srikanthkandi
-
Deploy on Ubuntu server:
# Run container docker run -d --name ipl-dashboard -p 3001:80 srikanthkandi/react-ipl-dashboard:latest # Or with docker-compose docker-compose up -d
-
Configure Nginx reverse proxy (add to your existing Nginx config):
location /ipl/ { proxy_pass http://127.0.0.1:3001/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_cache_bypass $http_upgrade; }
The project includes the following Docker files:
Dockerfile
- Multi-stage production build with Nginxdocker-compose.yml
- Simple orchestration for local and productionnginx.conf
- Nginx configuration for serving the React appbuild-and-push.bat
/build-and-push.sh
- Scripts to build and push to Docker Hubrun-container.bat
/run-container.sh
- Scripts to run the container easilynginx-config-example.conf
- Example Nginx reverse proxy configuration
# Build and run with Docker Compose
docker-compose up --build
# Run in background (detached mode)
docker-compose up -d --build
# Stop containers
docker-compose down
# View logs
docker-compose logs -f
# Rebuild and restart
docker-compose up --build --force-recreate
# Build image locally
docker build -t srikanthkandi/react-ipl-dashboard:latest .
# Run container
docker run -d --name ipl-dashboard -p 3000:80 srikanthkandi/react-ipl-dashboard:latest
# Run on custom port
docker run -d --name ipl-dashboard -p 8080:80 srikanthkandi/react-ipl-dashboard:latest
# Stop container
docker stop ipl-dashboard
# Remove container
docker rm ipl-dashboard
# View logs
docker logs ipl-dashboard
# Follow logs in real-time
docker logs -f ipl-dashboard
# Execute commands inside container
docker exec -it ipl-dashboard sh
# Check container status
docker ps
# Check all containers (including stopped)
docker ps -a
# Build and push to Docker Hub (Windows)
.\build-and-push.bat v1.0.1 srikanthkandi
# Build and push to Docker Hub (Linux/Mac)
./build-and-push.sh v1.0.1 srikanthkandi
# Login to Docker Hub
docker login
# Pull latest image
docker pull srikanthkandi/react-ipl-dashboard:latest
# Push specific tag
docker push srikanthkandi/react-ipl-dashboard:v1.0.1
# Update container to latest version
docker pull srikanthkandi/react-ipl-dashboard:latest
docker stop ipl-dashboard
docker rm ipl-dashboard
docker run -d --name ipl-dashboard -p 3000:80 srikanthkandi/react-ipl-dashboard:latest
# Restart container
docker restart ipl-dashboard
# Check container health
docker inspect ipl-dashboard
# View container resource usage
docker stats ipl-dashboard
# Clean up unused images
docker image prune -f
# Clean up everything (containers, networks, images)
docker system prune -a
# Check if port is in use
netstat -tulpn | grep :3000
# Test container connectivity
curl http://localhost:3000
# Check nginx configuration inside container
docker exec ipl-dashboard nginx -t
# View nginx access logs
docker exec ipl-dashboard tail -f /var/log/nginx/access.log
# View nginx error logs
docker exec ipl-dashboard tail -f /var/log/nginx/error.log
Functionality to be added
The app must have the following functionalities
- When the app is opened, Home Route should be displayed
- When the Home Route is opened,
- Make HTTP GET request to the teamsApiUrl
- loader should be displayed while fetching the data
- After fetching the data, the list of teams should be displayed
- When a team card in Home Route is clicked,
- Page should be navigated to the Team Matches Route with the URL
/team-matches/:id
- Page should be navigated to the Team Matches Route with the URL
- When the Team Matches Route is opened,
- Make HTTP GET request to the teamMatchesApiUrl with the team id to get the recent matches data of the team
- Example:
https://apis.ccbp.in/ipl/KKR
- Example:
- loader should be displayed while fetching the data
- After fetching the data, the team banner, latest match, and list of recent matches should be displayed
- Make HTTP GET request to the teamMatchesApiUrl with the team id to get the recent matches data of the team
API Requests & Responses
teamsApiUrl
Returns a response containing the list of all IPL teams
{
"teams": [
{
"name": "Royal Challengers Bangalore",
"id": "RCB",
"team_image_url": "https://assets.ccbp.in/frontend/react-js/rcb-logo-img.png",
// use value of the key 'name' for alt as `${name}`
},
...
],
}
teamMatchesApiUrl
Returns a response containing details of all recent matches of a team
{
"team_banner_url": "https://assets.ccbp.in/frontend/react-js/kkr-team-img.png",
"latest_match_details": {
"umpires": "CB Gaffaney, VK Sharma",
"result": "Kolkata Knight Riders Won by 7 wickets",
"man_of_the_match": "Shubman Gill",
"id": "1216545",
"date": "2020-09-26",
"venue": "At Sheikh Zayed Stadium, Abu Dhabi",
"competing_team": "Sunrisers Hyderabad",
"competing_team_logo": "https://upload.wikimedia.org/wikipedia/en/thumb/8/81/Sunrisers_Hyderabad.svg/1200px-Sunrisers_Hyderabad.svg.png",
// use value of the key 'competing_team' for alt as `latest match ${competing_team}`
"first_innings": "Sunrisers Hyderabad",
"second_innings": "Kolkata Knight Riders",
"match_status": "Won",
},
"recent_matches": [
{
"umpires": "RK Illingworth, K Srinivasan",
"result": "Royal Challengers Bangalore Won by 82 runs",
"man_of_the_match": "AB de Villiers",
"id": "1216540",
"date": "2020-10-12",
"venue": "At Sharjah Cricket Stadium, Sharjah",
"competing_team": "Royal Challengers Bangalore",
"competing_team_logo": "https://upload.wikimedia.org/wikipedia/en/thumb/2/2a/Royal_Challengers_Bangalore_2020.svg/1200px-Royal_Challengers_Bangalore_2020.svg.png",
// use value of the key 'competing_team' for alt as `competing team ${competing_team}`
"first_innings": "Royal Challengers Bangalore",
"second_innings": "Kolkata Knight Riders",
"match_status": "Lost",
},
...
],
}
Implementation Files
Use these files to complete the implementation:
src/App.js
src/components/Home/index.js
src/components/Home/index.css
src/components/TeamCard/index.js
src/components/TeamCard/index.css
src/components/TeamMatches/index.js
src/components/TeamMatches/index.css
src/components/LatestMatch/index.js
src/components/LatestMatch/index.css
src/components/MatchCard/index.js
src/components/MatchCard/index.css
Click to view
-
To display the animated loader, we need to import the Loader component using the below statement
import Loader from 'react-loader-spinner'
-
In order to display the given animated loader, pass the
type
andcolor
props to theLoader
component with values as Oval and #ffffff , respectively<Loader type="Oval" color="#ffffff" height={50} width={50} />
Click to view
The following instructions are required for the tests to pass
- The banner image in the Team Matches Route should have the alt attribute value as
team banner
- The alt attribute values for the images received from the response are given in the Example response
- The API responses received from the given api URLs should be converted to camel case
- Wrap the
Loader
component with an HTML container element and add thetestid
attribute value asloader
to it as shown below<div testid="loader"> <Loader type="Oval" color="#ffffff" height={50} width={50} /> </div>
- Render HomeRoute component when path in URL matches
/
- Render TeamMatchesRoute component when path in URL matches
/team-matches/:id
- No need to use the
BrowserRouter
inApp.js
as we have already included inindex.js
file - Each TeamMatchesRoute should have different gradient colors as background based on the selected team
Image URLs
Colors
Background Colors:
Border Colors
Text Colors
Font-families
- Bree Serif
- All components you implement should go in the
src/components
directory.- Don't change the component folder names as those are the files being imported into the tests.
- Do not remove the pre-filled code
- Want to quickly review some of the concepts you’ve been learning? Take a look at the Cheat Sheets.