-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [frontend] Add match history page * [backend] Remove UserGuard from history controller - Order history by date * [backend] Add match history seed data
- Loading branch information
Showing
6 changed files
with
150 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,9 @@ export class HistoryService { | |
}, | ||
}, | ||
}, | ||
orderBy: { | ||
createdAt: 'desc', | ||
}, | ||
...SelectHistory, | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { MatchDetailEntity, getMatchHistory } from "@/app/lib/actions"; | ||
import Link from "next/link"; | ||
import { Avatar } from "./avatar"; | ||
|
||
function MatchDetailItem({ | ||
detail, | ||
isProfileUser, | ||
}: { | ||
detail: MatchDetailEntity; | ||
isProfileUser: boolean; | ||
}) { | ||
const textColor = isProfileUser | ||
? detail.winLose === "WIN" | ||
? "text-green-500" | ||
: "text-red-500" | ||
: ""; | ||
return ( | ||
<Link href={`/user/${detail.user.id}`}> | ||
<div className="flex flex-col gap-2"> | ||
<div className="flex gap-2 items-center"> | ||
<Avatar avatarURL={detail.user.avatarURL} size="medium" /> | ||
<div>{detail.user.name}</div> | ||
<div className={`font-bold ${textColor}`}> | ||
{detail.winLose} ({detail.score}) | ||
</div> | ||
</div> | ||
</div> | ||
</Link> | ||
); | ||
} | ||
|
||
export default async function MatchHistory({ userId }: { userId: number }) { | ||
const history = await getMatchHistory(userId); | ||
return ( | ||
<div className="flex flex-col gap-2"> | ||
<div className="text-xl font-bold">Match History</div> | ||
<div className="flex flex-col gap-2"> | ||
{history.map((match) => { | ||
return ( | ||
<div key={match.id} className="flex gap-8 items-center"> | ||
<MatchDetailItem | ||
detail={match.players[0]} | ||
isProfileUser={match.players[0].user.id === userId} | ||
/> | ||
<MatchDetailItem | ||
detail={match.players[1]} | ||
isProfileUser={match.players[1].user.id === userId} | ||
/> | ||
<div className="text-sm">{match.createdAt}</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters