use username instead of membershipId in member page URL
This commit is contained in:
parent
ba5ec72ebd
commit
b718dcc335
4 changed files with 33 additions and 5 deletions
|
|
@ -341,7 +341,7 @@ export class GwAdapter extends BaseAdapter {
|
|||
// ==================== Member/Phantom Score History ====================
|
||||
|
||||
/**
|
||||
* Get all GW scores for a specific crew member
|
||||
* Get all GW scores for a specific crew member by membership ID
|
||||
*/
|
||||
async getMemberGwScores(membershipId: string, options?: RequestOptions): Promise<MemberGwScores> {
|
||||
const response = await this.request<MemberGwScores>(
|
||||
|
|
@ -351,6 +351,17 @@ export class GwAdapter extends BaseAdapter {
|
|||
return response
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all GW scores for a crew member by username
|
||||
*/
|
||||
async getMemberGwScoresByUsername(username: string, options?: RequestOptions): Promise<MemberGwScores> {
|
||||
const response = await this.request<MemberGwScores>(
|
||||
`/crew/memberships/${username}/gw_scores`,
|
||||
options
|
||||
)
|
||||
return response
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all GW scores for a specific phantom player
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ export const gwQueries = {
|
|||
}),
|
||||
|
||||
/**
|
||||
* Member's GW scores history query options
|
||||
* Member's GW scores history query options (by membership ID)
|
||||
*
|
||||
* @param membershipId - Crew membership ID
|
||||
*/
|
||||
|
|
@ -96,6 +96,20 @@ export const gwQueries = {
|
|||
gcTime: 1000 * 60 * 30 // 30 minutes
|
||||
}),
|
||||
|
||||
/**
|
||||
* Member's GW scores history query options (by username)
|
||||
*
|
||||
* @param username - User's username
|
||||
*/
|
||||
memberGwScoresByUsername: (username: string) =>
|
||||
queryOptions({
|
||||
queryKey: ['crew', 'member', 'username', username, 'gw_scores'] as const,
|
||||
queryFn: () => gwAdapter.getMemberGwScoresByUsername(username),
|
||||
enabled: !!username,
|
||||
staleTime: 1000 * 60 * 5, // 5 minutes
|
||||
gcTime: 1000 * 60 * 30 // 30 minutes
|
||||
}),
|
||||
|
||||
/**
|
||||
* Phantom's GW scores history query options
|
||||
*
|
||||
|
|
@ -135,5 +149,6 @@ export const gwKeys = {
|
|||
participationsAll: () => [...gwKeys.all, 'participations'] as const,
|
||||
participation: (participationId: string) => [...gwKeys.all, 'participations', participationId] as const,
|
||||
memberGwScores: (membershipId: string) => ['crew', 'member', membershipId, 'gw_scores'] as const,
|
||||
memberGwScoresByUsername: (username: string) => ['crew', 'member', 'username', username, 'gw_scores'] as const,
|
||||
phantomGwScores: (phantomId: string) => ['crew', 'phantom', phantomId, 'gw_scores'] as const
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,9 +31,11 @@
|
|||
const isTopFive = $derived(rank <= 5)
|
||||
|
||||
function handleRowClick() {
|
||||
// For members, use username (stored in name) for cleaner URLs
|
||||
// For phantoms, use phantom ID since they don't have usernames
|
||||
const path =
|
||||
player.type === 'member'
|
||||
? `/crew/members/${player.id}`
|
||||
? `/crew/members/${player.name}`
|
||||
: `/crew/phantoms/${player.id}`
|
||||
goto(path)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@
|
|||
import GwEventScoreRow from '$lib/components/crew/GwEventScoreRow.svelte'
|
||||
import GwCrewHistoryChart from '$lib/components/charts/GwCrewHistoryChart.svelte'
|
||||
|
||||
const membershipId = $derived($page.params.membershipId ?? '')
|
||||
const username = $derived($page.params.username ?? '')
|
||||
|
||||
// Query for member's GW scores
|
||||
const scoresQuery = createQuery(() => gwQueries.memberGwScores(membershipId))
|
||||
const scoresQuery = createQuery(() => gwQueries.memberGwScoresByUsername(username))
|
||||
|
||||
const memberName = $derived(scoresQuery.data?.member?.user?.username ?? 'Member')
|
||||
|
||||
Loading…
Reference in a new issue