refactor(soccer-app): extract team query logic into reusable utility - #25
Open
ayushtr-aws wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Task-Id: 01KZP23QXZP7SGBY0ZRGZF4EKY Prompt-Version: 1c9c10e027a2
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extracts the team search and sorting logic from
soccer-app/src/App.tsxinto a new reusable utility modulesoccer-app/src/utils/teamQuery.ts(TG-4).The new module exposes:
SortKeytype —"points" | "goals" | "name" | "league"(moved fromApp.tsx)matchesSearch(team, searchQuery)— case-insensitive match against team name, league and countrycompareTeams(a, b, sortKey)— the sort comparator (points/goals descending, name/league ascending)queryTeams(teams, searchQuery, sortKey)— filters then sorts, returning a new arrayApp.tsxnow importsqueryTeamsandSortKeyand callsqueryTeams(teams, searchQuery, sortKey)in place of the inline filter/sort chain. Behavior and UI are unchanged — same filtering fields, same sort keys and directions.Decisions
SortKeytype from the utility module so it remains the single source of truth shared byApp.tsx; this matches the shared orchestration context's field/shape names (points,goals,name,league).Build & test results
mise run build(tsc -b && vite build) → passed (built in ~161ms, 21 modules transformed).mise run lint(oxlint) → passed, no findings.node_moduleswas not present initially andtscwas missing; rannpm installinsoccer-app, after which build and lint succeeded.Agent notes
mise run buildfailed withtsc: not foundbecausesoccer-app/node_moduleswas absent; runningnpm installinsidesoccer-appresolved it. Future tasks on this repo should ensure dependencies are installed insoccer-app/(not the repo root).soccer-app/; mise tasks (build,lint,dev) proxy to npm scripts run in that dir. Linter isoxlint. Data/types live insrc/data/teams.ts.teamQuery.ts(no test runner is configured yet). Sibling epic sub-issues can now importqueryTeams/matchesSearch/compareTeamsrather than duplicating logic.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.
🤖 Generated with Claude Code