Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #74

Merged
merged 36 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
216a663
Fix to sliders not changing on reset
AkinariHex Jan 19, 2024
f490f95
Fix to tiers filter
AkinariHex Jan 19, 2024
d84c23b
Filters major bug fixes
AkinariHex Jan 19, 2024
92c5a16
Removed profile image from Dashboard
AkinariHex Jan 19, 2024
9d76efb
Merge pull request #58 from AkinariHex/nextjs
AkinariHex Jan 19, 2024
dea4ac4
Custom tooltip for Dashboard graph
AkinariHex Jan 22, 2024
2a58ab0
Adjusted graph tooltip
AkinariHex Jan 22, 2024
eafeb55
Redirect to homepage when not logged
AkinariHex Jan 22, 2024
af19a92
Show provisional rank indicator
AkinariHex Jan 23, 2024
58b4d0f
Provisional badge reword
AkinariHex Jan 23, 2024
62dc9c7
Merge pull request #60 from AkinariHex/nextjs
AkinariHex Jan 23, 2024
71a1017
Add color to range selection
AkinariHex Jan 24, 2024
cc5182a
Fix bar chart scale
AkinariHex Jan 24, 2024
0721143
Remove graph if not enough tournaments
AkinariHex Jan 24, 2024
2f3e6b3
Graph scales change
AkinariHex Jan 24, 2024
5ab3fd1
Teammates and opponents graph addition
AkinariHex Jan 24, 2024
7a320fa
Merge pull request #61 from AkinariHex/nextjs
AkinariHex Jan 24, 2024
3cae35e
Graphs stepSize adjustment
AkinariHex Jan 24, 2024
94a35c6
Removed tournaments over time graph
AkinariHex Jan 24, 2024
7235329
Rating graph update
AkinariHex Jan 24, 2024
4f7d442
Merge pull request #62 from AkinariHex/nextjs
AkinariHex Jan 24, 2024
92f41db
Rating graph labels limit
AkinariHex Jan 25, 2024
0008db0
Inline chart percentage fix
AkinariHex Jan 25, 2024
69bd830
autoSkip Y axis labels
AkinariHex Jan 25, 2024
03bfd34
Merge pull request #63 from AkinariHex/nextjs
AkinariHex Jan 25, 2024
28dad10
User rating new design
AkinariHex Jan 31, 2024
ead0ed5
View other users page and new login context initialization
AkinariHex Jan 31, 2024
903795f
New login context
AkinariHex Jan 31, 2024
c864e25
Fix navbar for Mode cookie
AkinariHex Jan 31, 2024
9673cd5
Merge pull request #70 from AkinariHex/nextjs
AkinariHex Jan 31, 2024
0305ebe
Users page major fixes
AkinariHex Jan 31, 2024
5a9977f
Merge pull request #71 from AkinariHex/nextjs
AkinariHex Jan 31, 2024
6effa5b
Hide login button if user is logged
AkinariHex Jan 31, 2024
3886d0e
Fix unmatched rating value
AkinariHex Feb 1, 2024
d4a74aa
Merge pull request #72 from AkinariHex/nextjs
AkinariHex Feb 1, 2024
ec044c5
Merge pull request #73 from hburn7/develop
hburn7 Feb 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 81 additions & 4 deletions app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,29 @@ export async function getUserData() {
cookies().get('OTR-Access-Token')?.value
}`,
},
next: {
/* next: {
revalidate: 120,
tags: ['user-me'],
},
}, */
});

if (res.status !== 200) {
const errorMessage = await res.text();

return {
error: {
status: res.status,
text: res.statusText,
message: errorMessage,
},
};
}

res = await res.json();
if (res.status === 200) {
res = await res.json();

return res;
return res;
}

/* .then((response) => {
return response.json();
Expand All @@ -48,6 +53,32 @@ export async function getUserData() {
}); */
}

export async function checkUserLogin() {
let res = await fetch(`${process.env.REACT_APP_API_URL}/me/validate`, {
method: 'GET',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': `${process.env.REACT_APP_ORIGIN_URL}`,
Cookie: `${cookies().get('OTR-Access-Token')?.name}=${
cookies().get('OTR-Access-Token')?.value
}`,
},
});

if (!res?.ok) {
const errorCode = res?.status;

return {
error: {
errorCode,
},
};
}

return await getUserData();
}

export async function revalidateUserData() {
return revalidateTag('user-me');
}
Expand Down Expand Up @@ -411,6 +442,52 @@ export async function fetchDashboard() {
return data;
}

export async function fetchUserPageTitle(player: string | number) {
let res = await fetch(
`${process.env.REACT_APP_API_URL}/players/${player}/info`,
{
headers: {
'Content-Type': 'application/json',
},
}
);

if (res?.ok) {
res = await res.json();
return res;
}

return null;
}

export async function fetchUserPage(player: string | number) {
const isUserLogged = await checkUserLogin();

let res = await fetch(
`${process.env.REACT_APP_API_URL}/stats/${player}${
isUserLogged ? `?comparerId=${isUserLogged?.userId}` : ''
}`,
{
headers: {
'Content-Type': 'application/json',
},
}
);

if (!res?.ok) {
return redirect('/');
}

res = await res.json();

/* TEMPORARY BEHAVIOR */
if (res?.generalStats === null) {
return redirect('/');
}

return res;
}

export async function paginationParamsToURL(params: {}) {
let url = '';

Expand Down
6 changes: 6 additions & 0 deletions app/dashboard/page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,9 @@
.cardStat .value {
font-weight: 600;
}

.noGraphText {
font-style: italic;
font-weight: 400;
font-size: 0.9rem;
}
43 changes: 19 additions & 24 deletions app/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fetchDashboard } from '@/app/actions';
import AreaChart from '@/components/Charts/AreaChart/AreaChart';
import BarChart from '@/components/Charts/BarChart/BarChart';
import DoughnutChart from '@/components/Charts/DoughnutChart/DoughnutChart';
Expand All @@ -11,7 +12,6 @@ import UserMainCard from '@/components/Dashboard/UserMainCard/UserMainCard';
import FormattedNumber from '@/components/FormattedNumber/FormattedNumber';
import Notice from '@/components/Notice/Notice';
import clsx from 'clsx';
import { fetchDashboard } from '../actions';
import styles from './page.module.css';

import type { Metadata } from 'next';
Expand Down Expand Up @@ -67,7 +67,7 @@ export default async function page({
<div className={styles.graphContainer}>
<div className={styles.header}>
<div className={styles.rating}>
<span>{Math.floor(data.generalStats.rating)}</span>
<span>{Math.round(data.generalStats.rating)}</span>
<span
className={clsx(
styles.change,
Expand Down Expand Up @@ -191,44 +191,39 @@ export default async function page({
<GridCard title={'Average score per mod'}>
<RadarChart averageModScore={data?.modStats} />
</GridCard>
<GridCard title={'Most played with teammates - TO DO'}>
<PlayersBarChart />
<GridCard title={'Most played with teammates'}>
<PlayersBarChart players={data?.frequentTeammates} />
</GridCard>
<GridCard title={'Most played with opponents - TO DO'}>
<PlayersBarChart />
<GridCard title={'Most played with opponents'}>
<PlayersBarChart players={data?.frequentOpponents} />
</GridCard>
</StatsGrid>
<StatsGrid>
<GridCard title={'Tournaments over time - TO DO'}>
<div className={styles.chart}>
<AreaChart />
</div>
</GridCard>
<GridCard title={'Most common team size'}>
<GridCard title={'Most common format'}>
<BarChart
mainAxe={'x'}
teamSizes={data?.tournamentStats.teamSizeCounts}
/>
</GridCard>
<GridCard title={'Most common format - TO DO'}>
<BarChart mainAxe={'x'} />
</GridCard>
<GridCard title={'Summary of placements - TO DO'}>
<BarChart mainAxe={'x'} />
</GridCard>
<GridCard title={'Best tournament performances'}>
<BarChart
mainAxe={'y'}
bestTournamentPerformances={data?.tournamentStats.bestPerformances}
/>
</GridCard>
<GridCard title={'Worst tournament performances'}>
<BarChart
mainAxe={'y'}
worstTournamentPerformances={
data?.tournamentStats.worstPerformances
}
/>
{data?.tournamentStats.worstPerformances.length > 0 ? (
<BarChart
mainAxe={'y'}
worstTournamentPerformances={
data?.tournamentStats.worstPerformances
}
/>
) : (
<span className={styles.noGraphText}>
Play 6 or more tournaments to populate this graph!
</span>
)}
</GridCard>
</StatsGrid>
</main>
Expand Down
16 changes: 16 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@
--mods-FM-bg-row: 101, 38%, 63%, 0.15;
--mods-TB-bg: 191, 26%, 57%;
--mods-TB-bg-row: 191, 26%, 57%, 0.15;

--accent-color: 216, 100%, 65%;
--accent-secondary-color: var(--blue-300);

/* CHARTS */
--tooltip-color: 0, 0%, 100%;
--tooltip-gain: var(--green-400);
--tooltip-loss: var(--red-400);

/* BADGES */
--badge-provisional-background: var(--yellow-400);
--badge-provisional-foreground: var(--yellow-900);

/* USER RATING TIER */
--tier-bar-background: var(--gray-300);
--tier-bar-accent: var(--accent-color);
}

* {
Expand Down
9 changes: 6 additions & 3 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Footer from '@/components/Footer/Footer';
import NavBar from '@/components/NavBar/NavBar';
import UserProvider from '@/util/UserLoggedContext';
import type { Metadata } from 'next';
import { Viewport } from 'next';
import { Inter } from 'next/font/google';
Expand Down Expand Up @@ -31,9 +32,11 @@ export default function RootLayout({
return (
<html lang="en" className={inter.variable}>
<body>
<NavBar />
{children}
<Footer />
<UserProvider>
<NavBar />
{children}
<Footer />
</UserProvider>
</body>
</html>
);
Expand Down
9 changes: 0 additions & 9 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,9 @@ import decoration4 from '@/public/decorations/decoration-4.svg';
import fullLogo from '@/public/logos/full-logo.svg';
import Image from 'next/image';
import Balancer from 'react-wrap-balancer';
import { getUserData } from './actions';
import styles from './page.module.css';

export const revalidate = 60;

const getUser = async () => {
return await getUserData();
};

export default async function Home() {
const user = await getUser();

return (
<main className={styles.main}>
<div className={styles.row}>
Expand Down
114 changes: 114 additions & 0 deletions app/users/[id]/page.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
.main {
gap: var(--main-padding);
}

.notices {
display: flex;
flex-flow: column;
gap: 0.8rem;
}

.mainGraphContainer {
display: flex;
flex-flow: column;
gap: var(--internal-gap);
}

.graphContainer {
display: flex;
flex-flow: column;
background-color: hsla(var(--gray-100));
border-radius: var(--main-borderRadius);
padding: var(--main-padding);
gap: 1.2rem;
}

.graphContainer .header {
width: 100%;
display: flex;
flex-flow: row;
align-items: flex-end;
justify-content: space-between;
}

.graphContainer .chart,
.chart {
height: 18rem;
}

.header .rating {
display: flex;
flex-flow: row;
font-size: 3.4rem;
font-weight: 600;
gap: 0.6rem;
line-height: 3.4rem;
}

.rating .change {
font-size: 1.6rem;
line-height: 2.2rem;
display: flex;
flex-flow: row;
align-items: flex-end;
}

.change.positive {
color: hsla(var(--green-400));
}

.change.positive::before {
content: '+';
}

.change.negative {
color: hsla(var(--red-400));
}

.change.negative::before {
content: '-';
}

.header .stats {
display: flex;
flex-flow: row;
gap: 4rem;
align-items: flex-end;
}

.stats .item {
display: flex;
flex-flow: row;
gap: 1.1rem;
font-size: 1.1rem;
font-weight: 400;
}

.item .score {
font-weight: 600;
}

.item #rank::before {
content: '#';
}

.item #percentile::after {
content: '%';
}

.cardStat {
display: flex;
flex-flow: row;
gap: 1rem;
font-size: 1.2rem;
}

.cardStat .value {
font-weight: 600;
}

.noGraphText {
font-style: italic;
font-weight: 400;
font-size: 0.9rem;
}
Loading
Loading