Compare commits
10 Commits
c5959cfd14
...
renovate/f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b03518291 | ||
| d8fec0e5d7 | |||
| c9b09b8250 | |||
| fde1867863 | |||
| ce9d08963f | |||
| 79cbb06ec9 | |||
| d1ede63256 | |||
| 4d6e1dc5b2 | |||
| aee28cd7a1 | |||
| 3dbc3f35ba |
@@ -1,11 +1,11 @@
|
|||||||
---
|
---
|
||||||
# nuzlocke-tracker-532i
|
# nuzlocke-tracker-532i
|
||||||
title: 'UX: Make level field optional in boss defeat modal'
|
title: 'UX: Make level field optional in boss defeat modal'
|
||||||
status: todo
|
status: completed
|
||||||
type: feature
|
type: feature
|
||||||
priority: normal
|
priority: normal
|
||||||
created_at: 2026-03-21T21:50:48Z
|
created_at: 2026-03-21T21:50:48Z
|
||||||
updated_at: 2026-03-21T22:04:08Z
|
updated_at: 2026-03-22T09:16:12Z
|
||||||
---
|
---
|
||||||
|
|
||||||
## Problem
|
## Problem
|
||||||
@@ -22,8 +22,17 @@ When recording which team members beat a boss, users must manually enter a level
|
|||||||
|
|
||||||
Remove the level field entirely from the UI and make it optional in the backend:
|
Remove the level field entirely from the UI and make it optional in the backend:
|
||||||
|
|
||||||
- [ ] Remove level input from `BossDefeatModal.tsx`
|
- [x] Remove level input from `BossDefeatModal.tsx`
|
||||||
- [ ] Make `level` column nullable in the database (alembic migration)
|
- [x] Make `level` column nullable in the database (alembic migration)
|
||||||
- [ ] Update the API schema to make level optional (default to null)
|
- [x] Update the API schema to make level optional (default to null)
|
||||||
- [ ] Update any backend validation that requires level
|
- [x] Update any backend validation that requires level
|
||||||
- [ ] Verify boss result display still works without level data
|
- [x] Verify boss result display still works without level data
|
||||||
|
|
||||||
|
|
||||||
|
## Summary of Changes
|
||||||
|
|
||||||
|
- Removed level input field from BossDefeatModal.tsx, simplifying team selection to just checkboxes
|
||||||
|
- Created alembic migration to make boss_result_team.level column nullable
|
||||||
|
- Updated SQLAlchemy model and Pydantic schemas to make level optional (defaults to null)
|
||||||
|
- Updated RunEncounters.tsx to conditionally render level only when present
|
||||||
|
- Updated frontend TypeScript types for BossResultTeamMember and BossResultTeamMemberInput
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
---
|
---
|
||||||
# nuzlocke-tracker-lkro
|
# nuzlocke-tracker-lkro
|
||||||
title: 'UX: Make team section a floating sidebar on desktop'
|
title: 'UX: Make team section a floating sidebar on desktop'
|
||||||
status: todo
|
status: completed
|
||||||
type: feature
|
type: feature
|
||||||
priority: normal
|
priority: normal
|
||||||
created_at: 2026-03-21T21:50:48Z
|
created_at: 2026-03-21T21:50:48Z
|
||||||
updated_at: 2026-03-22T08:08:13Z
|
updated_at: 2026-03-22T09:11:58Z
|
||||||
---
|
---
|
||||||
|
|
||||||
## Problem
|
## Problem
|
||||||
@@ -28,9 +28,31 @@ Alternative: A floating action button (FAB) that opens the team in a slide-over
|
|||||||
|
|
||||||
## Checklist
|
## Checklist
|
||||||
|
|
||||||
- [ ] Add responsive 2-column layout to RunEncounters page (desktop only)
|
- [x] Add responsive 2-column layout to RunEncounters page (desktop only)
|
||||||
- [ ] Move team section into a sticky sidebar column
|
- [x] Move team section into a sticky sidebar column
|
||||||
- [ ] Ensure sidebar scrolls independently if team is taller than viewport
|
- [x] Ensure sidebar scrolls independently if team is taller than viewport
|
||||||
- [ ] Keep current stacked layout on mobile/tablet
|
- [x] Keep current stacked layout on mobile/tablet
|
||||||
- [ ] Test with various team sizes (0-6 pokemon)
|
- [x] Test with various team sizes (0-6 pokemon)
|
||||||
- [ ] Test evolution/nickname editing still works from sidebar
|
- [x] Test evolution/nickname editing still works from sidebar
|
||||||
|
|
||||||
|
## Summary of Changes
|
||||||
|
|
||||||
|
Implemented a responsive 2-column layout for the RunEncounters page:
|
||||||
|
|
||||||
|
**Desktop (lg, ≥1024px):**
|
||||||
|
- Encounters list on the left in a flex column
|
||||||
|
- Team section in a 256px sticky sidebar on the right
|
||||||
|
- Sidebar stays visible while scrolling through routes and bosses
|
||||||
|
- Independent scrolling for sidebar when team is taller than viewport (max-h-[calc(100vh-6rem)] overflow-y-auto)
|
||||||
|
- 2-column grid for pokemon cards in sidebar
|
||||||
|
|
||||||
|
**Mobile/Tablet (<1024px):**
|
||||||
|
- Original stacked layout preserved (team above encounters)
|
||||||
|
- Collapsible team section with expand/collapse toggle
|
||||||
|
|
||||||
|
**Technical changes:**
|
||||||
|
- Page container widened from max-w-4xl to lg:max-w-6xl
|
||||||
|
- Added lg:flex lg:gap-6 wrapper for 2-column layout
|
||||||
|
- Mobile team section hidden on lg with lg:hidden
|
||||||
|
- Desktop sidebar hidden below lg with hidden lg:block
|
||||||
|
- Sidebar styled with bg-surface-1 border and rounded corners
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ status: completed
|
|||||||
type: bug
|
type: bug
|
||||||
priority: normal
|
priority: normal
|
||||||
created_at: 2026-03-22T10:51:30Z
|
created_at: 2026-03-22T10:51:30Z
|
||||||
updated_at: 2026-03-22T10:52:46Z
|
updated_at: 2026-03-22T10:59:46Z
|
||||||
---
|
---
|
||||||
|
|
||||||
Backend JWKS verification only accepts RS256 algorithm, but Supabase JWT key was switched to ECC P-256 (ES256). This causes 401 errors on all authenticated requests. Fix: accept both RS256 and ES256 in the algorithms list, and update tests accordingly.
|
Backend JWKS verification only accepts RS256 algorithm, but Supabase JWT key was switched to ECC P-256 (ES256). This causes 401 errors on all authenticated requests. Fix: accept both RS256 and ES256 in the algorithms list, and update tests accordingly.
|
||||||
|
|
||||||
## Summary of Changes\n\nAdded ES256 to the accepted JWT algorithms in `_verify_jwt()` so ECC P-256 keys from Supabase are verified correctly alongside RSA keys. Added corresponding test with EC key fixtures.
|
## Summary of Changes\n\nAdded ES256 to the accepted JWT algorithms in `_verify_jwt()` so ECC P-256 keys from Supabase are verified correctly alongside RSA keys. Added corresponding test with EC key fixtures.
|
||||||
|
|
||||||
|
Deployed to production via PR #86 merge on 2026-03-22.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ description = "Backend API for Another Nuzlocke Tracker"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.14"
|
requires-python = ">=3.14"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastapi==0.135.1",
|
"fastapi==0.135.3",
|
||||||
"uvicorn[standard]==0.42.0",
|
"uvicorn[standard]==0.42.0",
|
||||||
"pydantic==2.12.5",
|
"pydantic==2.12.5",
|
||||||
"pydantic-settings==2.13.1",
|
"pydantic-settings==2.13.1",
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
"""make_boss_result_team_level_nullable
|
||||||
|
|
||||||
|
Revision ID: 903e0cdbfe5a
|
||||||
|
Revises: p7e8f9a0b1c2
|
||||||
|
Create Date: 2026-03-22 10:13:41.828406
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from collections.abc import Sequence
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "903e0cdbfe5a"
|
||||||
|
down_revision: str | Sequence[str] | None = "p7e8f9a0b1c2"
|
||||||
|
branch_labels: str | Sequence[str] | None = None
|
||||||
|
depends_on: str | Sequence[str] | None = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
op.alter_column(
|
||||||
|
"boss_result_team",
|
||||||
|
"level",
|
||||||
|
existing_type=sa.SmallInteger(),
|
||||||
|
nullable=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
op.execute("UPDATE boss_result_team SET level = 1 WHERE level IS NULL")
|
||||||
|
op.alter_column(
|
||||||
|
"boss_result_team",
|
||||||
|
"level",
|
||||||
|
existing_type=sa.SmallInteger(),
|
||||||
|
nullable=False,
|
||||||
|
)
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
from fastapi import APIRouter
|
import urllib.request
|
||||||
|
|
||||||
|
from fastapi import APIRouter, Request
|
||||||
from sqlalchemy import text
|
from sqlalchemy import text
|
||||||
|
|
||||||
|
from app.core.auth import _build_jwks_url, _extract_token, _get_jwks_client
|
||||||
|
from app.core.config import settings
|
||||||
from app.core.database import async_session
|
from app.core.database import async_session
|
||||||
|
|
||||||
router = APIRouter(tags=["health"])
|
router = APIRouter(tags=["health"])
|
||||||
@@ -23,3 +27,45 @@ async def health_check():
|
|||||||
async def root():
|
async def root():
|
||||||
"""Root endpoint."""
|
"""Root endpoint."""
|
||||||
return {"message": "Nuzlocke Tracker API", "docs": "/docs"}
|
return {"message": "Nuzlocke Tracker API", "docs": "/docs"}
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/auth-debug")
|
||||||
|
async def auth_debug(request: Request):
|
||||||
|
"""Temporary diagnostic endpoint for auth debugging."""
|
||||||
|
result: dict = {}
|
||||||
|
|
||||||
|
# Config
|
||||||
|
result["supabase_url"] = settings.supabase_url
|
||||||
|
result["has_jwt_secret"] = bool(settings.supabase_jwt_secret)
|
||||||
|
result["jwks_url"] = (
|
||||||
|
_build_jwks_url(settings.supabase_url) if settings.supabase_url else None
|
||||||
|
)
|
||||||
|
|
||||||
|
# JWKS fetch
|
||||||
|
jwks_url = result["jwks_url"]
|
||||||
|
if jwks_url:
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(jwks_url, timeout=5) as resp:
|
||||||
|
result["jwks_status"] = resp.status
|
||||||
|
result["jwks_body"] = resp.read().decode()
|
||||||
|
except Exception as e:
|
||||||
|
result["jwks_fetch_error"] = str(e)
|
||||||
|
|
||||||
|
# JWKS client
|
||||||
|
client = _get_jwks_client()
|
||||||
|
result["jwks_client_exists"] = client is not None
|
||||||
|
|
||||||
|
# Token info (header only, no secrets)
|
||||||
|
token = _extract_token(request)
|
||||||
|
if token:
|
||||||
|
import jwt
|
||||||
|
|
||||||
|
try:
|
||||||
|
header = jwt.get_unverified_header(token)
|
||||||
|
result["token_header"] = header
|
||||||
|
except Exception as e:
|
||||||
|
result["token_header_error"] = str(e)
|
||||||
|
else:
|
||||||
|
result["token"] = "not provided"
|
||||||
|
|
||||||
|
return result
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import logging
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ from app.core.database import get_session
|
|||||||
from app.models.nuzlocke_run import NuzlockeRun
|
from app.models.nuzlocke_run import NuzlockeRun
|
||||||
from app.models.user import User
|
from app.models.user import User
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
_jwks_client: PyJWKClient | None = None
|
_jwks_client: PyJWKClient | None = None
|
||||||
|
|
||||||
|
|
||||||
@@ -24,11 +26,21 @@ class AuthUser:
|
|||||||
role: str | None = None
|
role: str | None = None
|
||||||
|
|
||||||
|
|
||||||
|
def _build_jwks_url(base_url: str) -> str:
|
||||||
|
"""Build the JWKS URL, adding /auth/v1 prefix for Supabase Cloud."""
|
||||||
|
base = base_url.rstrip("/")
|
||||||
|
if "/auth/v1" in base:
|
||||||
|
return f"{base}/.well-known/jwks.json"
|
||||||
|
# Supabase Cloud URLs need the /auth/v1 prefix;
|
||||||
|
# local GoTrue serves JWKS at root but uses HS256 fallback anyway.
|
||||||
|
return f"{base}/auth/v1/.well-known/jwks.json"
|
||||||
|
|
||||||
|
|
||||||
def _get_jwks_client() -> PyJWKClient | None:
|
def _get_jwks_client() -> PyJWKClient | None:
|
||||||
"""Get or create a cached JWKS client."""
|
"""Get or create a cached JWKS client."""
|
||||||
global _jwks_client
|
global _jwks_client
|
||||||
if _jwks_client is None and settings.supabase_url:
|
if _jwks_client is None and settings.supabase_url:
|
||||||
jwks_url = f"{settings.supabase_url.rstrip('/')}/.well-known/jwks.json"
|
jwks_url = _build_jwks_url(settings.supabase_url)
|
||||||
_jwks_client = PyJWKClient(jwks_url, cache_jwk_set=True, lifespan=300)
|
_jwks_client = PyJWKClient(jwks_url, cache_jwk_set=True, lifespan=300)
|
||||||
return _jwks_client
|
return _jwks_client
|
||||||
|
|
||||||
@@ -71,12 +83,14 @@ def _verify_jwt(token: str) -> dict | None:
|
|||||||
algorithms=["RS256", "ES256"],
|
algorithms=["RS256", "ES256"],
|
||||||
audience="authenticated",
|
audience="authenticated",
|
||||||
)
|
)
|
||||||
except jwt.InvalidTokenError:
|
except jwt.InvalidTokenError as e:
|
||||||
pass
|
logger.warning("JWKS JWT validation failed: %s", e)
|
||||||
except PyJWKClientError:
|
except PyJWKClientError as e:
|
||||||
pass
|
logger.warning("JWKS client error: %s", e)
|
||||||
except PyJWKSetError:
|
except PyJWKSetError as e:
|
||||||
pass
|
logger.warning("JWKS set error: %s", e)
|
||||||
|
else:
|
||||||
|
logger.warning("No JWKS client available (SUPABASE_URL not set?)")
|
||||||
return _verify_jwt_hs256(token)
|
return _verify_jwt_hs256(token)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class BossResultTeam(Base):
|
|||||||
encounter_id: Mapped[int] = mapped_column(
|
encounter_id: Mapped[int] = mapped_column(
|
||||||
ForeignKey("encounters.id", ondelete="CASCADE"), index=True
|
ForeignKey("encounters.id", ondelete="CASCADE"), index=True
|
||||||
)
|
)
|
||||||
level: Mapped[int] = mapped_column(SmallInteger)
|
level: Mapped[int | None] = mapped_column(SmallInteger, nullable=True)
|
||||||
|
|
||||||
boss_result: Mapped[BossResult] = relationship(back_populates="team")
|
boss_result: Mapped[BossResult] = relationship(back_populates="team")
|
||||||
encounter: Mapped[Encounter] = relationship()
|
encounter: Mapped[Encounter] = relationship()
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class BossBattleResponse(CamelModel):
|
|||||||
class BossResultTeamMemberResponse(CamelModel):
|
class BossResultTeamMemberResponse(CamelModel):
|
||||||
id: int
|
id: int
|
||||||
encounter_id: int
|
encounter_id: int
|
||||||
level: int
|
level: int | None
|
||||||
|
|
||||||
|
|
||||||
class BossResultResponse(CamelModel):
|
class BossResultResponse(CamelModel):
|
||||||
@@ -120,7 +120,7 @@ class BossPokemonInput(CamelModel):
|
|||||||
|
|
||||||
class BossResultTeamMemberInput(CamelModel):
|
class BossResultTeamMemberInput(CamelModel):
|
||||||
encounter_id: int
|
encounter_id: int
|
||||||
level: int
|
level: int | None = None
|
||||||
|
|
||||||
|
|
||||||
class BossResultCreate(CamelModel):
|
class BossResultCreate(CamelModel):
|
||||||
|
|||||||
8
backend/uv.lock
generated
8
backend/uv.lock
generated
@@ -65,7 +65,7 @@ requires-dist = [
|
|||||||
{ name = "alembic", specifier = "==1.18.4" },
|
{ name = "alembic", specifier = "==1.18.4" },
|
||||||
{ name = "asyncpg", specifier = "==0.31.0" },
|
{ name = "asyncpg", specifier = "==0.31.0" },
|
||||||
{ name = "cryptography", specifier = "==45.0.3" },
|
{ name = "cryptography", specifier = "==45.0.3" },
|
||||||
{ name = "fastapi", specifier = "==0.135.1" },
|
{ name = "fastapi", specifier = "==0.135.3" },
|
||||||
{ name = "httpx", marker = "extra == 'dev'", specifier = "==0.28.1" },
|
{ name = "httpx", marker = "extra == 'dev'", specifier = "==0.28.1" },
|
||||||
{ name = "pydantic", specifier = "==2.12.5" },
|
{ name = "pydantic", specifier = "==2.12.5" },
|
||||||
{ name = "pydantic-settings", specifier = "==2.13.1" },
|
{ name = "pydantic-settings", specifier = "==2.13.1" },
|
||||||
@@ -216,7 +216,7 @@ wheels = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastapi"
|
name = "fastapi"
|
||||||
version = "0.135.1"
|
version = "0.135.3"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "annotated-doc" },
|
{ name = "annotated-doc" },
|
||||||
@@ -225,9 +225,9 @@ dependencies = [
|
|||||||
{ name = "typing-extensions" },
|
{ name = "typing-extensions" },
|
||||||
{ name = "typing-inspection" },
|
{ name = "typing-inspection" },
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/e7/7b/f8e0211e9380f7195ba3f3d40c292594fd81ba8ec4629e3854c353aaca45/fastapi-0.135.1.tar.gz", hash = "sha256:d04115b508d936d254cea545b7312ecaa58a7b3a0f84952535b4c9afae7668cd", size = 394962, upload-time = "2026-03-01T18:18:29.369Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/f7/e6/7adb4c5fa231e82c35b8f5741a9f2d055f520c29af5546fd70d3e8e1cd2e/fastapi-0.135.3.tar.gz", hash = "sha256:bd6d7caf1a2bdd8d676843cdcd2287729572a1ef524fc4d65c17ae002a1be654", size = 396524, upload-time = "2026-04-01T16:23:58.188Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/e4/72/42e900510195b23a56bde950d26a51f8b723846bfcaa0286e90287f0422b/fastapi-0.135.1-py3-none-any.whl", hash = "sha256:46e2fc5745924b7c840f71ddd277382af29ce1cdb7d5eab5bf697e3fb9999c9e", size = 116999, upload-time = "2026-03-01T18:18:30.831Z" },
|
{ url = "https://files.pythonhosted.org/packages/84/a4/5caa2de7f917a04ada20018eccf60d6cc6145b0199d55ca3711b0fc08312/fastapi-0.135.3-py3-none-any.whl", hash = "sha256:9b0f590c813acd13d0ab43dd8494138eb58e484bfac405db1f3187cfc5810d98", size = 117734, upload-time = "2026-04-01T16:23:59.328Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ function matchVariant(labels: string[], starterName?: string | null): string | n
|
|||||||
return matches.length === 1 ? (matches[0] ?? null) : null
|
return matches.length === 1 ? (matches[0] ?? null) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TeamSelection {
|
type TeamSelection = number
|
||||||
encounterId: number
|
|
||||||
level: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export function BossDefeatModal({
|
export function BossDefeatModal({
|
||||||
boss,
|
boss,
|
||||||
@@ -36,26 +33,15 @@ export function BossDefeatModal({
|
|||||||
isPending,
|
isPending,
|
||||||
starterName,
|
starterName,
|
||||||
}: BossDefeatModalProps) {
|
}: BossDefeatModalProps) {
|
||||||
const [selectedTeam, setSelectedTeam] = useState<Map<number, TeamSelection>>(new Map())
|
const [selectedTeam, setSelectedTeam] = useState<Set<TeamSelection>>(new Set())
|
||||||
|
|
||||||
const toggleTeamMember = (enc: EncounterDetail) => {
|
const toggleTeamMember = (encounterId: number) => {
|
||||||
setSelectedTeam((prev) => {
|
setSelectedTeam((prev) => {
|
||||||
const next = new Map(prev)
|
const next = new Set(prev)
|
||||||
if (next.has(enc.id)) {
|
if (next.has(encounterId)) {
|
||||||
next.delete(enc.id)
|
next.delete(encounterId)
|
||||||
} else {
|
} else {
|
||||||
next.set(enc.id, { encounterId: enc.id, level: enc.catchLevel ?? 1 })
|
next.add(encounterId)
|
||||||
}
|
|
||||||
return next
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateLevel = (encounterId: number, level: number) => {
|
|
||||||
setSelectedTeam((prev) => {
|
|
||||||
const next = new Map(prev)
|
|
||||||
const existing = next.get(encounterId)
|
|
||||||
if (existing) {
|
|
||||||
next.set(encounterId, { ...existing, level })
|
|
||||||
}
|
}
|
||||||
return next
|
return next
|
||||||
})
|
})
|
||||||
@@ -87,7 +73,9 @@ export function BossDefeatModal({
|
|||||||
|
|
||||||
const handleSubmit = (e: FormEvent) => {
|
const handleSubmit = (e: FormEvent) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const team: BossResultTeamMemberInput[] = Array.from(selectedTeam.values())
|
const team: BossResultTeamMemberInput[] = Array.from(selectedTeam).map((encounterId) => ({
|
||||||
|
encounterId,
|
||||||
|
}))
|
||||||
onSubmit({
|
onSubmit({
|
||||||
bossBattleId: boss.id,
|
bossBattleId: boss.id,
|
||||||
result: 'won',
|
result: 'won',
|
||||||
@@ -134,11 +122,17 @@ export function BossDefeatModal({
|
|||||||
return (
|
return (
|
||||||
<div key={bp.id} className="flex flex-col items-center">
|
<div key={bp.id} className="flex flex-col items-center">
|
||||||
{bp.pokemon.spriteUrl ? (
|
{bp.pokemon.spriteUrl ? (
|
||||||
<img src={bp.pokemon.spriteUrl} alt={bp.pokemon.name} className="w-10 h-10" />
|
<img
|
||||||
|
src={bp.pokemon.spriteUrl}
|
||||||
|
alt={bp.pokemon.name}
|
||||||
|
className="w-10 h-10"
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="w-10 h-10 bg-surface-3 rounded-full" />
|
<div className="w-10 h-10 bg-surface-3 rounded-full" />
|
||||||
)}
|
)}
|
||||||
<span className="text-xs text-text-tertiary capitalize">{bp.pokemon.name}</span>
|
<span className="text-xs text-text-tertiary capitalize">
|
||||||
|
{bp.pokemon.name}
|
||||||
|
</span>
|
||||||
<span className="text-xs font-medium text-text-secondary">Lv.{bp.level}</span>
|
<span className="text-xs font-medium text-text-secondary">Lv.{bp.level}</span>
|
||||||
<ConditionBadge condition={bp.conditionLabel} size="xs" />
|
<ConditionBadge condition={bp.conditionLabel} size="xs" />
|
||||||
{bp.ability && (
|
{bp.ability && (
|
||||||
@@ -166,7 +160,6 @@ export function BossDefeatModal({
|
|||||||
<div className="grid grid-cols-2 sm:grid-cols-3 gap-2 max-h-48 overflow-y-auto">
|
<div className="grid grid-cols-2 sm:grid-cols-3 gap-2 max-h-48 overflow-y-auto">
|
||||||
{aliveEncounters.map((enc) => {
|
{aliveEncounters.map((enc) => {
|
||||||
const isSelected = selectedTeam.has(enc.id)
|
const isSelected = selectedTeam.has(enc.id)
|
||||||
const selection = selectedTeam.get(enc.id)
|
|
||||||
const displayPokemon = enc.currentPokemon ?? enc.pokemon
|
const displayPokemon = enc.currentPokemon ?? enc.pokemon
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -176,12 +169,12 @@ export function BossDefeatModal({
|
|||||||
? 'border-accent-500 bg-accent-500/10'
|
? 'border-accent-500 bg-accent-500/10'
|
||||||
: 'border-border-default hover:bg-surface-2'
|
: 'border-border-default hover:bg-surface-2'
|
||||||
}`}
|
}`}
|
||||||
onClick={() => toggleTeamMember(enc)}
|
onClick={() => toggleTeamMember(enc.id)}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={isSelected}
|
checked={isSelected}
|
||||||
onChange={() => toggleTeamMember(enc)}
|
onChange={() => toggleTeamMember(enc.id)}
|
||||||
className="sr-only"
|
className="sr-only"
|
||||||
/>
|
/>
|
||||||
{displayPokemon.spriteUrl ? (
|
{displayPokemon.spriteUrl ? (
|
||||||
@@ -193,26 +186,9 @@ export function BossDefeatModal({
|
|||||||
) : (
|
) : (
|
||||||
<div className="w-8 h-8 bg-surface-3 rounded-full" />
|
<div className="w-8 h-8 bg-surface-3 rounded-full" />
|
||||||
)}
|
)}
|
||||||
<div className="flex-1 min-w-0">
|
<p className="flex-1 min-w-0 text-xs font-medium truncate">
|
||||||
<p className="text-xs font-medium truncate">
|
|
||||||
{enc.nickname ?? displayPokemon.name}
|
{enc.nickname ?? displayPokemon.name}
|
||||||
</p>
|
</p>
|
||||||
{isSelected && (
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
min={1}
|
|
||||||
max={100}
|
|
||||||
value={selection?.level ?? enc.catchLevel ?? 1}
|
|
||||||
onChange={(e) => {
|
|
||||||
e.stopPropagation()
|
|
||||||
updateLevel(enc.id, Number.parseInt(e.target.value, 10) || 1)
|
|
||||||
}}
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
className="w-14 text-xs px-1 py-0.5 mt-1 rounded border border-border-default bg-surface-1"
|
|
||||||
placeholder="Lv"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -922,7 +922,7 @@ export function RunEncounters() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-4xl mx-auto p-8">
|
<div className="max-w-4xl lg:max-w-6xl mx-auto p-8">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<Link
|
<Link
|
||||||
@@ -1246,9 +1246,12 @@ export function RunEncounters() {
|
|||||||
{/* Encounters Tab */}
|
{/* Encounters Tab */}
|
||||||
{activeTab === 'encounters' && (
|
{activeTab === 'encounters' && (
|
||||||
<>
|
<>
|
||||||
{/* Team Section */}
|
<div className="lg:flex lg:gap-6">
|
||||||
|
{/* Main content column */}
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
{/* Team Section - Mobile/Tablet only */}
|
||||||
{(alive.length > 0 || dead.length > 0) && (
|
{(alive.length > 0 || dead.length > 0) && (
|
||||||
<div className="mb-6">
|
<div className="mb-6 lg:hidden">
|
||||||
<div className="flex items-center justify-between mb-3">
|
<div className="flex items-center justify-between mb-3">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -1298,7 +1301,9 @@ export function RunEncounters() {
|
|||||||
key={enc.id}
|
key={enc.id}
|
||||||
encounter={enc}
|
encounter={enc}
|
||||||
onClick={
|
onClick={
|
||||||
isActive && canEdit ? () => setSelectedTeamEncounter(enc) : undefined
|
isActive && canEdit
|
||||||
|
? () => setSelectedTeamEncounter(enc)
|
||||||
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@@ -1314,7 +1319,9 @@ export function RunEncounters() {
|
|||||||
encounter={enc}
|
encounter={enc}
|
||||||
showFaintLevel
|
showFaintLevel
|
||||||
onClick={
|
onClick={
|
||||||
isActive && canEdit ? () => setSelectedTeamEncounter(enc) : undefined
|
isActive && canEdit
|
||||||
|
? () => setSelectedTeamEncounter(enc)
|
||||||
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@@ -1347,7 +1354,9 @@ export function RunEncounters() {
|
|||||||
<PokemonCard
|
<PokemonCard
|
||||||
key={enc.id}
|
key={enc.id}
|
||||||
encounter={enc}
|
encounter={enc}
|
||||||
onClick={isActive && canEdit ? () => setSelectedTeamEncounter(enc) : undefined}
|
onClick={
|
||||||
|
isActive && canEdit ? () => setSelectedTeamEncounter(enc) : undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -1472,7 +1481,9 @@ export function RunEncounters() {
|
|||||||
>
|
>
|
||||||
<span className={`w-2.5 h-2.5 rounded-full shrink-0 ${si.dot}`} />
|
<span className={`w-2.5 h-2.5 rounded-full shrink-0 ${si.dot}`} />
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<div className="text-sm font-medium text-text-primary">{route.name}</div>
|
<div className="text-sm font-medium text-text-primary">
|
||||||
|
{route.name}
|
||||||
|
</div>
|
||||||
{encounter ? (
|
{encounter ? (
|
||||||
<div className="flex items-center gap-2 mt-0.5">
|
<div className="flex items-center gap-2 mt-0.5">
|
||||||
{encounter.pokemon.spriteUrl && (
|
{encounter.pokemon.spriteUrl && (
|
||||||
@@ -1486,7 +1497,9 @@ export function RunEncounters() {
|
|||||||
{encounter.nickname ?? encounter.pokemon.name}
|
{encounter.nickname ?? encounter.pokemon.name}
|
||||||
{encounter.status === 'caught' &&
|
{encounter.status === 'caught' &&
|
||||||
encounter.faintLevel !== null &&
|
encounter.faintLevel !== null &&
|
||||||
(encounter.deathCause ? ` — ${encounter.deathCause}` : ' (dead)')}
|
(encounter.deathCause
|
||||||
|
? ` — ${encounter.deathCause}`
|
||||||
|
: ' (dead)')}
|
||||||
</span>
|
</span>
|
||||||
{giftEncounter && (
|
{giftEncounter && (
|
||||||
<>
|
<>
|
||||||
@@ -1598,7 +1611,11 @@ export function RunEncounters() {
|
|||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
{boss.spriteUrl && (
|
{boss.spriteUrl && (
|
||||||
<img src={boss.spriteUrl} alt={boss.name} className="h-10 w-auto" />
|
<img
|
||||||
|
src={boss.spriteUrl}
|
||||||
|
alt={boss.name}
|
||||||
|
className="h-10 w-auto"
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@@ -1608,7 +1625,9 @@ export function RunEncounters() {
|
|||||||
<span className="px-2 py-0.5 text-xs font-medium rounded-full bg-surface-2 text-text-secondary">
|
<span className="px-2 py-0.5 text-xs font-medium rounded-full bg-surface-2 text-text-secondary">
|
||||||
{bossTypeLabel[boss.bossType] ?? boss.bossType}
|
{bossTypeLabel[boss.bossType] ?? boss.bossType}
|
||||||
</span>
|
</span>
|
||||||
{boss.specialtyType && <TypeBadge type={boss.specialtyType} />}
|
{boss.specialtyType && (
|
||||||
|
<TypeBadge type={boss.specialtyType} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-text-tertiary">
|
<p className="text-xs text-text-tertiary">
|
||||||
{boss.location} · Level Cap: {boss.levelCap}
|
{boss.location} · Level Cap: {boss.levelCap}
|
||||||
@@ -1663,9 +1682,11 @@ export function RunEncounters() {
|
|||||||
<span className="text-[10px] text-text-tertiary capitalize">
|
<span className="text-[10px] text-text-tertiary capitalize">
|
||||||
{enc.nickname ?? dp.name}
|
{enc.nickname ?? dp.name}
|
||||||
</span>
|
</span>
|
||||||
|
{tm.level != null && (
|
||||||
<span className="text-[10px] text-text-muted">
|
<span className="text-[10px] text-text-muted">
|
||||||
Lv.{tm.level}
|
Lv.{tm.level}
|
||||||
</span>
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
@@ -1690,6 +1711,70 @@ export function RunEncounters() {
|
|||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Team Sidebar - Desktop only */}
|
||||||
|
{(alive.length > 0 || dead.length > 0) && (
|
||||||
|
<div className="hidden lg:block w-64 shrink-0">
|
||||||
|
<div className="sticky top-20 max-h-[calc(100vh-6rem)] overflow-y-auto">
|
||||||
|
<div className="bg-surface-1 border border-border-default rounded-lg p-4">
|
||||||
|
<div className="flex items-center justify-between mb-3">
|
||||||
|
<h2 className="text-lg font-semibold text-text-primary">
|
||||||
|
{isActive ? 'Team' : 'Final Team'}
|
||||||
|
</h2>
|
||||||
|
<span className="text-xs text-text-muted">
|
||||||
|
{alive.length}/{alive.length + dead.length}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{alive.length > 1 && (
|
||||||
|
<select
|
||||||
|
value={teamSort}
|
||||||
|
onChange={(e) => setTeamSort(e.target.value as TeamSortKey)}
|
||||||
|
className="w-full text-sm border border-border-default rounded-lg px-3 py-1.5 bg-surface-0 text-text-primary mb-3"
|
||||||
|
>
|
||||||
|
<option value="route">Route Order</option>
|
||||||
|
<option value="level">Catch Level</option>
|
||||||
|
<option value="species">Species Name</option>
|
||||||
|
<option value="dex">National Dex</option>
|
||||||
|
</select>
|
||||||
|
)}
|
||||||
|
{alive.length > 0 && (
|
||||||
|
<div className="grid grid-cols-2 gap-2 mb-3">
|
||||||
|
{alive.map((enc) => (
|
||||||
|
<PokemonCard
|
||||||
|
key={enc.id}
|
||||||
|
encounter={enc}
|
||||||
|
onClick={
|
||||||
|
isActive && canEdit ? () => setSelectedTeamEncounter(enc) : undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{dead.length > 0 && (
|
||||||
|
<>
|
||||||
|
<h3 className="text-sm font-medium text-text-tertiary mb-2">Graveyard</h3>
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
{dead.map((enc) => (
|
||||||
|
<PokemonCard
|
||||||
|
key={enc.id}
|
||||||
|
encounter={enc}
|
||||||
|
showFaintLevel
|
||||||
|
onClick={
|
||||||
|
isActive && canEdit
|
||||||
|
? () => setSelectedTeamEncounter(enc)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Encounter Modal */}
|
{/* Encounter Modal */}
|
||||||
{selectedRoute && (
|
{selectedRoute && (
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ export interface BossBattle {
|
|||||||
export interface BossResultTeamMember {
|
export interface BossResultTeamMember {
|
||||||
id: number
|
id: number
|
||||||
encounterId: number
|
encounterId: number
|
||||||
level: number
|
level: number | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BossResult {
|
export interface BossResult {
|
||||||
@@ -253,7 +253,7 @@ export interface BossResult {
|
|||||||
|
|
||||||
export interface BossResultTeamMemberInput {
|
export interface BossResultTeamMemberInput {
|
||||||
encounterId: number
|
encounterId: number
|
||||||
level: number
|
level?: number | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateBossResultInput {
|
export interface CreateBossResultInput {
|
||||||
|
|||||||
Reference in New Issue
Block a user