diff --git a/src/app/[locale]/user/[username]/page.tsx b/src/app/[locale]/user/[username]/page.tsx index 2f1eed3..a80385a 100644 --- a/src/app/[locale]/user/[username]/page.tsx +++ b/src/app/[locale]/user/[username]/page.tsx @@ -19,7 +19,6 @@ export const dynamicParams = true; type Props = { params: Promise<{ locale?: string; username: string }>; - searchParams?: Promise<{ country?: string }>; }; export async function generateMetadata({ params }: Props): Promise { @@ -85,13 +84,9 @@ export async function generateMetadata({ params }: Props): Promise { }; } -export default async function UserProfilePage({ params, searchParams }: Props) { +export default async function UserProfilePage({ params }: Props) { const { username } = await params; const cleanUsername = decodeURIComponent(username.trim()); - const profileUrl = toAbsoluteUrl(`/user/${cleanUsername}`); - - const resolvedSearchParams = searchParams ? await searchParams : undefined; - const countryParam = resolvedSearchParams?.country; let profileData: Awaited> | null = null; let fetchErrorMessage: string | null = null; @@ -104,9 +99,6 @@ export default async function UserProfilePage({ params, searchParams }: Props) { source: "ssr", routeOrJob: "/[locale]/user/[username]", target: { username: cleanUsername }, - context: { - ...(countryParam ? { countryParam } : {}), - }, }); } @@ -120,14 +112,14 @@ export default async function UserProfilePage({ params, searchParams }: Props) { const { user, location } = profileData; const profilePageSchema = buildUserProfileSchema(user, location); - const breadcrumbSchema = buildUserBreadcrumbSchema(user, location, countryParam); + const breadcrumbSchema = buildUserBreadcrumbSchema(user, location); return (
- +
); } diff --git a/src/features/developer/components/user-profile-client.tsx b/src/features/developer/components/user-profile-client.tsx index f416e14..833c3a6 100644 --- a/src/features/developer/components/user-profile-client.tsx +++ b/src/features/developer/components/user-profile-client.tsx @@ -1,6 +1,5 @@ "use client"; import { useEffect, useMemo, useState } from "react"; -import { useSearchParams } from "next/navigation"; import type { Route } from "next"; import { useClipboardCopy } from "@/hooks"; import { @@ -51,12 +50,10 @@ const countries = countriesData as CountryInfo[]; type Props = { user: UserResult; location?: string | null; - countryParam?: string | null; }; -export function UserProfileClient({ user, location, countryParam }: Props) { +export function UserProfileClient({ user, location }: Props) { const { t } = useTranslation(); - const searchParams = useSearchParams(); const { copied, copy } = useClipboardCopy(); const { copied: markdownCopied, copy: copyMarkdown } = useClipboardCopy(); const { copied: htmlCopied, copy: copyHtml } = useClipboardCopy(); @@ -110,17 +107,14 @@ export function UserProfileClient({ user, location, countryParam }: Props) { }; }, [badgeDialogOpen]); - // Location & Country detection - const detectedSlug = detectCountry(location ?? null); - const rawCountry = (countryParam || searchParams.get("country") || detectedSlug || "") - .trim() + // Location & Country detection (purely from user info) + const detectedSlug = detectCountry(location ?? null) + ?.trim() .toLowerCase(); - const activeCountrySlug = rawCountry ? rawCountry.replace(/[^a-z0-9_-]/g, "") : null; - - const activeCountryInfo = activeCountrySlug - ? (countries.find((c) => c.slug.toLowerCase() === activeCountrySlug) ?? { - slug: activeCountrySlug, - title: activeCountrySlug + const detectedCountryInfo = detectedSlug + ? (countries.find((c) => c.slug.toLowerCase() === detectedSlug) ?? { + slug: detectedSlug, + title: detectedSlug .split("_") .filter(Boolean) .map((s) => s.charAt(0).toUpperCase() + s.slice(1)) @@ -128,8 +122,7 @@ export function UserProfileClient({ user, location, countryParam }: Props) { }) : null; - const flagSlug = activeCountryInfo?.slug || detectedSlug; - const flagCode = flagSlug ? getCountryCode(flagSlug) : null; + const flagCode = detectedSlug ? getCountryCode(detectedSlug) : null; const handleCopyLink = () => copy(window.location.href); @@ -149,15 +142,15 @@ export function UserProfileClient({ user, location, countryParam }: Props) { {/* ── Breadcrumb & Back Navigation ────────────────────────────── */}
- {activeCountryInfo ? ( - + {detectedCountryInfo ? ( + ) : ( @@ -186,14 +179,14 @@ export function UserProfileClient({ user, location, countryParam }: Props) { {t("profile.breadcrumbs.leaderboards")} - {activeCountryInfo ? ( + {detectedCountryInfo ? ( <> / - {activeCountryInfo.title} + {detectedCountryInfo.title} ) : null} @@ -623,7 +616,9 @@ export function UserProfileClient({ user, location, countryParam }: Props) {

{t("profile.getBadge")}

-

{t("profile.badgeDescription")}

+

+ {t("profile.badgeDescription")} +