Merge main into migrate-about-pages and resolve conflicts

This commit is contained in:
Justin Edmund 2025-09-03 17:19:47 -07:00
commit cf69ed0477
2 changed files with 11 additions and 45 deletions

View file

@ -1,6 +1,6 @@
import { Metadata } from 'next' import { Metadata } from 'next'
import { notFound } from 'next/navigation' import { notFound } from 'next/navigation'
import { getUserProfile, getRaidGroups } from '~/app/lib/data' import { getUserInfo, getTeams, getRaidGroups } from '~/app/lib/data'
import ProfilePageClient from './ProfilePageClient' import ProfilePageClient from './ProfilePageClient'
// Dynamic metadata // Dynamic metadata
@ -10,10 +10,10 @@ export async function generateMetadata({
params: { username: string } params: { username: string }
}): Promise<Metadata> { }): Promise<Metadata> {
try { try {
const userProfileData = await getUserProfile(params.username, { page: 1 }) const userData = await getUserInfo(params.username)
// If user doesn't exist, use default metadata // If user doesn't exist, use default metadata
if (!userProfileData || !userProfileData.profile) { if (!userData || !userData.user) {
return { return {
title: 'User not found / granblue.team', title: 'User not found / granblue.team',
description: 'This user could not be found' description: 'This user could not be found'
@ -47,33 +47,25 @@ export default async function ProfilePage({
const page = searchParams.page ? parseInt(searchParams.page, 10) : 1; const page = searchParams.page ? parseInt(searchParams.page, 10) : 1;
// Parallel fetch data with Promise.all for better performance // Parallel fetch data with Promise.all for better performance
const [userProfileData, raidGroupsData] = await Promise.all([ const [userData, teamsData, raidGroupsData] = await Promise.all([
getUserProfile(params.username, { element, raid, recency, page }), getUserInfo(params.username),
getTeams({ username: params.username, element, raid, recency, page }),
getRaidGroups() getRaidGroups()
]) ])
// If user doesn't exist, show 404 // If user doesn't exist, show 404
if (!userProfileData || !userProfileData.profile) { if (!userData || !userData.user) {
notFound() notFound()
} }
// Extract user and teams from the profile response
const user = userProfileData.profile
const teams = userProfileData.profile.parties || []
const initialData = { const initialData = {
user: { user: userData.user,
id: user.id, teams: teamsData.results || [],
username: user.username,
avatar: user.avatar,
gender: user.gender
},
teams: teams,
raidGroups: raidGroupsData || [], raidGroups: raidGroupsData || [],
pagination: { pagination: {
current_page: page, current_page: page,
total_pages: userProfileData.meta?.total_pages || 1, total_pages: teamsData.meta?.total_pages || 1,
record_count: userProfileData.meta?.count || 0 record_count: teamsData.meta?.count || 0
} }
} }

View file

@ -62,32 +62,6 @@ export async function getUserInfo(username: string) {
} }
} }
// Get user profile with teams (combines user info and teams)
export async function getUserProfile(username: string, params?: {
element?: number;
raid?: string;
recency?: string;
page?: number;
}) {
try {
const queryParams: Record<string, string> = {};
if (params?.element) queryParams.element = params.element.toString();
if (params?.raid) queryParams.raid_id = params.raid;
if (params?.recency) queryParams.recency = params.recency;
if (params?.page) queryParams.page = params.page.toString();
let endpoint = `/users/${username}`;
const queryString = new URLSearchParams(queryParams).toString();
if (queryString) endpoint += `?${queryString}`;
const data = await fetchFromApi(endpoint);
return data;
} catch (error) {
console.error(`Failed to fetch user profile for ${username}`, error);
throw error;
}
}
// Get raid groups // Get raid groups
export async function getRaidGroups() { export async function getRaidGroups() {
try { try {