Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | <template> <div> <!-- Header --> <div class="mb-6"> <h2 class="text-lg font-semibold text-fg">Quality of Play Rankings</h2> <p class="text-sm text-fg-muted mt-1"> Homegrown · Updated weekly by MLS Next </p> </div> <!-- Filters --> <div class="mb-6 space-y-3"> <!-- Division --> <div> <h3 class="text-sm font-medium text-fg mb-2">Division</h3> <div class="flex flex-wrap gap-2"> <button v-for="div in homegrownDivisions" :key="div.id" @click="selectedDivisionId = div.id" :class="[ 'px-4 py-2 text-sm rounded-lg font-medium transition-colors', selectedDivisionId === div.id ? 'bg-brand-500 text-white shadow-sm' : 'bg-surface-alt text-fg-muted hover:bg-line', ]" > {{ div.name }} </button> </div> </div> <!-- Age Group --> <div> <h3 class="text-sm font-medium text-fg mb-2">Age Group</h3> <div class="flex flex-wrap gap-2"> <button v-for="ag in qopAgeGroups" :key="ag.id" @click="selectedAgeGroupId = ag.id" :class="[ 'px-4 py-2 text-sm rounded-lg font-medium transition-colors', selectedAgeGroupId === ag.id ? 'bg-brand-500 text-white shadow-sm' : 'bg-surface-alt text-fg-muted hover:bg-line', ]" > {{ ag.name }} </button> </div> </div> </div> <!-- Loading --> <div v-if="loading" class="text-center py-8 text-fg-muted"> Loading QoP rankings... </div> <!-- Error --> <div v-else-if="error" class="text-center py-8 text-red-600"> {{ error }} </div> <!-- No data --> <div v-else-if="!rankings.length" class="text-center py-8 text-fg-muted"> No QoP rankings available yet for this age group. </div> <!-- Rankings Table --> <div v-else class="overflow-x-auto"> <div v-if="weekOf" class="flex items-center gap-2 text-xs text-fg-muted mb-2" > <button v-if="prevSnapshotId != null" type="button" @click="goToSnapshot(prevSnapshotId)" :disabled="loading" class="px-2 py-0.5 rounded hover:bg-surface-alt text-fg-muted disabled:opacity-50 disabled:cursor-not-allowed" :title="`Previous week${priorWeekOf ? ' (' + priorWeekOf + ')' : ''}`" aria-label="Previous snapshot" > ◀ </button> <span> Week of {{ weekOf }}<span v-if="priorWeekOf"> · Prior week: {{ priorWeekOf }}</span > </span> <button v-if="nextSnapshotId != null" type="button" @click="goToSnapshot(nextSnapshotId)" :disabled="loading" class="px-2 py-0.5 rounded hover:bg-surface-alt text-fg-muted disabled:opacity-50 disabled:cursor-not-allowed" title="Next week" aria-label="Next snapshot" > ▶ </button> </div> <table class="min-w-full divide-y divide-line"> <thead class="bg-brand-500"> <tr> <th class="px-3 py-3 text-left text-xs font-semibold text-slate-300 uppercase tracking-wider" title="Rank" > # </th> <th class="px-3 py-3 text-center text-xs font-semibold text-slate-300 uppercase tracking-wider" title="Rank change from prior week" > +/- </th> <th class="px-4 py-3 text-left text-xs font-semibold text-slate-300 uppercase tracking-wider" > Team </th> <th class="px-4 py-3 text-center text-xs font-semibold text-slate-300 uppercase tracking-wider" title="Matches Played" > MP </th> <th class="hidden sm:table-cell px-4 py-3 text-center text-xs font-semibold text-slate-300 uppercase tracking-wider" title="Attacking Score" > ATT </th> <th class="hidden sm:table-cell px-4 py-3 text-center text-xs font-semibold text-slate-300 uppercase tracking-wider" title="Defensive Score" > DEF </th> <th class="px-4 py-3 text-center text-xs font-semibold text-brand-200 uppercase tracking-wider" title="Quality of Play Score" > QoP </th> </tr> </thead> <tbody class="bg-card"> <!-- Championship Qualification label before first row --> <tr v-if="rankings.length" class="border-0"> <td colspan="7" class="px-0 py-0"> <div class="flex items-center gap-2 pb-1 pt-1 px-3 bg-brand-50"> <span class="text-xs font-semibold text-brand-700 uppercase tracking-wide whitespace-nowrap" >Championship Qualification</span > </div> </td> </tr> <template v-for="entry in rankings" :key="entry.rank"> <tr class="hover:bg-surface-alt transition-colors border-b border-line" > <td class="px-3 py-3 text-sm text-fg-muted"> {{ entry.rank }} </td> <td class="px-3 py-3 text-xs text-center"> <span v-if="entry.rank_change > 0" class="text-green-600 font-medium" :title="`Up ${entry.rank_change}`" > ▲{{ entry.rank_change }} </span> <span v-else-if="entry.rank_change < 0" class="text-red-600 font-medium" :title="`Down ${Math.abs(entry.rank_change)}`" > ▼{{ Math.abs(entry.rank_change) }} </span> <span v-else class="text-fg-muted">—</span> </td> <td class="px-4 py-3 text-sm font-medium text-fg"> {{ entry.team_name }} </td> <td class="px-4 py-3 text-sm text-center text-fg-muted"> {{ entry.matches_played ?? '—' }} </td> <td class="hidden sm:table-cell px-4 py-3 text-sm text-center text-fg-muted" > {{ entry.att_score != null ? entry.att_score.toFixed(1) : '—' }} <span v-if="entry.att_change != null && entry.att_change > 0" class="ml-1 text-xs font-normal text-green-600" :title="`ATT up ${entry.att_change} from prior week`" >+{{ entry.att_change.toFixed(1) }}</span > <span v-else-if="entry.att_change != null && entry.att_change < 0" class="ml-1 text-xs font-normal text-red-500" :title="`ATT down ${Math.abs(entry.att_change)} from prior week`" >{{ entry.att_change.toFixed(1) }}</span > </td> <td class="hidden sm:table-cell px-4 py-3 text-sm text-center text-fg-muted" > {{ entry.def_score != null ? entry.def_score.toFixed(1) : '—' }} <span v-if="entry.def_change != null && entry.def_change > 0" class="ml-1 text-xs font-normal text-green-600" :title="`DEF up ${entry.def_change} from prior week`" >+{{ entry.def_change.toFixed(1) }}</span > <span v-else-if="entry.def_change != null && entry.def_change < 0" class="ml-1 text-xs font-normal text-red-500" :title="`DEF down ${Math.abs(entry.def_change)} from prior week`" >{{ entry.def_change.toFixed(1) }}</span > </td> <td class="px-4 py-3 text-sm text-center font-bold text-brand-600 dark:text-brand-300" > {{ entry.qop_score != null ? entry.qop_score.toFixed(1) : '—' }} <span v-if="entry.qop_change != null && entry.qop_change > 0" class="ml-1 text-xs font-normal text-green-600" :title="`QoP up ${entry.qop_change} from prior week`" >+{{ entry.qop_change.toFixed(1) }}</span > <span v-else-if="entry.qop_change != null && entry.qop_change < 0" class="ml-1 text-xs font-normal text-red-500" :title="`QoP down ${Math.abs(entry.qop_change)} from prior week`" >{{ entry.qop_change.toFixed(1) }}</span > </td> </tr> <!-- Championship Qualification cutoff: after rank 5 --> <tr v-if="entry.rank === 5" class="border-0"> <td colspan="7" class="px-0 py-0"> <div class="flex items-center gap-2 border-t-2 border-brand-500 pt-1 pb-1 px-3" > <span class="text-xs font-semibold text-brand-600 dark:text-brand-300 uppercase tracking-wide whitespace-nowrap" >Premier Qualification</span > </div> </td> </tr> <!-- Tournament cutoff: after rank 10 --> <tr v-if="entry.rank === 10" class="border-0"> <td colspan="7" class="px-0 py-0"> <div class="flex items-center gap-2 border-t-2 border-red-400 pt-1 pb-1 px-3" > <span class="text-xs font-semibold text-red-500 uppercase tracking-wide whitespace-nowrap" >Not Invited — MLS NEXT Cup Tournament · Salt Lake City, UT</span > </div> </td> </tr> </template> </tbody> </table> </div> </div> </template> <script> import { ref, onMounted, watch } from 'vue'; import { useAuthStore } from '../stores/auth'; import { getApiBaseUrl } from '../config/api'; export default { name: 'QoPStandings', setup() { const authStore = useAuthStore(); const homegrownDivisions = ref([]); const selectedDivisionId = ref(null); const qopAgeGroups = ref([]); const selectedAgeGroupId = ref(null); const rankings = ref([]); const weekOf = ref(null); const priorWeekOf = ref(null); const currentSnapshotId = ref(null); const prevSnapshotId = ref(null); const nextSnapshotId = ref(null); const loading = ref(false); const error = ref(null); const resolveIds = async () => { const [ageGroupsData, divisionsData, leaguesData] = await Promise.all([ authStore.apiRequest(`${getApiBaseUrl()}/api/age-groups`), authStore.apiRequest(`${getApiBaseUrl()}/api/divisions`), authStore.apiRequest(`${getApiBaseUrl()}/api/leagues`), ]); const homegrown = leaguesData.find(l => l.name === 'Homegrown'); if (!homegrown) { error.value = 'Homegrown league not found.'; return false; } const divs = divisionsData .filter(d => Number(d.league_id) === Number(homegrown.id)) .sort((a, b) => a.name.localeCompare(b.name)); if (!divs.length) { error.value = 'No divisions found for Homegrown league.'; return false; } homegrownDivisions.value = divs; const northeast = divs.find(d => d.name === 'Northeast'); selectedDivisionId.value = northeast ? northeast.id : divs[0].id; const relevant = ageGroupsData .filter(ag => ag.name === 'U13' || ag.name === 'U14') .sort((a, b) => a.name.localeCompare(b.name)); qopAgeGroups.value = relevant; const u14 = relevant.find(ag => ag.name === 'U14'); selectedAgeGroupId.value = u14 ? u14.id : (relevant[0]?.id ?? null); return true; }; const fetchRankings = async () => { if (!selectedAgeGroupId.value || !selectedDivisionId.value) return; loading.value = true; error.value = null; try { const params = new URLSearchParams({ division_id: selectedDivisionId.value, age_group_id: selectedAgeGroupId.value, }); if (currentSnapshotId.value != null) { params.set('snapshot_id', currentSnapshotId.value); } const data = await authStore.apiRequest( `${getApiBaseUrl()}/api/qop-rankings?${params}` ); rankings.value = data.rankings ?? []; weekOf.value = data.week_of ?? null; priorWeekOf.value = data.prior_week_of ?? null; currentSnapshotId.value = data.snapshot_id ?? null; prevSnapshotId.value = data.prev_snapshot_id ?? null; nextSnapshotId.value = data.next_snapshot_id ?? null; } catch (err) { error.value = err.message; } finally { loading.value = false; } }; const goToSnapshot = id => { currentSnapshotId.value = id; fetchRankings(); }; // Changing filters should always return to the newest snapshot for the // new (division, age_group) pair — otherwise a stale snapshot_id from the // prior selection would 404 and render empty. watch([selectedAgeGroupId, selectedDivisionId], () => { currentSnapshotId.value = null; fetchRankings(); }); onMounted(async () => { const ok = await resolveIds(); if (ok) await fetchRankings(); }); return { homegrownDivisions, selectedDivisionId, qopAgeGroups, selectedAgeGroupId, rankings, weekOf, priorWeekOf, prevSnapshotId, nextSnapshotId, loading, error, goToSnapshot, }; }, }; </script> |