Skip to content

Commit

Permalink
fix: code
Browse files Browse the repository at this point in the history
  • Loading branch information
karanpargal committed Sep 3, 2024
1 parent b918bdd commit c56ca3b
Show file tree
Hide file tree
Showing 8 changed files with 5,160 additions and 6,188 deletions.
742 changes: 374 additions & 368 deletions packages/backend/utils/types/database.types.ts

Large diffs are not rendered by default.

68 changes: 32 additions & 36 deletions packages/frontend/src/app/components/profile/GameHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GamePlayer } from "./GamePlayer";
import { useWeb3AuthContext } from "@/utils/context/web3auth.context";
import { MappedPlayedGame } from "@/utils/types";

export const GameHistory: React.FC<{ playedGame: MappedPlayedGame }> = async ({
export const GameHistory: React.FC<{ playedGame: MappedPlayedGame }> = ({
playedGame,
}) => {
const { user } = useWeb3AuthContext();
Expand All @@ -17,46 +17,42 @@ export const GameHistory: React.FC<{ playedGame: MappedPlayedGame }> = async ({
const won = playedGame.winner_id === user.data.player_id;

return (
<div className="px-4">
<h3 className="text-heading-3 text-neutral-300 my-2">Match History</h3>

<div className="border border-neutral-400 rounded-lg w-full">
<p className="text-body-1 text-neutral-100 bg-neutral-600 font-medium px-4 py-2 w-full rounded-t-lg">
{playedGame.game_id}
</p>

<div className="flex justify-center items-center gap-x-6 max-w-80 pt-8 w-3/5 mx-auto">
<GamePlayer
profile_photo={user.data.profile_photo}
won={won}
name="You"
wallet_address={user.data.wallet_address}
/>

<BattleIcon className="h-20 w-20" />

<GamePlayer
profile_photo={user.data.profile_photo}
won={won}
name="Enemy"
wallet_address={user.data.wallet_address}
/>
</div>
<div className="border border-neutral-400 rounded-lg w-full my-6">
<p className="text-body-1 text-neutral-100 bg-neutral-600 font-medium px-4 py-2 w-full rounded-t-lg">
{playedGame.game_id}
</p>

<div className="flex justify-center items-center gap-x-6 max-w-80 pt-8 w-3/5 mx-auto">
<GamePlayer
profile_photo={user.data.profile_photo}
won={won}
name="You"
wallet_address={user.data.wallet_address}
/>

<BattleIcon className="h-20 w-20" />

<GamePlayer
profile_photo={user.data.profile_photo}
won={won}
name="Enemy"
wallet_address={user.data.wallet_address}
/>
</div>

<div className="px-4 mt-4 text-body-3">
<div className="flex items-center gap-x-2 justify-start py-4 border-t border-neutral-500">
<p className="text-status-danger">Loss</p>
<div className="px-4 mt-4 text-body-3">
<div className="flex items-center gap-x-2 justify-start py-4 border-t border-neutral-500">
<p className="text-status-danger">Loss</p>

<span className="text-neutral-500">|</span>
<span className="text-neutral-500">|</span>

<p className="text-neutral-100">
<span className="text-neutral-300">Tier</span> Alpha
</p>
<p className="text-neutral-100">
<span className="text-neutral-300">Tier</span> Alpha
</p>

<span className="text-neutral-500">|</span>
<span className="text-neutral-500">|</span>

<p className="text-neutral-300">21 Aug 2024</p>
</div>
<p className="text-neutral-300">21 Aug 2024</p>
</div>
</div>
</div>
Expand Down
70 changes: 70 additions & 0 deletions packages/frontend/src/app/components/profile/SeasonStats.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React from "react";
import SeasonDropdown from "../shared/season-dropdown";
import { MappedPlayedGame, MappedSeason } from "@/utils/types";
import { GameHistory } from "./GameHistory";

const SeasonStats: React.FC<{
seasons: MappedSeason[];
selectedSeason: MappedSeason;
setSelectedSeason: React.Dispatch<
React.SetStateAction<MappedSeason | undefined>
>;
selectedSeasonEnded: boolean;
playedGames: MappedPlayedGame[];
}> = ({
seasons,
selectedSeason,
setSelectedSeason,
selectedSeasonEnded,
playedGames,
}) => {
return (
<div className="mx-4">
<h3 className="text-heading-3 text-neutral-300 my-2 mb-6">
Season Stats
</h3>

<SeasonDropdown
seasons={seasons}
selectedSeason={selectedSeason}
setSelectedSeason={setSelectedSeason}
selectedSeasonEnded={selectedSeasonEnded}
/>

<div className="flex justify-center items-center border border-neutral-400 p-4 rounded-lg mt-6 gap-x-2">
{[
{
heading: "Won",
value: 1,
},
{
heading: "Played",
value: 2,
},
{
heading: "Score",
value: 1,
},
{
heading: "Rank",
value: 1,
},
].map(({ heading, value }) => (
<div
key={heading}
className="flex-1 flex-col gap-y-1 text-center border-r last:border-r-0 px-1"
>
<p className="text-neutral-300 text-body-3">{heading}</p>
<p className="text-neutral-100 text-body-1">{value}</p>
</div>
))}
</div>

{playedGames.map((game) => (
<GameHistory key="" playedGame={game} />
))}
</div>
);
};

export default SeasonStats;
11 changes: 10 additions & 1 deletion packages/frontend/src/app/components/profile/WalletDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { getTokenBalance } from "@/utils/functions/ethers";
import { web3auth } from "@/utils/service/web3auth.service";
import { CustomChainConfig } from "@web3auth/base";
import { useEffect, useState } from "react";
import { ChainSelector } from "./ChainSelector";

export const WalletDetails: React.FC<{
selectedChain: CustomChainConfig;
}> = ({ selectedChain }) => {
setSelectedChain: (chain: CustomChainConfig) => void;
}> = ({ selectedChain, setSelectedChain }) => {
// const { user } = useWeb3AuthContext();
const [currentBalance, setCurrentBalance] = useState<string>("0");
const user = {
Expand Down Expand Up @@ -44,6 +46,13 @@ export const WalletDetails: React.FC<{

return (
<>
<h3 className="text-heading-3 text-neutral-300 my-2 mx-4">
Wallet Details
</h3>
<ChainSelector
selectedChain={selectedChain}
setSelectedChain={setSelectedChain}
/>
<div className="flex flex-col justify-center items-center border border-neutral-400 mx-4 rounded-lg">
<p className="text-body-1 text-neutral-100 bg-neutral-600 px-4 py-2 w-full rounded-t-lg">
Connected Wallet
Expand Down
25 changes: 0 additions & 25 deletions packages/frontend/src/app/components/profile/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,6 @@ export const ProfileHero: React.FC = () => {
<p className="text-neutral-300 text-body-3">{user.data.email_id}</p>
</div>
</div>

<div className="flex justify-center items-center border border-neutral-400 p-4 mx-4 rounded-lg">
{[
{
heading: "Won",
value: "user.data.won",
},
{
heading: "Played",
value: "user.data.played",
},
{
heading: "Score",
value: "user.data.score",
},
].map(({ heading, value }) => (
<div
key={heading}
className="flex-1 flex-col gap-y-1 text-center border-r last:border-r-0"
>
<p className="text-neutral-300 text-body-3">{heading}</p>
<p className="text-neutral-100 text-body-1">{value}</p>
</div>
))}
</div>
</>
);
};
80 changes: 80 additions & 0 deletions packages/frontend/src/app/components/shared/season-dropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
"use client";

import ChevronDown from "@/shared/icons/Chevron-Down";
import Dropdown from "./dropdown";
import { MappedSeason } from "@/utils/types";
import { useState } from "react";

const SeasonDropdown: React.FC<{
seasons: MappedSeason[];
selectedSeason: MappedSeason;
setSelectedSeason: React.Dispatch<
React.SetStateAction<MappedSeason | undefined>
>;
selectedSeasonEnded: boolean;
}> = ({ seasons, selectedSeason, setSelectedSeason, selectedSeasonEnded }) => {
const [dropdownOpen, setDropdownOpen] = useState<boolean>(false);

return (
<Dropdown
open={dropdownOpen}
setOpen={setDropdownOpen}
trigger="click"
propagationStop
options={[
<div
key="seasons-dropdown"
className="bg-neutral-600 mt-2 rounded-lg px-4 max-h-96 overflow-auto"
>
{seasons.map((season, i) => (
<div
key={season.season_id}
className={`${
selectedSeason.season_id === season.season_id
? "bg-neutral-500"
: ""
} rounded-lg py-3 px-4 my-4 flex items-center justify-between w-full text-neutral-300 hover:text-neutral-100 transition-all cursor-pointer`}
onClick={() => {
setSelectedSeason(season);
setDropdownOpen(false);
}}
>
<p className="font-medium text-body-1">{season.name}</p>

{season.ended_on > new Date().toISOString() ? (
<span className="px-3 py-2 font-medium leading-none text-body-4 text-neutral-500 bg-status-success rounded-2xl">
LIVE
</span>
) : (
<p className="text-body-4">
Ended on {new Date(season.ended_on).getDate()}
</p>
)}
</div>
))}
</div>,
]}
dropdownClassname="w-full"
>
<div className="cursor-pointer border-neutral-400 border rounded-lg p-4 flex items-center justify-between">
<div className="flex items-center gap-4">
<span>{selectedSeason.name}</span>

{selectedSeasonEnded && (
<span className="px-3 py-2 font-medium leading-none text-body-4 text-neutral-500 bg-status-success rounded-2xl">
LIVE
</span>
)}
</div>

<div
className={`text-neutral-300 ${dropdownOpen ? "rotate-180" : ""} transition-all`}
>
<ChevronDown />
</div>
</div>
</Dropdown>
);
};

export default SeasonDropdown;
Loading

0 comments on commit c56ca3b

Please sign in to comment.