diff --git a/apps/web/.env.development b/apps/web/.env.development new file mode 100644 index 00000000..cd55dbf3 --- /dev/null +++ b/apps/web/.env.development @@ -0,0 +1,7 @@ +VITE_API_BASE_URL=http://localhost:3000 +VITE_DEFAULT_COMMUNITY_ID=69ebe0adf627c11be2f020a1 +VITE_MSAL_CLIENT_ID=15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3 +VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/5ef88004-e953-4b04-93db-64bbf49c6863 +VITE_MSAL_API_SCOPE=api://15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3/lolympus-tournament-support-dev +VITE_MSAL_REDIRECT_URI=http://localhost:5173/auth/callback +VITE_MSAL_SILENT_REDIRECT_URI=http://localhost:5173/auth/silent-callback.html diff --git a/apps/web/.env.example b/apps/web/.env.example new file mode 100644 index 00000000..969d2d5c --- /dev/null +++ b/apps/web/.env.example @@ -0,0 +1,7 @@ +VITE_API_BASE_URL=http://localhost:3000 +VITE_DEFAULT_COMMUNITY_ID= +VITE_MSAL_CLIENT_ID=15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3 +VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/ +VITE_MSAL_API_SCOPE=api://lolympus-api/access_as_user +VITE_MSAL_REDIRECT_URI=http://localhost:5173/auth/callback +VITE_MSAL_SILENT_REDIRECT_URI=http://localhost:5173/auth/silent-callback.html diff --git a/apps/web/.env.production b/apps/web/.env.production new file mode 100644 index 00000000..64d88a8a --- /dev/null +++ b/apps/web/.env.production @@ -0,0 +1,8 @@ +VITE_API_BASE_URL=https://lolympus-api.dahyeon.us +VITE_DEFAULT_COMMUNITY_ID=69ebe0adf627c11be2f020a1 +VITE_MSAL_CLIENT_ID=15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3 +VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/5ef88004-e953-4b04-93db-64bbf49c6863 +VITE_MSAL_API_SCOPE=api://15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3/lolympus-tournament-support-dev +VITE_MSAL_REDIRECT_URI=https://lolympus.dahyeon.us/auth/callback +VITE_MSAL_SILENT_REDIRECT_URI=https://lolympus.dahyeon.us/auth/silent-callback.html + diff --git a/apps/web/.env.test b/apps/web/.env.test new file mode 100644 index 00000000..be6c0bbe --- /dev/null +++ b/apps/web/.env.test @@ -0,0 +1,6 @@ +VITE_API_BASE_URL=https://lolympus-test-api.dahyeon.us +VITE_DEFAULT_COMMUNITY_ID=69ebe0adf627c11be2f020a1 +VITE_MSAL_CLIENT_ID=15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3 +VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/5ef88004-e953-4b04-93db-64bbf49c6863 +VITE_MSAL_API_SCOPE=api://15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3/lolympus-tournament-support-dev +VITE_MSAL_REDIRECT_URI=http://localhost:5173/auth/callback diff --git a/apps/web/.gitignore b/apps/web/.gitignore new file mode 100644 index 00000000..a547bf36 --- /dev/null +++ b/apps/web/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/apps/web/README.md b/apps/web/README.md new file mode 100644 index 00000000..7dbf7ebf --- /dev/null +++ b/apps/web/README.md @@ -0,0 +1,73 @@ +# React + TypeScript + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +Currently, two official plugins are available: + +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs) +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) + +## React Compiler + +The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). + +## Expanding the ESLint configuration + +If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: + +```js +export default defineConfig([ + globalIgnores(['dist']), + { + files: ['**/*.{ts,tsx}'], + extends: [ + // Other configs... + + // Remove tseslint.configs.recommended and replace with this + tseslint.configs.recommendedTypeChecked, + // Alternatively, use this for stricter rules + tseslint.configs.strictTypeChecked, + // Optionally, add this for stylistic rules + tseslint.configs.stylisticTypeChecked, + + // Other configs... + ], + languageOptions: { + parserOptions: { + project: ['./tsconfig.node.json', './tsconfig.app.json'], + tsconfigRootDir: import.meta.dirname, + }, + // other options... + }, + }, +]) +``` + +You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: + +```js +// eslint.config.js +import reactX from 'eslint-plugin-react-x' +import reactDom from 'eslint-plugin-react-dom' + +export default defineConfig([ + globalIgnores(['dist']), + { + files: ['**/*.{ts,tsx}'], + extends: [ + // Other configs... + // Enable lint rules for React + reactX.configs['recommended-typescript'], + // Enable lint rules for React DOM + reactDom.configs.recommended, + ], + languageOptions: { + parserOptions: { + project: ['./tsconfig.node.json', './tsconfig.app.json'], + tsconfigRootDir: import.meta.dirname, + }, + // other options... + }, + }, +]) +``` diff --git a/apps/web/eslint.config.js b/apps/web/eslint.config.js new file mode 100644 index 00000000..5e6b472f --- /dev/null +++ b/apps/web/eslint.config.js @@ -0,0 +1,23 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import tseslint from 'typescript-eslint' +import { defineConfig, globalIgnores } from 'eslint/config' + +export default defineConfig([ + globalIgnores(['dist']), + { + files: ['**/*.{ts,tsx}'], + extends: [ + js.configs.recommended, + tseslint.configs.recommended, + reactHooks.configs.flat.recommended, + reactRefresh.configs.vite, + ], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + }, +]) diff --git a/apps/web/index.html b/apps/web/index.html new file mode 100644 index 00000000..ae9502bc --- /dev/null +++ b/apps/web/index.html @@ -0,0 +1,13 @@ + + + + + + + 롤림푸스 - 내전 관리 + + +
+ + + diff --git a/apps/web/package.json b/apps/web/package.json new file mode 100644 index 00000000..e689239d --- /dev/null +++ b/apps/web/package.json @@ -0,0 +1,46 @@ +{ + "name": "web", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "build:test": "tsc -b && vite build --mode test", + "build:prod": "tsc -b && vite build --mode production", + "deploy:test": "node ../../scripts/deploy-cloudflare-pages.mjs test", + "deploy:prod": "node ../../scripts/deploy-cloudflare-pages.mjs prod", + "pages:login": "wrangler login", + "pages:whoami": "wrangler whoami", + "lint": "eslint .", + "preview": "vite preview" + }, + "dependencies": { + "@azure/msal-browser": "^5.8.0", + "@azure/msal-react": "^5.3.1", + "@tanstack/react-query": "^5.100.1", + "lucide-react": "^1.14.0", + "react": "^19.2.4", + "react-dom": "^19.2.4", + "react-router": "^7.14.0", + "socket.io-client": "^4.8.3" + }, + "devDependencies": { + "@eslint/js": "^9.39.4", + "@tailwindcss/vite": "^4.2.2", + "@types/node": "^24.12.2", + "@types/react": "^19.2.14", + "@types/react-dom": "^19.2.3", + "@vitejs/plugin-react": "^6.0.1", + "daisyui": "^5.5.19", + "eslint": "^9.39.4", + "eslint-plugin-react-hooks": "^7.0.1", + "eslint-plugin-react-refresh": "^0.5.2", + "globals": "^17.4.0", + "tailwindcss": "^4.2.2", + "typescript": "~6.0.2", + "typescript-eslint": "^8.58.0", + "vite": "^8.0.4", + "wrangler": "^4.85.0" + } +} diff --git a/apps/web/public/_headers b/apps/web/public/_headers new file mode 100644 index 00000000..05a20c9e --- /dev/null +++ b/apps/web/public/_headers @@ -0,0 +1,9 @@ +/* + X-Content-Type-Options: nosniff + Referrer-Policy: strict-origin-when-cross-origin + +/assets/* + Cache-Control: public, max-age=31536000, immutable + +/index.html + Cache-Control: no-cache diff --git a/apps/web/public/_redirects b/apps/web/public/_redirects new file mode 100644 index 00000000..7797f7c6 --- /dev/null +++ b/apps/web/public/_redirects @@ -0,0 +1 @@ +/* /index.html 200 diff --git a/apps/web/public/auth/silent-callback.html b/apps/web/public/auth/silent-callback.html new file mode 100644 index 00000000..5db0a78d --- /dev/null +++ b/apps/web/public/auth/silent-callback.html @@ -0,0 +1,8 @@ + + + + + Silent Auth + + + diff --git a/apps/web/public/favicon.svg b/apps/web/public/favicon.svg new file mode 100644 index 00000000..6893eb13 --- /dev/null +++ b/apps/web/public/favicon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/public/icons.svg b/apps/web/public/icons.svg new file mode 100644 index 00000000..e9522193 --- /dev/null +++ b/apps/web/public/icons.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/web/public/riot.txt b/apps/web/public/riot.txt new file mode 100644 index 00000000..3028f46b --- /dev/null +++ b/apps/web/public/riot.txt @@ -0,0 +1 @@ +c47e5251-44c8-4569-a3f6-3cab42fdec98 \ No newline at end of file diff --git a/apps/web/src/App.css b/apps/web/src/App.css new file mode 100644 index 00000000..e00a71c3 --- /dev/null +++ b/apps/web/src/App.css @@ -0,0 +1 @@ +/* App-specific styles — currently using Tailwind + daisyUI */ diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx new file mode 100644 index 00000000..c5c84037 --- /dev/null +++ b/apps/web/src/App.tsx @@ -0,0 +1,116 @@ +import { BrowserRouter, Link, Route, Routes } from 'react-router'; +import { useMsal } from '@azure/msal-react'; +import DevAuthSwitcher from './components/DevAuthSwitcher'; +import { DEFAULT_COMMUNITY_ID } from './config'; +import { useCommunity } from './api/hooks'; +import { isMsalConfigured } from './lib/auth/msal.config'; +import AuthCallbackPage from './pages/AuthCallback'; +import HomePage from './pages/HomePage'; +import LoginPage from './pages/Login'; +import MatchDetailPage from './pages/MatchDetailPage'; +import MatchTeamProgressPage from './pages/MatchTeamProgressPage'; +import AuctionPage from './pages/AuctionPage'; +import UserHistoryPage from './pages/UserHistoryPage'; +import CommunityInternalStatsPage from './pages/CommunityInternalStatsPage'; +import InternalMatchDetailPage from './pages/InternalMatchDetailPage'; +import LegacyImportPage from './pages/admin/LegacyImportPage'; +import LegacyMatchesPage from './pages/admin/LegacyMatchesPage'; +import MatchAdminPage from './pages/admin/MatchAdminPage'; +import TournamentCodesPage from './pages/admin/TournamentCodesPage'; + +function MsalHeaderActions() { + const { accounts, instance } = useMsal(); + const account = instance.getActiveAccount() ?? accounts[0]; + + if (!account) { + return ( + + 로그인 + + ); + } + + return ( + + ); +} + +function App() { + const communityQuery = useCommunity(DEFAULT_COMMUNITY_ID); + const communityLabel = communityQuery.data?.name ?? 'LOLYMPUS'; + + return ( + +
+ + + + } /> + } /> + } /> + } /> + } + /> + } /> + } /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + + +
+
+ ); +} + +export default App; diff --git a/apps/web/src/assets/hero.png b/apps/web/src/assets/hero.png new file mode 100644 index 00000000..cc51a3d2 Binary files /dev/null and b/apps/web/src/assets/hero.png differ diff --git a/apps/web/src/assets/position/Bottom_icon.png b/apps/web/src/assets/position/Bottom_icon.png new file mode 100644 index 00000000..c49002d3 Binary files /dev/null and b/apps/web/src/assets/position/Bottom_icon.png differ diff --git a/apps/web/src/assets/position/Jungle_icon.png b/apps/web/src/assets/position/Jungle_icon.png new file mode 100644 index 00000000..88daaf69 Binary files /dev/null and b/apps/web/src/assets/position/Jungle_icon.png differ diff --git a/apps/web/src/assets/position/Middle_icon.png b/apps/web/src/assets/position/Middle_icon.png new file mode 100644 index 00000000..c16810c7 Binary files /dev/null and b/apps/web/src/assets/position/Middle_icon.png differ diff --git a/apps/web/src/assets/position/Specialist_icon.png b/apps/web/src/assets/position/Specialist_icon.png new file mode 100644 index 00000000..0ed35aee Binary files /dev/null and b/apps/web/src/assets/position/Specialist_icon.png differ diff --git a/apps/web/src/assets/position/Support_icon.png b/apps/web/src/assets/position/Support_icon.png new file mode 100644 index 00000000..724f6c8c Binary files /dev/null and b/apps/web/src/assets/position/Support_icon.png differ diff --git a/apps/web/src/assets/position/Top_icon.png b/apps/web/src/assets/position/Top_icon.png new file mode 100644 index 00000000..fa923fce Binary files /dev/null and b/apps/web/src/assets/position/Top_icon.png differ diff --git a/apps/web/src/assets/position/bot-gold.svg b/apps/web/src/assets/position/bot-gold.svg new file mode 100644 index 00000000..caafb7ba --- /dev/null +++ b/apps/web/src/assets/position/bot-gold.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/apps/web/src/assets/position/bot-white.svg b/apps/web/src/assets/position/bot-white.svg new file mode 100644 index 00000000..2c4fcc73 --- /dev/null +++ b/apps/web/src/assets/position/bot-white.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/apps/web/src/assets/position/jungle-gold.svg b/apps/web/src/assets/position/jungle-gold.svg new file mode 100644 index 00000000..759c655f --- /dev/null +++ b/apps/web/src/assets/position/jungle-gold.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/apps/web/src/assets/position/jungle-white.svg b/apps/web/src/assets/position/jungle-white.svg new file mode 100644 index 00000000..3d04f51c --- /dev/null +++ b/apps/web/src/assets/position/jungle-white.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/apps/web/src/assets/position/mid-gold.svg b/apps/web/src/assets/position/mid-gold.svg new file mode 100644 index 00000000..e1bfff78 --- /dev/null +++ b/apps/web/src/assets/position/mid-gold.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/apps/web/src/assets/position/mid-white.svg b/apps/web/src/assets/position/mid-white.svg new file mode 100644 index 00000000..fef3b83f --- /dev/null +++ b/apps/web/src/assets/position/mid-white.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/apps/web/src/assets/position/position-bottom.svg b/apps/web/src/assets/position/position-bottom.svg new file mode 100644 index 00000000..4c3917a4 --- /dev/null +++ b/apps/web/src/assets/position/position-bottom.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/apps/web/src/assets/position/position-jungle.svg b/apps/web/src/assets/position/position-jungle.svg new file mode 100644 index 00000000..1beaf9bd --- /dev/null +++ b/apps/web/src/assets/position/position-jungle.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/apps/web/src/assets/position/position-middle.svg b/apps/web/src/assets/position/position-middle.svg new file mode 100644 index 00000000..abfd95cc --- /dev/null +++ b/apps/web/src/assets/position/position-middle.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/apps/web/src/assets/position/position-support.svg b/apps/web/src/assets/position/position-support.svg new file mode 100644 index 00000000..4e31d1cb --- /dev/null +++ b/apps/web/src/assets/position/position-support.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/apps/web/src/assets/position/position-top.svg b/apps/web/src/assets/position/position-top.svg new file mode 100644 index 00000000..442f48da --- /dev/null +++ b/apps/web/src/assets/position/position-top.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/apps/web/src/assets/position/support-gold.svg b/apps/web/src/assets/position/support-gold.svg new file mode 100644 index 00000000..a89d6a15 --- /dev/null +++ b/apps/web/src/assets/position/support-gold.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/apps/web/src/assets/position/support-white.svg b/apps/web/src/assets/position/support-white.svg new file mode 100644 index 00000000..18f6851c --- /dev/null +++ b/apps/web/src/assets/position/support-white.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/apps/web/src/assets/position/top-gold.svg b/apps/web/src/assets/position/top-gold.svg new file mode 100644 index 00000000..442f48da --- /dev/null +++ b/apps/web/src/assets/position/top-gold.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/apps/web/src/assets/position/top-white.svg b/apps/web/src/assets/position/top-white.svg new file mode 100644 index 00000000..fa3e1b6d --- /dev/null +++ b/apps/web/src/assets/position/top-white.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/apps/web/src/assets/react.svg b/apps/web/src/assets/react.svg new file mode 100644 index 00000000..6c87de9b --- /dev/null +++ b/apps/web/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/vite.svg b/apps/web/src/assets/vite.svg new file mode 100644 index 00000000..5101b674 --- /dev/null +++ b/apps/web/src/assets/vite.svg @@ -0,0 +1 @@ +Vite diff --git a/apps/web/src/components/DevAuthSwitcher.tsx b/apps/web/src/components/DevAuthSwitcher.tsx new file mode 100644 index 00000000..29f25143 --- /dev/null +++ b/apps/web/src/components/DevAuthSwitcher.tsx @@ -0,0 +1,58 @@ +import { useEffect, useState } from 'react'; +import { useQueryClient } from '@tanstack/react-query'; +import { setAuthUserId, useAuthUserId } from '../config'; + +export default function DevAuthSwitcher() { + const authUserId = useAuthUserId(); + const queryClient = useQueryClient(); + const [inputValue, setInputValue] = useState(authUserId ?? ''); + + useEffect(() => { + setInputValue(authUserId ?? ''); + }, [authUserId]); + + if (!import.meta.env.DEV) { + return null; + } + + function updateAuthUserId(nextValue: string | null) { + setAuthUserId(nextValue); + void queryClient.invalidateQueries(); + } + + return ( +
+
+ Dev Auth +
+
+ X-Auth-User-Id +
+ setInputValue(event.target.value)} + placeholder="Mongo User ID" + className="mt-1 w-full border border-base-content/10 bg-transparent px-2 py-2 text-xs text-base-content focus:outline-none focus:border-primary/30" + /> +
+ + +
+
+ 현재값: {authUserId ?? '없음'} +
+
+ ); +} diff --git a/apps/web/src/config.ts b/apps/web/src/config.ts new file mode 100644 index 00000000..2e0381ca --- /dev/null +++ b/apps/web/src/config.ts @@ -0,0 +1,97 @@ +import { useSyncExternalStore } from 'react'; + +const AUTH_USER_ID_STORAGE_KEY = 'lolympus.authUserId'; +const DEV_CAPTAIN_TEAM_INDEX_STORAGE_KEY = 'lolympus.devCaptainTeamIndex'; +const LEGACY_DEV_CAPTAIN_SIDE_STORAGE_KEY = 'lolympus.devCaptainSide'; +const AUTH_USER_CHANGED_EVENT = 'lolympus:auth-user-changed'; +const CAPTAIN_SIDE_CHANGED_EVENT = 'lolympus:captain-side-changed'; + +export const API_BASE_URL = ( + import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:3000' +).replace(/\/$/, ''); + +export const DEFAULT_COMMUNITY_ID = ( + import.meta.env.VITE_DEFAULT_COMMUNITY_ID ?? '' +).trim(); + +function dispatchWindowEvent(eventName: string) { + if (typeof window === 'undefined') return; + window.dispatchEvent(new Event(eventName)); +} + +function subscribeToWindowChanges(eventName: string, callback: () => void) { + if (typeof window === 'undefined') { + return () => undefined; + } + + const handleChange = () => callback(); + window.addEventListener(eventName, handleChange); + window.addEventListener('storage', handleChange); + + return () => { + window.removeEventListener(eventName, handleChange); + window.removeEventListener('storage', handleChange); + }; +} + +export function getAuthUserId(): string | null { + if (!import.meta.env.DEV) return null; + if (typeof window === 'undefined') return null; + const value = window.localStorage.getItem(AUTH_USER_ID_STORAGE_KEY)?.trim(); + return value ? value : null; +} + +export function setAuthUserId(userId: string | null) { + if (!import.meta.env.DEV) return; + if (typeof window === 'undefined') return; + + if (!userId?.trim()) { + window.localStorage.removeItem(AUTH_USER_ID_STORAGE_KEY); + } else { + window.localStorage.setItem(AUTH_USER_ID_STORAGE_KEY, userId.trim()); + } + + dispatchWindowEvent(AUTH_USER_CHANGED_EVENT); +} + +export function getDevCaptainTeamIndex(): number | null { + if (typeof window === 'undefined') return null; + + const value = window.localStorage.getItem(DEV_CAPTAIN_TEAM_INDEX_STORAGE_KEY); + const parsed = Number(value); + if (Number.isInteger(parsed) && parsed > 0) return parsed; + + const legacy = window.localStorage.getItem(LEGACY_DEV_CAPTAIN_SIDE_STORAGE_KEY); + if (legacy === 'blue') return 1; + if (legacy === 'red') return 2; + return null; +} + +export function setDevCaptainTeamIndex(teamIndex: number | null) { + if (typeof window === 'undefined') return; + if (teamIndex && Number.isInteger(teamIndex) && teamIndex > 0) { + window.localStorage.setItem( + DEV_CAPTAIN_TEAM_INDEX_STORAGE_KEY, + String(teamIndex), + ); + } else { + window.localStorage.removeItem(DEV_CAPTAIN_TEAM_INDEX_STORAGE_KEY); + } + dispatchWindowEvent(CAPTAIN_SIDE_CHANGED_EVENT); +} + +export function useAuthUserId(): string | null { + return useSyncExternalStore( + (callback) => subscribeToWindowChanges(AUTH_USER_CHANGED_EVENT, callback), + getAuthUserId, + () => null, + ); +} + +export function useDevCaptainTeamIndex(): number | null { + return useSyncExternalStore( + (callback) => subscribeToWindowChanges(CAPTAIN_SIDE_CHANGED_EVENT, callback), + getDevCaptainTeamIndex, + () => null, + ); +} diff --git a/apps/web/src/index.css b/apps/web/src/index.css new file mode 100644 index 00000000..45ade146 --- /dev/null +++ b/apps/web/src/index.css @@ -0,0 +1,46 @@ +@import url("https://fonts.googleapis.com/css2?family=Asta+Sans:wght@300..800&family=Gamja+Flower&display=swap"); + +@import "tailwindcss"; +@plugin "daisyui" { + themes: + light --default, + dark --prefersdark; +} + +body { + margin: 0; + font-family: + "Asta Sans", + -apple-system, + BlinkMacSystemFont, + system-ui, + Roboto, + "Helvetica Neue", + "Segoe UI", + "Apple SD Gothic Neo", + "Noto Sans KR", + "Malgun Gothic", + "Apple Color Emoji", + "Segoe UI Emoji", + "Segoe UI Symbol", + sans-serif; + font-size: 14px; + line-height: 1.5; +} + +/* poro.gg style: 모든 모서리 각지게 */ +*, +*::before, +*::after { + border-radius: 0 !important; +} + +/* daisyUI badge만 살짝 둥글게 (pill 형태) */ +.badge { + border-radius: 2px !important; +} + +/* 버튼도 각지게 */ +.btn { + border-radius: 0 !important; +} diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx new file mode 100644 index 00000000..5487c4df --- /dev/null +++ b/apps/web/src/main.tsx @@ -0,0 +1,26 @@ +import { StrictMode } from 'react'; +import { createRoot } from 'react-dom/client'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import './index.css'; +import App from './App.tsx'; +import { MsalAppProvider } from './lib/auth/MsalAppProvider.tsx'; + +const queryClient = new QueryClient({ + defaultOptions: { + queries: { + staleTime: 10 * 1000, + gcTime: 5 * 60 * 1000, + refetchOnWindowFocus: false, + }, + }, +}); + +createRoot(document.getElementById('root')!).render( + + + + + + + , +); diff --git a/apps/web/src/pages/AuthCallback.tsx b/apps/web/src/pages/AuthCallback.tsx new file mode 100644 index 00000000..1476342f --- /dev/null +++ b/apps/web/src/pages/AuthCallback.tsx @@ -0,0 +1,17 @@ +import { useEffect } from 'react'; +import { useNavigate } from 'react-router'; + +export default function AuthCallbackPage() { + const navigate = useNavigate(); + + useEffect(() => { + const timer = window.setTimeout(() => navigate('/', { replace: true }), 300); + return () => window.clearTimeout(timer); + }, [navigate]); + + return ( +
+ 로그인 처리 중... +
+ ); +} diff --git a/apps/web/src/pages/HomePage.tsx b/apps/web/src/pages/HomePage.tsx new file mode 100644 index 00000000..e7d8874a --- /dev/null +++ b/apps/web/src/pages/HomePage.tsx @@ -0,0 +1,255 @@ +import { Link } from 'react-router'; +import { mapApiMatchToMatchDetail } from '../api/mappers'; +import { useMatches, useMe } from '../api/hooks'; +import { DEFAULT_COMMUNITY_ID } from '../config'; + +function StatusBadge({ status }: { status: string }) { + const styles: Record = { + 모집중: 'bg-green-500/15 text-green-500 border-green-500/20', + 팀빌딩: 'bg-amber-500/15 text-amber-500 border-amber-500/20', + 진행중: 'bg-blue-500/15 text-blue-400 border-blue-500/20', + 종료: 'bg-base-content/8 text-base-content/40 border-base-content/10', + }; + + return ( + + {status} + + ); +} + +function MapBadge({ map }: { map: string }) { + return ( + + {map} + + ); +} + +function getStatusLabel(status: string) { + switch (status) { + case 'recruiting': + return '모집중'; + case 'team-built': + return '팀빌딩'; + case 'in-progress': + return '진행중'; + case 'finished': + return '종료'; + default: + return status; + } +} + +export default function HomePage() { + const upcomingMatchesQuery = useMatches({ limit: 20 }, DEFAULT_COMMUNITY_ID); + const finishedMatchesQuery = useMatches( + { status: 'finished', limit: 10 }, + DEFAULT_COMMUNITY_ID, + ); + const meQuery = useMe(); + + if (!DEFAULT_COMMUNITY_ID) { + return ( +
+
+ `apps/web/.env.development`의 `VITE_DEFAULT_COMMUNITY_ID`를 먼저 설정해주세요. +
+
+ ); + } + + if (upcomingMatchesQuery.isLoading || finishedMatchesQuery.isLoading) { + return ( +
+ 매치 목록을 불러오는 중... +
+ ); + } + + if (upcomingMatchesQuery.error || finishedMatchesQuery.error) { + return ( +
+ + 매치 목록을 불러오지 못했습니다. + +
+ ); + } + + const upcomingMatches = + upcomingMatchesQuery.data?.map(mapApiMatchToMatchDetail) ?? []; + const finishedMatches = + finishedMatchesQuery.data?.map(mapApiMatchToMatchDetail) ?? []; + const nextMatch = upcomingMatches[0]; + const upcomingCards = nextMatch ? upcomingMatches.slice(1) : upcomingMatches; + const currentUser = + meQuery.data?.memberships.find( + (membership) => membership.community?._id === DEFAULT_COMMUNITY_ID, + )?.user ?? null; + const canManage = currentUser?.role === 'owner' || currentUser?.role === 'admin'; + + return ( +
+
+
+

+ 다음 내전 +

+
+ {canManage && ( + + 내전 관리 + + )} + + 내전 전적 보기 + +
+
+ + {nextMatch ? ( + +
+
+
+
+
+

+ {nextMatch.title} +

+ +
+

+ {nextMatch.description} +

+
+ {nextMatch.date} {nextMatch.time} + | + + {nextMatch.participants.length}/{nextMatch.maxParticipants}명 + + | + +
+
+
+ + 상세 보기 + +
+
+
+
+ + ) : ( +
+ 아직 등록된 내전이 없습니다. +
+ )} +
+ +
+

+ 예정된 내전 +

+
+ {upcomingCards.length > 0 ? ( + upcomingCards.map((match) => ( + +
+
+

+ {match.title} +

+ +
+
+
{match.date} {match.time}
+
+ {match.participants.length}/{match.maxParticipants}명 +
+
+
+ +
+
+ + )) + ) : ( +
+ 예정된 추가 매치가 없습니다. +
+ )} +
+
+ +
+

+ 지난 내전 기록 +

+
+ + + + + + + + + + + + {finishedMatches.length > 0 ? ( + finishedMatches.map((match) => ( + + + + + + + + )) + ) : ( + + + + )} + +
날짜내전맵참가결과
+ {match.date} + + + {match.title} + + + + + {match.participants.length}명 + + {match.result?.winner ? `${match.result.winner} 승리` : '-'} +
+ 아직 종료된 내전 기록이 없습니다. +
+
+
+
+ ); +} diff --git a/apps/web/src/pages/Login.tsx b/apps/web/src/pages/Login.tsx new file mode 100644 index 00000000..7bbca0e1 --- /dev/null +++ b/apps/web/src/pages/Login.tsx @@ -0,0 +1,47 @@ +import { useMsal } from "@azure/msal-react"; +import { + isMsalConfigured, + MSAL_API_SCOPE, + msalInstance, +} from "../lib/auth/msal.config"; + +function LoginButton() { + const { instance } = useMsal(); + + return ( + + ); +} + +export default function LoginPage() { + return ( +
+
+

로그인

+

+ Entra ID 계정으로 LOLYMPUS 정보를 불러옵니다. +

+
+ {isMsalConfigured && msalInstance ? ( + + ) : ( +
+ MSAL 환경변수 설정이 필요합니다. +
+ )} +
+
+
+ ); +} diff --git a/apps/web/tsconfig.app.json b/apps/web/tsconfig.app.json new file mode 100644 index 00000000..1d29c885 --- /dev/null +++ b/apps/web/tsconfig.app.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "es2023", + "lib": ["ES2023", "DOM", "DOM.Iterable"], + "module": "esnext", + "types": ["vite/client"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"] +} diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json new file mode 100644 index 00000000..1ffef600 --- /dev/null +++ b/apps/web/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" } + ] +} diff --git a/apps/web/tsconfig.node.json b/apps/web/tsconfig.node.json new file mode 100644 index 00000000..d3c52ea6 --- /dev/null +++ b/apps/web/tsconfig.node.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "target": "es2023", + "lib": ["ES2023"], + "module": "esnext", + "types": ["node"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + + /* Linting */ + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["vite.config.ts"] +} diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts new file mode 100644 index 00000000..828a1bc1 --- /dev/null +++ b/apps/web/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; +import tailwindcss from "@tailwindcss/vite"; + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [react(), tailwindcss()], + server: { + host: "0.0.0.0", + allowedHosts: ["126.dahyeon.us"], + }, +});