first commit
Deploy Docker Compose / deploy (push) Failing after 51s
Details
Deploy Docker Compose / deploy (push) Failing after 51s
Details
This commit is contained in:
parent
65d27b99f3
commit
c56c214098
|
|
@ -0,0 +1,35 @@
|
|||
name: Deploy Docker Compose
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest # Use the Ubuntu runner
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2 # Checkout your repository code
|
||||
|
||||
- name: Install Docker
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker.io # Install Docker
|
||||
sudo usermod -aG docker $USER # Add the current user to the docker group (optional)
|
||||
docker --version # Verify Docker installation
|
||||
|
||||
- name: Install Docker Compose
|
||||
run: |
|
||||
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r .tag_name)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
docker-compose --version # Verify Docker Compose installation
|
||||
|
||||
- name: Deploy using Docker Compose
|
||||
env: # Inject secrets into environment variables
|
||||
LOL_APIKEY: ${{ secrets.RIOT_APIKEY }}
|
||||
run: |
|
||||
docker-compose build --build-arg RIOT_APIKEY =${RIOT_APIKEY }
|
||||
docker-compose -f docker-compose.yaml up -d # Start the containers in detached mode
|
||||
docker-compose logs # Display logs from the containers to show output
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# Use an official Node.js runtime as a parent image
|
||||
FROM node:18
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install pnpm
|
||||
RUN npm install -g pnpm
|
||||
|
||||
# Copy package.json and pnpm-lock.yaml
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
|
||||
# Accept build arguments
|
||||
ARG RIOT_APIKEY
|
||||
|
||||
# Set environment variables
|
||||
ENV RIOT_APIKEY=$RIOT_APIKEY
|
||||
|
||||
# Install dependencies using pnpm
|
||||
RUN pnpm install
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
|
||||
# Build the application (if needed)
|
||||
RUN pnpm build
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 4173
|
||||
|
||||
# Command to run the application
|
||||
CMD ["pnpm", "dev"]
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
sveltekit-app:
|
||||
container_name: trackerdeq
|
||||
environment:
|
||||
- RIOT_APIKEY=${RIOT_APIKEY}
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
RIOT_APIKEY: ${RIOT_APIKEY}
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "3334:4173"
|
||||
restart: always
|
||||
|
|
@ -1 +0,0 @@
|
|||
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
|
||||
|
Before Width: | Height: | Size: 391 B |
|
|
@ -1 +0,0 @@
|
|||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|
||||
|
Before Width: | Height: | Size: 1.0 KiB |
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB |
|
|
@ -0,0 +1 @@
|
|||
b89cde11-6ba8-4f6a-b0ae-5b8bfff359df
|
||||
|
|
@ -1 +0,0 @@
|
|||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
|
||||
|
Before Width: | Height: | Size: 128 B |
|
|
@ -1 +0,0 @@
|
|||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
|
||||
|
Before Width: | Height: | Size: 385 B |
|
|
@ -0,0 +1,19 @@
|
|||
import { getLobbyData } from "@/app/lib/utils";
|
||||
import { NextRequest } from "next/server";
|
||||
|
||||
export async function GET (
|
||||
req: NextRequest,
|
||||
context: { params: { player: string } }
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
const { player } = await context.params;
|
||||
const data = await getLobbyData( player );
|
||||
return Response.json( data );
|
||||
} catch ( err: any )
|
||||
{
|
||||
console.error( "API error:", err );
|
||||
return new Response( "Failed to fetch lobby data", { status: 500 } );
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import { getRankedData } from "@/app/lib/utils";
|
||||
import { NextRequest } from "next/server";
|
||||
|
||||
export async function GET (
|
||||
req: NextRequest,
|
||||
context: { params: { name: string; tag: string } }
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
const { name, tag } = await context.params;
|
||||
const data = await getRankedData( name, tag );
|
||||
return Response.json( data );
|
||||
} catch ( err: any )
|
||||
{
|
||||
console.error( "API error:", err );
|
||||
return new Response( "Failed to fetch ranked data", { status: 500 } );
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import { getSessionData } from "@/app/lib/utils";
|
||||
import { NextRequest } from "next/server";
|
||||
|
||||
export async function GET (
|
||||
req: NextRequest,
|
||||
context: { params: { name: string; tag: string } }
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
const { name, tag } = await context.params;
|
||||
const data = await getSessionData( name, tag );
|
||||
return Response.json( data );
|
||||
} catch ( err: any )
|
||||
{
|
||||
console.error( "API error:", err );
|
||||
return new Response( "Failed to fetch session data", { status: 500 } );
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
interface Player
|
||||
{
|
||||
name: string;
|
||||
position: string;
|
||||
team: string | null;
|
||||
tag: string | null;
|
||||
country: string | null;
|
||||
logo: string | null;
|
||||
championId: number;
|
||||
teamId: number;
|
||||
wr: number;
|
||||
championImage: string;
|
||||
countryFlag: string;
|
||||
positionIcon: string;
|
||||
}
|
||||
|
||||
interface LobbyData
|
||||
{
|
||||
inGame: boolean;
|
||||
gameId?: number;
|
||||
players?: Player[];
|
||||
}
|
||||
|
||||
export default function Lobby ( { player }: { player: string } )
|
||||
{
|
||||
const [ data, setData ] = useState<LobbyData | null>( null );
|
||||
const [ lastGameId, setLastGameId ] = useState<number | null>( null );
|
||||
const [ showAnimation, setShowAnimation ] = useState( false );
|
||||
|
||||
useEffect( () =>
|
||||
{
|
||||
const fetchLobby = async () =>
|
||||
{
|
||||
const res = await fetch( `/api/lobby/${ player }` );
|
||||
if ( !res.ok ) return;
|
||||
const json = await res.json();
|
||||
setData( json );
|
||||
|
||||
if ( json.inGame && json.gameId !== lastGameId )
|
||||
{
|
||||
setShowAnimation( true );
|
||||
setLastGameId( json.gameId );
|
||||
}
|
||||
};
|
||||
|
||||
fetchLobby();
|
||||
const interval = setInterval( fetchLobby, 45 * 1000 );
|
||||
return () => clearInterval( interval );
|
||||
}, [ player, lastGameId ] );
|
||||
|
||||
if ( !data || !data.inGame || !data.players ) return null;
|
||||
|
||||
const overlayClass = `overlay slide-animation max-h-screen grid grid-rows-2 items-center font-sans font-bold tracking-wide ${ showAnimation ? "" : "hidden"
|
||||
}`;
|
||||
|
||||
return (
|
||||
<div className={ overlayClass } onAnimationEnd={ () => setShowAnimation( false ) }>
|
||||
{ [ 200, 100 ].map( ( teamId ) => (
|
||||
<div className="team w-max" key={ teamId }>
|
||||
{ data.players
|
||||
.filter( ( p ) => p.teamId === teamId )
|
||||
.map( ( player, i ) =>
|
||||
{
|
||||
const playerClass =
|
||||
"player flex flex-row justify-between items-center my-2 min-w-56 w-full max-w-[400px] bg-opacity-50 rounded-xl shadow-md " +
|
||||
( teamId === 100 ? "bg-sky-800" : "bg-red-800" );
|
||||
|
||||
return (
|
||||
<div key={ i } className={ playerClass }>
|
||||
<div
|
||||
className="champion w-11 h-11 scale-125 bg-center bg-no-repeat bg-[length:120%] rounded-br-xl rounded-tr-xl"
|
||||
style={ {
|
||||
backgroundImage: `url(${ player.championImage })`,
|
||||
} }
|
||||
></div>
|
||||
|
||||
<div className="grid grid-rows-2 flex-grow mx-4 min-w-0">
|
||||
<div className="name font-semibold text-white text-sm text-shadow-xl truncate">
|
||||
{ player.tag ? `${ player.tag } ${ player.name }` : player.name }
|
||||
</div>
|
||||
|
||||
<div className="flex flex-row gap-1">
|
||||
<div
|
||||
className="country w-8 h-6 scale-75 bg-center bg-contain bg-no-repeat"
|
||||
style={ {
|
||||
backgroundImage: `url(${ player.countryFlag })`,
|
||||
} }
|
||||
></div>
|
||||
<div
|
||||
className="position w-6 h-6 scale-105 bg-center bg-contain bg-no-repeat"
|
||||
style={ {
|
||||
backgroundImage: `url(${ player.positionIcon })`,
|
||||
} }
|
||||
></div>
|
||||
<div className="wr font-bold text-white text-xs text-shadow-xl ml-1 pt-1">
|
||||
{ player.wr }%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{ player.logo && (
|
||||
<div
|
||||
className="logo w-10 h-10 scale-90 mr-1 -ml-1 my-1 bg-center bg-contain bg-no-repeat rounded-lg"
|
||||
style={ { backgroundImage: `url(${ player.logo })` } }
|
||||
></div>
|
||||
) }
|
||||
</div>
|
||||
);
|
||||
} ) }
|
||||
</div>
|
||||
) ) }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
interface Match
|
||||
{
|
||||
matchId: string;
|
||||
championImg: string;
|
||||
win: boolean;
|
||||
kills: number;
|
||||
deaths: number;
|
||||
assists: number;
|
||||
isOld?: boolean;
|
||||
}
|
||||
|
||||
interface SummonerData
|
||||
{
|
||||
tier: string;
|
||||
division?: string;
|
||||
lp: number;
|
||||
wins: number;
|
||||
losses: number;
|
||||
winrate: number;
|
||||
matches: Match[];
|
||||
}
|
||||
|
||||
export default function Ranked ( { name, tag }: { name: string; tag: string } )
|
||||
{
|
||||
const [ data, setData ] = useState<SummonerData | null>( null );
|
||||
|
||||
useEffect( () =>
|
||||
{
|
||||
const fetchData = async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
const res = await fetch( `/api/ranked/${ name }/${ tag }` );
|
||||
if ( !res.ok ) throw new Error( "API error" );
|
||||
const json = await res.json();
|
||||
setData( json );
|
||||
} catch ( err )
|
||||
{
|
||||
console.error( "Failed to fetch ranked data:", err );
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
const interval = setInterval( fetchData, 2 * 60 * 1000 );
|
||||
|
||||
return () => clearInterval( interval );
|
||||
}, [ name, tag ] );
|
||||
|
||||
if ( !data ) return null;
|
||||
|
||||
return (
|
||||
<div className="font-sans">
|
||||
<div className="text flex flex-row font-bold tracking-wide">
|
||||
<div className="elo basis-2/3 pr-4 mb-3 text-white">
|
||||
{ [ "MASTER", "GRANDMASTER", "CHALLENGER" ].includes( data.tier ) ? (
|
||||
<div className="league basis-1/2 text-4xl text-shadow-xl">
|
||||
{ data.tier } { data.lp } LP
|
||||
</div>
|
||||
) : (
|
||||
<div className="points basis-1/2 text-3xl text-shadow-xl">
|
||||
{ data.tier } { data.division } { data.lp } LP
|
||||
</div>
|
||||
) }
|
||||
</div>
|
||||
|
||||
<div className="stats basis-1/3 flex flex-row justify-end text-3xl tracking-tighter">
|
||||
<div className="wins px-2 text-sky-600 text-shadow-xl">{ data.wins }W</div>
|
||||
<div className="losses px-2 text-red-600 text-shadow-xl">{ data.losses }L</div>
|
||||
<div className="winrate pl-3 text-white text-shadow-xl">
|
||||
{ data.winrate }%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="games flex flex-row">
|
||||
{ data.matches.map( ( match, index ) => (
|
||||
<div
|
||||
key={ match.matchId || index }
|
||||
className={ `game basis-1/6 px-1.5 ${ match.isOld ? "old" : "" }` }
|
||||
>
|
||||
<div
|
||||
className={ `background ring-4 rounded-full ${ match.win ? "win ring-sky-600" : "loss ring-red-600"
|
||||
}` }
|
||||
>
|
||||
<div
|
||||
className={ `champion bg-center aspect-square scale-90 rounded-full drop-shadow-lg bg-no-repeat bg-[length:110%] ${ match.win ? "" : "lose"
|
||||
}` }
|
||||
style={ { backgroundImage: `url('${ match.championImg }')` } }
|
||||
/>
|
||||
</div>
|
||||
<div className="kda text-center text-xl font-semilight text-gray-200 tracking-tight text-shadow-xl">
|
||||
{ match.kills }/{ match.deaths }/{ match.assists }
|
||||
</div>
|
||||
</div>
|
||||
) ) }
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
interface SessionData
|
||||
{
|
||||
profileIcon: string;
|
||||
rankedIcon?: string;
|
||||
kills: string;
|
||||
deaths: string;
|
||||
assists: string;
|
||||
wins: number;
|
||||
losses: number;
|
||||
lpGain?: number;
|
||||
}
|
||||
|
||||
export default function Session ( { name, tag }: { name: string; tag: string } )
|
||||
{
|
||||
const [ data, setData ] = useState<SessionData | null>( null );
|
||||
|
||||
useEffect( () =>
|
||||
{
|
||||
const fetchData = async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
const res = await fetch( `/api/session/${ name }/${ tag }` );
|
||||
if ( !res.ok ) throw new Error( "API error" );
|
||||
const json = await res.json();
|
||||
setData( json );
|
||||
} catch ( err )
|
||||
{
|
||||
console.error( "Failed to fetch session data:", err );
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
const interval = setInterval( fetchData, 2 * 60 * 1000 );
|
||||
return () => clearInterval( interval );
|
||||
}, [ name, tag ] );
|
||||
|
||||
if ( !data ) return null;
|
||||
|
||||
return (
|
||||
<div className="font-sans font-bold tracking-wide">
|
||||
<div className="profile scale-50 mx-[17rem] -mb-12 relative">
|
||||
<div className="profile-picture w-64 h-64 floating-box relative">
|
||||
<img
|
||||
className="absolute inset-0 w-full h-full object-cover rounded-full scale-75 mt-16"
|
||||
src={ data.profileIcon }
|
||||
alt="Summoner Icon"
|
||||
/>
|
||||
{ data.rankedIcon && (
|
||||
<img
|
||||
className="absolute inset-0 w-full h-full object-cover scale-200"
|
||||
src={ data.rankedIcon }
|
||||
alt="Ranked Icon"
|
||||
/>
|
||||
) }
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="session mt-5">
|
||||
<div className="kda text-center px-2">
|
||||
<span className="text-3xl text-white text-shadow-xl">
|
||||
{ data.kills }
|
||||
</span>
|
||||
<span className="text-2xl text-gray-300 text-shadow-xl">/</span>
|
||||
<span className="text-3xl text-red-600 text-shadow-xl">
|
||||
{ data.deaths }
|
||||
</span>
|
||||
<span className="text-2xl text-gray-300 text-shadow-xl">/</span>
|
||||
<span className="text-3xl text-white text-shadow-xl">
|
||||
{ data.assists }
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="relative h-10 overflow-hidden mt-2">
|
||||
<div className={ `absolute top-0 w-full ${ data.lpGain !== 0 ? "slide-box" : ""
|
||||
}` }>
|
||||
<div className="wl flex flex-row justify-center">
|
||||
<div className="wins text-3xl text-center text-sky-600 px-1 text-shadow-xl">
|
||||
{ data.wins }W
|
||||
</div>
|
||||
<div className="losses text-3xl text-center text-red-600 px-1 text-shadow-xl">
|
||||
{ data.losses }L
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{ typeof data.lpGain === "number" && data.lpGain !== 0 && (
|
||||
<div
|
||||
className={ `lp text-3xl text-center px-1 text-shadow-xl ${ data.lpGain > 0
|
||||
? "text-sky-600"
|
||||
: data.lpGain < 0
|
||||
? "text-red-600"
|
||||
: "text-white"
|
||||
}` }
|
||||
>
|
||||
{ data.lpGain > 0 ? `+${ data.lpGain }` : data.lpGain }LP
|
||||
</div>
|
||||
) }
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,26 +1,114 @@
|
|||
@import "tailwindcss";
|
||||
|
||||
:root {
|
||||
--background: #ffffff;
|
||||
--foreground: #171717;
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--font-sans: var(--font-geist-sans);
|
||||
--font-mono: var(--font-geist-mono);
|
||||
--background: #ffffff;
|
||||
--foreground: #171717;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--background: #0a0a0a;
|
||||
--foreground: #ededed;
|
||||
}
|
||||
:root {
|
||||
--background: #0a0a0a;
|
||||
--foreground: #ededed;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
@keyframes slideInOut {
|
||||
0% {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
|
||||
5% {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
95% {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
}
|
||||
|
||||
.slide-animation {
|
||||
animation: slideInOut 30s ease-in-out forwards;
|
||||
}
|
||||
|
||||
.game:nth-child(1) {
|
||||
opacity: 1.00;
|
||||
}
|
||||
|
||||
.game:nth-child(2) {
|
||||
opacity: 0.95;
|
||||
}
|
||||
|
||||
.game:nth-child(3) {
|
||||
opacity: 0.90;
|
||||
}
|
||||
|
||||
.game:nth-child(4) {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.game:nth-child(5) {
|
||||
opacity: 0.80;
|
||||
}
|
||||
|
||||
.game:nth-child(6) {
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
.lose {
|
||||
filter: grayscale(0.25);
|
||||
}
|
||||
|
||||
.game.old>.background {
|
||||
filter: grayscale(0.75);
|
||||
}
|
||||
|
||||
.game.old>.background>.champion {
|
||||
filter: blur(1px) grayscale(0.85);
|
||||
}
|
||||
|
||||
.floating-box {
|
||||
animation: float 5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(-0.5rem);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateY(-1.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slide {
|
||||
|
||||
0%,
|
||||
40% {
|
||||
transform: translateY(0%);
|
||||
}
|
||||
|
||||
50%,
|
||||
90% {
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(0%);
|
||||
}
|
||||
}
|
||||
|
||||
.slide-box {
|
||||
animation: slide 15s ease-in-out infinite;
|
||||
}
|
||||
|
|
@ -1,34 +1,22 @@
|
|||
import type { Metadata } from "next";
|
||||
import { Geist, Geist_Mono } from "next/font/google";
|
||||
import "./globals.css";
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
const geistMono = Geist_Mono({
|
||||
variable: "--font-geist-mono",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Create Next App",
|
||||
description: "Generated by create next app",
|
||||
title: "trackerdeq"
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
export default function RootLayout ( {
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||
>
|
||||
{children}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
children: React.ReactNode;
|
||||
}> )
|
||||
{
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className="dark">
|
||||
{ children }
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,272 @@
|
|||
import { cookies } from "next/headers";
|
||||
|
||||
const RIOT_TOKEN = process.env.RIOT_APIKEY!;
|
||||
const REGION = "EUW1";
|
||||
const REGION_GROUP = "EUROPE";
|
||||
const TWELVE_HOURS_IN_MS = 12 * 60 * 60 * 1000;
|
||||
|
||||
const headers = { "X-Riot-Token": RIOT_TOKEN };
|
||||
|
||||
|
||||
export function getChampionSquare ( championId: number )
|
||||
{
|
||||
return `https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-icons/${ championId }.png`;
|
||||
}
|
||||
|
||||
export function getSummonerIcon ( profileIconId: number )
|
||||
{
|
||||
return `https://raw.communitydragon.org/latest/game/assets/ux/summonericons/profileicon${ profileIconId }.png`;
|
||||
}
|
||||
|
||||
export function getPositionIcon ( position: string )
|
||||
{
|
||||
switch ( position )
|
||||
{
|
||||
case "10_top":
|
||||
return "https://raw.communitydragon.org/latest/plugins/rcp-fe-lol-clash/global/default/assets/images/position-selector/positions/icon-position-top.png";
|
||||
case "20_jungle":
|
||||
return "https://raw.communitydragon.org/latest/plugins/rcp-fe-lol-clash/global/default/assets/images/position-selector/positions/icon-position-jungle.png";
|
||||
case "30_mid":
|
||||
return "https://raw.communitydragon.org/latest/plugins/rcp-fe-lol-clash/global/default/assets/images/position-selector/positions/icon-position-middle.png";
|
||||
case "40_adc":
|
||||
return "https://raw.communitydragon.org/latest/plugins/rcp-fe-lol-clash/global/default/assets/images/position-selector/positions/icon-position-bottom.png";
|
||||
case "50_support":
|
||||
return "https://raw.communitydragon.org/latest/plugins/rcp-fe-lol-clash/global/default/assets/images/position-selector/positions/icon-position-utility.png";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
export function getRankedIcon ( rankedTier: string )
|
||||
{
|
||||
return `https://raw.communitydragon.org/latest/plugins/rcp-fe-lol-static-assets/global/default/ranked-emblem/wings/wings_${ rankedTier.toLowerCase() }.png`;
|
||||
}
|
||||
|
||||
export function getCountryFlag ( countryCode: string )
|
||||
{
|
||||
return `https://flagcdn.com/160x120/${ countryCode.toLowerCase() }.png`;
|
||||
}
|
||||
|
||||
export function calculateWinrate ( wins: number, losses: number ): number
|
||||
{
|
||||
const total = wins + losses;
|
||||
return total === 0 ? 0 : Math.round( ( wins / total ) * 100 );
|
||||
}
|
||||
|
||||
export function isOlderThanHoursAgo ( timestamp: number, hours: number ): boolean
|
||||
{
|
||||
const currentTimestamp = Date.now();
|
||||
const hoursInMs = hours * 60 * 60 * 1000;
|
||||
return timestamp < currentTimestamp - hoursInMs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function fetchAccount ( name: string, tag: string )
|
||||
{
|
||||
const res = await fetch(
|
||||
`https://${ REGION_GROUP }.api.riotgames.com/riot/account/v1/accounts/by-riot-id/${ name }/${ tag }`,
|
||||
{ headers }
|
||||
);
|
||||
if ( !res.ok ) throw new Error( "Account fetch failed" );
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function fetchSummoner ( puuid: string )
|
||||
{
|
||||
const res = await fetch(
|
||||
`https://${ REGION }.api.riotgames.com/lol/summoner/v4/summoners/by-puuid/${ puuid }`,
|
||||
{ headers }
|
||||
);
|
||||
if ( !res.ok ) throw new Error( "Summoner fetch failed" );
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function fetchRankedStats ( summonerId: string )
|
||||
{
|
||||
const res = await fetch(
|
||||
`https://${ REGION }.api.riotgames.com/lol/league/v4/entries/by-summoner/${ summonerId }`,
|
||||
{ headers }
|
||||
);
|
||||
if ( !res.ok ) return {};
|
||||
const leagues = await res.json();
|
||||
const soloQ = leagues.find( ( e: any ) => e.queueType === "RANKED_SOLO_5x5" );
|
||||
if ( !soloQ ) return {};
|
||||
return {
|
||||
tier: soloQ.tier,
|
||||
division: soloQ.rank,
|
||||
lp: soloQ.leaguePoints,
|
||||
wins: soloQ.wins,
|
||||
losses: soloQ.losses,
|
||||
winrate: calculateWinrate( soloQ.wins, soloQ.losses ),
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchMatches ( puuid: string )
|
||||
{
|
||||
const idsRes = await fetch(
|
||||
`https://${ REGION_GROUP }.api.riotgames.com/lol/match/v5/matches/by-puuid/${ puuid }/ids?queue=420&count=6`,
|
||||
{ headers }
|
||||
);
|
||||
if ( !idsRes.ok ) throw new Error( "Match list fetch failed" );
|
||||
|
||||
const matchIds = await idsRes.json();
|
||||
|
||||
const matches = await Promise.all(
|
||||
matchIds.map( async ( matchId: string ) =>
|
||||
{
|
||||
const res = await fetch(
|
||||
`https://${ REGION_GROUP }.api.riotgames.com/lol/match/v5/matches/${ matchId }`,
|
||||
{ headers }
|
||||
);
|
||||
const match = await res.json();
|
||||
const participant = match.info.participants.find( ( p: any ) => p.puuid === puuid );
|
||||
return {
|
||||
matchId,
|
||||
kills: participant.kills,
|
||||
deaths: participant.deaths,
|
||||
assists: participant.assists,
|
||||
championImg: getChampionSquare( participant.championId ),
|
||||
win: participant.win,
|
||||
isOld: isOlderThanHoursAgo( match.info.gameCreation, 12 ),
|
||||
};
|
||||
} )
|
||||
);
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
export async function getRankedData ( name: string, tag: string )
|
||||
{
|
||||
const account = await fetchAccount( name, tag );
|
||||
const summoner = await fetchSummoner( account.puuid );
|
||||
const [ matches, rankedStats ] = await Promise.all( [
|
||||
fetchMatches( account.puuid ),
|
||||
fetchRankedStats( summoner.id ),
|
||||
] );
|
||||
|
||||
return { ...rankedStats, matches };
|
||||
}
|
||||
|
||||
export async function getSessionData ( name: string, tag: string )
|
||||
{
|
||||
const cookieStore = cookies();
|
||||
const sessionCookie = ( await cookieStore ).get( "lpSession" );
|
||||
|
||||
const account = await fetchAccount( name, tag );
|
||||
const summoner = await fetchSummoner( account.puuid );
|
||||
const [ matches, rankedStats ] = await Promise.all( [
|
||||
fetchMatches( account.puuid ),
|
||||
fetchRankedStats( summoner.id ),
|
||||
] );
|
||||
|
||||
let totalKills = 0;
|
||||
let totalDeaths = 0;
|
||||
let totalAssists = 0;
|
||||
let wins = 0;
|
||||
let losses = 0;
|
||||
|
||||
for ( const match of matches )
|
||||
{
|
||||
totalKills += match.kills;
|
||||
totalDeaths += match.deaths;
|
||||
totalAssists += match.assists;
|
||||
match.win ? wins++ : losses++;
|
||||
}
|
||||
|
||||
const matchCount = matches.length || 1;
|
||||
const avgKills = ( totalKills / matchCount ).toFixed( 1 );
|
||||
const avgDeaths = ( totalDeaths / matchCount ).toFixed( 1 );
|
||||
const avgAssists = ( totalAssists / matchCount ).toFixed( 1 );
|
||||
|
||||
let lpGain = 0;
|
||||
let currentLP = rankedStats.lp || 0;
|
||||
let initialLP = currentLP;
|
||||
const now = Date.now();
|
||||
|
||||
if ( sessionCookie )
|
||||
{
|
||||
try
|
||||
{
|
||||
const sessionData = JSON.parse( sessionCookie.value );
|
||||
const sessionTime = sessionData.timestamp;
|
||||
|
||||
if ( now - sessionTime < TWELVE_HOURS_IN_MS )
|
||||
{
|
||||
initialLP = sessionData.initialLP;
|
||||
lpGain = currentLP - initialLP;
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
if ( !sessionCookie || lpGain === 0 )
|
||||
{
|
||||
( await cookieStore ).set(
|
||||
"lpSession",
|
||||
JSON.stringify( { initialLP: currentLP, timestamp: now } ),
|
||||
{
|
||||
path: "/",
|
||||
maxAge: TWELVE_HOURS_IN_MS / 1000,
|
||||
httpOnly: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
profileIcon: getSummonerIcon( summoner.profileIconId ),
|
||||
rankedIcon: getRankedIcon( rankedStats.tier ),
|
||||
kills: avgKills,
|
||||
deaths: avgDeaths,
|
||||
assists: avgAssists,
|
||||
wins,
|
||||
losses,
|
||||
lpGain,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getLobbyData ( player: string )
|
||||
{
|
||||
const searchRes = await fetch( `https://api.lolpros.gg/es/profiles/${ player }` );
|
||||
if ( !searchRes.ok ) throw new Error( "Profile search failed" );
|
||||
|
||||
const profile = await searchRes.json();
|
||||
if ( !profile?.uuid ) throw new Error( "Player not found" );
|
||||
|
||||
const gameRes = await fetch( `https://api.lolpros.gg/lol/game/${ profile.uuid }` );
|
||||
if ( gameRes.status === 204 ) return { inGame: false };
|
||||
|
||||
if ( !gameRes.ok ) throw new Error( "Game data fetch failed" );
|
||||
const gameData = await gameRes.json();
|
||||
|
||||
const players = gameData.participants
|
||||
.filter( ( p: any ) => p.lolpros )
|
||||
.map( ( p: any ) =>
|
||||
{
|
||||
const name = p.lolpros?.name || "Unknown";
|
||||
const position = p.lolpros?.position || "Unknown";
|
||||
const country = p.lolpros?.country || null;
|
||||
|
||||
return {
|
||||
name,
|
||||
position,
|
||||
team: p.lolpros?.team?.name || null,
|
||||
tag: p.lolpros?.team?.tag || null,
|
||||
country,
|
||||
logo: p.lolpros?.team?.logo?.url || null,
|
||||
championId: p.championId,
|
||||
teamId: p.teamId,
|
||||
wr: calculateWinrate( p.ranking.wins, p.ranking.losses ),
|
||||
championImage: getChampionSquare( p.championId ),
|
||||
countryFlag: getCountryFlag( country ),
|
||||
positionIcon: getPositionIcon( position ),
|
||||
};
|
||||
} )
|
||||
.sort( ( a: any, b: any ) => a.position.localeCompare( b.position ) );
|
||||
|
||||
return {
|
||||
inGame: true,
|
||||
gameId: gameData.gameId,
|
||||
players,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import Lobby from "@/app/components/Lobby";
|
||||
|
||||
export default async function Page ( {
|
||||
params,
|
||||
}: {
|
||||
params: { player: string };
|
||||
} )
|
||||
{
|
||||
const { player } = await params;
|
||||
|
||||
return <Lobby player={ player } />;
|
||||
}
|
||||
116
src/app/page.tsx
116
src/app/page.tsx
|
|
@ -1,103 +1,17 @@
|
|||
import Image from "next/image";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
|
||||
<main className="flex flex-col gap-[32px] row-start-2 items-center sm:items-start">
|
||||
<Image
|
||||
className="dark:invert"
|
||||
src="/next.svg"
|
||||
alt="Next.js logo"
|
||||
width={180}
|
||||
height={38}
|
||||
priority
|
||||
/>
|
||||
<ol className="list-inside list-decimal text-sm/6 text-center sm:text-left font-[family-name:var(--font-geist-mono)]">
|
||||
<li className="mb-2 tracking-[-.01em]">
|
||||
Get started by editing{" "}
|
||||
<code className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-[family-name:var(--font-geist-mono)] font-semibold">
|
||||
src/app/page.tsx
|
||||
</code>
|
||||
.
|
||||
</li>
|
||||
<li className="tracking-[-.01em]">
|
||||
Save and see your changes instantly.
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<div className="flex gap-4 items-center flex-col sm:flex-row">
|
||||
<a
|
||||
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] font-medium text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:w-auto"
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
className="dark:invert"
|
||||
src="/vercel.svg"
|
||||
alt="Vercel logomark"
|
||||
width={20}
|
||||
height={20}
|
||||
/>
|
||||
Deploy now
|
||||
</a>
|
||||
<a
|
||||
className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent font-medium text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 w-full sm:w-auto md:w-[158px]"
|
||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Read our docs
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
<footer className="row-start-3 flex gap-[24px] flex-wrap items-center justify-center">
|
||||
<a
|
||||
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
|
||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
aria-hidden
|
||||
src="/file.svg"
|
||||
alt="File icon"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Learn
|
||||
</a>
|
||||
<a
|
||||
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
|
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
aria-hidden
|
||||
src="/window.svg"
|
||||
alt="Window icon"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Examples
|
||||
</a>
|
||||
<a
|
||||
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
|
||||
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
aria-hidden
|
||||
src="/globe.svg"
|
||||
alt="Globe icon"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Go to nextjs.org →
|
||||
</a>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
export default function Page ()
|
||||
{
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<a href="/ranked/sly%20wakz/euw">ranked</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="/session/sly%20wakz/euw">session</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="/lobby/wakz">lobby</a>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
import Ranked from "@/app/components/Ranked";
|
||||
|
||||
export default async function Page ( {
|
||||
params,
|
||||
}: {
|
||||
params: { name: string; tag: string };
|
||||
} )
|
||||
{
|
||||
const { name, tag } = await params;
|
||||
|
||||
return <Ranked name={ name } tag={ tag } />;
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import Session from "@/app/components/Session";
|
||||
|
||||
export default async function Page ( {
|
||||
params,
|
||||
}: {
|
||||
params: { name: string; tag: string };
|
||||
} )
|
||||
{
|
||||
const { name, tag } = await params;
|
||||
|
||||
return <Session name={ name } tag={ tag } />;
|
||||
}
|
||||
Loading…
Reference in New Issue