From 6031c81f5394acf315b277302a7fd18ea288b506 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 19 Aug 2024 04:40:08 +0900 Subject: refactor(frontend): extract UserIcon component --- .../components/GolfPlayApps/GolfPlayAppGaming.tsx | 13 +++----- .../GolfWatchApps/GolfWatchAppGaming.tsx | 25 +++++--------- frontend/app/components/UserIcon.tsx | 19 +++++++++++ frontend/app/routes/dashboard.tsx | 39 ++++++++++------------ 4 files changed, 50 insertions(+), 46 deletions(-) create mode 100644 frontend/app/components/UserIcon.tsx (limited to 'frontend/app') diff --git a/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx b/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx index e9139ba..e6cb7e9 100644 --- a/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx +++ b/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx @@ -4,6 +4,7 @@ import SubmitButton from "../../components/SubmitButton"; import type { PlayerInfo } from "../../models/PlayerInfo"; import BorderedContainer from "../BorderedContainer"; import SubmitResult from "../Gaming/SubmitResult"; +import UserIcon from "../UserIcon"; type Props = { gameDisplayName: string; @@ -60,14 +61,10 @@ export default function GolfPlayAppGaming({
{playerInfo.displayName}
{playerInfo.iconPath && ( - {`${playerInfo.displayName} )} diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx index e8ac825..e325cf7 100644 --- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx @@ -3,6 +3,7 @@ import BorderedContainer from "../BorderedContainer"; import CodeBlock from "../Gaming/CodeBlock"; import ScoreBar from "../Gaming/ScoreBar"; import SubmitResult from "../Gaming/SubmitResult"; +import UserIcon from "../UserIcon"; type Props = { gameDisplayName: string; @@ -39,14 +40,10 @@ export default function GolfWatchAppGaming({
{playerInfoA.iconPath && ( - {`${playerInfoA.displayName} )}
@@ -68,14 +65,10 @@ export default function GolfWatchAppGaming({
{playerInfoB.displayName}
{playerInfoB.iconPath && ( - {`${playerInfoB.displayName} )}
diff --git a/frontend/app/components/UserIcon.tsx b/frontend/app/components/UserIcon.tsx new file mode 100644 index 0000000..656c170 --- /dev/null +++ b/frontend/app/components/UserIcon.tsx @@ -0,0 +1,19 @@ +type Props = { + iconPath: string; + displayName: string; + className: string; +}; + +export default function UserIcon({ iconPath, displayName, className }: Props) { + return ( + {`${displayName} + ); +} diff --git a/frontend/app/routes/dashboard.tsx b/frontend/app/routes/dashboard.tsx index 7aa77fd..3a50757 100644 --- a/frontend/app/routes/dashboard.tsx +++ b/frontend/app/routes/dashboard.tsx @@ -4,6 +4,7 @@ import { apiGetGames } from "../.server/api/client"; import { ensureUserLoggedIn } from "../.server/auth"; import BorderedContainer from "../components/BorderedContainer"; import NavigateLink from "../components/NavigateLink"; +import UserIcon from "../components/UserIcon"; export const meta: MetaFunction = () => [ { title: "Dashboard | iOSDC Japan 2024 Albatross.swift" }, @@ -22,23 +23,19 @@ export default function Dashboard() { const { user, games } = useLoaderData()!; return ( -
+
{user.icon_path && ( - {`${user.display_name} )} -

+

{user.display_name} @{user.username}

-

試合

+

試合

{games.length === 0 ? ( @@ -77,16 +74,14 @@ export default function Dashboard() { )}
-
-
- -
-
+
+ +
{user.is_admin && ( Admin Dashboard -- cgit v1.2.3-70-g09d2