Armería: PvP campos de batalla, logros por categoría, bandas/mazmorras y página de hermandad
- PvP: pestaña Campos de batalla (pvpstats) con resultado, stats por partida y fecha/hora. - Logros: rejilla por categoría con anillos de progreso + detalle por categoría (datos de Achievement.db2 + Achievement_Category.db2, iconos vía wowhead). - Bandas: progreso por dificultad (10/25/heroico) con jefes reales de DungeonEncounter.db2 y tooltip de jefes; agrupado por expansión (Clásico/TBC/WotLK). - Mazmorras: mismo sistema, Normal + Heroico, Clásico/TBC/WotLK. - Página de hermandad estilo armería: cabecera (emblema, puntos = unión de logros de miembros sin duplicar, nº miembros, fundada), pestañas Hermandad/Logros, roster con iconos de clase/raza, columna Función (rol por spec), filtros clase/función, orden por rango/puntos/nivel de objeto/nivel/nombre, paginación. - Barra lateral: mensaje diario con login (iron-session, gated por pertenencia), logros recientes y desgloses de clases y funciones. - Cabecera de personaje: enlace a la hermandad + nombre del reino. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -9,26 +9,42 @@ import {
|
||||
getCharacterProfessions,
|
||||
getItemIcons,
|
||||
getAchievementPoints,
|
||||
getCharacterTalents,
|
||||
getCharacterTalentGroups,
|
||||
getCharacterSpecs,
|
||||
getSpellIcons,
|
||||
getActivityPage,
|
||||
getAchievementOverview,
|
||||
getRaidProgress,
|
||||
getDungeonProgress,
|
||||
getRealmName,
|
||||
getQuestCount,
|
||||
getQuestPage,
|
||||
getQuestStatusCounts,
|
||||
getCharacterCollection,
|
||||
getReputations,
|
||||
getPvpRank,
|
||||
getCharacterArena,
|
||||
getPvpCurrency,
|
||||
getBattlegroundHistory,
|
||||
} from '@/lib/armory'
|
||||
import { raceName, className, classColor, factionOf, classPower } from '@/lib/wow-data'
|
||||
import { raceName, className, classColor, factionOf, classPower, XP_FOR_LEVEL } from '@/lib/wow-data'
|
||||
import { PageShell } from '@/components/PageShell'
|
||||
import { ArmoryPaperdoll, type SheetItem } from '@/components/ArmoryPaperdoll'
|
||||
import { wowheadIcon } from '@/lib/wowhead'
|
||||
import { ArmoryTalents } from '@/components/ArmoryTalents'
|
||||
import { ArmoryActivity } from '@/components/ArmoryActivity'
|
||||
import { WowheadRefresh } from '@/components/WowheadRefresh'
|
||||
import { ArmoryTalentTab } from '@/components/ArmoryTalentTab'
|
||||
import { ArmoryAchievements } from '@/components/ArmoryAchievements'
|
||||
import { ArmoryRaids } from '@/components/ArmoryRaids'
|
||||
import { ArmoryQuests } from '@/components/ArmoryQuests'
|
||||
import { ArmoryTabs, type ArmoryTab } from '@/components/ArmoryTabs'
|
||||
import { ArmoryReputations } from '@/components/ArmoryReputations'
|
||||
import { ArmoryCollection } from '@/components/ArmoryCollection'
|
||||
import { ArmoryPvpRank } from '@/components/ArmoryPvpRank'
|
||||
import { ArmoryBattlegrounds } from '@/components/ArmoryBattlegrounds'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
const MAX_LEVEL = 80
|
||||
|
||||
export default async function CharacterPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: string; guid: string }>
|
||||
}) {
|
||||
export default async function CharacterPage({ params }: { params: Promise<{ locale: string; guid: string }> }) {
|
||||
const { locale, guid } = await params
|
||||
setRequestLocale(locale)
|
||||
const t = await getTranslations('Armory')
|
||||
@@ -37,18 +53,36 @@ export default async function CharacterPage({
|
||||
const character = await getCharacter(id)
|
||||
if (!character) notFound()
|
||||
|
||||
const [equipment, customizations, stats, professions, achievementPoints, talents, specs, activityData] = await Promise.all([
|
||||
getCharacterEquipment(id, locale),
|
||||
getCharacterCustomizations(id),
|
||||
getCharacterStats(id),
|
||||
getCharacterProfessions(id, locale),
|
||||
getAchievementPoints(id),
|
||||
getCharacterTalents(id, character.class, locale),
|
||||
getCharacterSpecs(id, character.class, locale),
|
||||
getActivityPage(id, locale, 1, 10, ''),
|
||||
const [equipment, customizations, stats, professions, achievementPoints, talentGroups, specs, activityData, questCount] =
|
||||
await Promise.all([
|
||||
getCharacterEquipment(id, locale),
|
||||
getCharacterCustomizations(id),
|
||||
getCharacterStats(id),
|
||||
getCharacterProfessions(id, locale),
|
||||
getAchievementPoints(id),
|
||||
getCharacterTalentGroups(id, character.class, locale),
|
||||
getCharacterSpecs(id, character.class, locale),
|
||||
getActivityPage(id, locale, 1, 10, '', ''),
|
||||
getQuestCount(id),
|
||||
])
|
||||
const [questData, mounts, pets, questCounts, reputations, pvpRankData, arena, pvpCurrency, bgHistory, achOverview, raidProgress, dungeonProgress, realmName] = await Promise.all([
|
||||
getQuestPage(id, locale, 1, 15, '', '', 'all'),
|
||||
getCharacterCollection(id, locale, 'mounts'),
|
||||
getCharacterCollection(id, locale, 'pets'),
|
||||
getQuestStatusCounts(id),
|
||||
getReputations(id, locale),
|
||||
getPvpRank(1, 30, ''),
|
||||
getCharacterArena(id),
|
||||
getPvpCurrency(id),
|
||||
getBattlegroundHistory(id),
|
||||
getAchievementOverview(id, factionOf(character.race), locale),
|
||||
getRaidProgress(id, locale),
|
||||
getDungeonProgress(id, locale),
|
||||
getRealmName(),
|
||||
])
|
||||
const qGrand = questCounts.rewarded + questCounts.complete + questCounts.inprogress + questCounts.failed
|
||||
const icons = await getItemIcons(equipment.map((e) => e.entry))
|
||||
const spellIcons = talents ? await getSpellIcons(talents.trees.flatMap((tr) => tr.talents.map((c) => c.spell))) : {}
|
||||
const spellIcons = await getSpellIcons(talentGroups.spellIds)
|
||||
|
||||
const items: SheetItem[] = equipment.map((e) => ({
|
||||
slot: e.slot,
|
||||
@@ -70,6 +104,10 @@ export default async function CharacterPage({
|
||||
const factionLabel = faction === 'alliance' ? t('alliance') : faction === 'horde' ? t('horde') : ''
|
||||
const power = classPower(character.class, locale)
|
||||
|
||||
const xpNext = character.level < MAX_LEVEL ? XP_FOR_LEVEL[character.level] ?? 0 : 0
|
||||
const xpPct =
|
||||
character.level >= MAX_LEVEL ? 100 : xpNext > 0 ? Math.min(100, Math.round((character.xp / xpNext) * 100)) : 0
|
||||
|
||||
const statRows = stats
|
||||
? [
|
||||
{ label: t('strength'), value: `${stats.strength}` },
|
||||
@@ -89,6 +127,431 @@ export default async function CharacterPage({
|
||||
]
|
||||
: []
|
||||
|
||||
// ---- Pestaña Equipación: modelo + spec + stats/profesiones/PvP ----
|
||||
const equipTab = (
|
||||
<>
|
||||
<ArmoryPaperdoll
|
||||
race={character.race}
|
||||
gender={character.gender}
|
||||
customizations={customizations}
|
||||
items={items}
|
||||
health={character.health}
|
||||
power={character.power}
|
||||
powerLabel={power.label}
|
||||
powerColor={power.color}
|
||||
locale={locale}
|
||||
labels={{
|
||||
loading: t('modelLoading'),
|
||||
unavailable: t('modelUnavailable'),
|
||||
health: t('health'),
|
||||
itemLevel: t('itemLevel'),
|
||||
model: t('model3d'),
|
||||
list: t('equipment'),
|
||||
}}
|
||||
/>
|
||||
|
||||
{specs.primary && (
|
||||
<div className="armory-panel armory-spec-panel">
|
||||
<h2 className="armory-section-title">{t('specialization')}</h2>
|
||||
<div className="armory-specs">
|
||||
<div className="armory-spec-box active">
|
||||
<span
|
||||
className="armory-spec-box-icon"
|
||||
style={{ backgroundImage: `url(${wowheadIcon(specs.primary.icon, 'medium')})` }}
|
||||
/>
|
||||
<div className="armory-spec-box-info">
|
||||
<div className="armory-spec-box-name">{specs.primary.name}</div>
|
||||
<div className="armory-spec-box-dist">{specs.primary.dist.join(' / ')}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className={`armory-spec-box ${specs.secondary ? '' : 'na'}`}>
|
||||
{specs.secondary ? (
|
||||
<>
|
||||
<span
|
||||
className="armory-spec-box-icon"
|
||||
style={{ backgroundImage: `url(${wowheadIcon(specs.secondary.icon, 'medium')})` }}
|
||||
/>
|
||||
<div className="armory-spec-box-info">
|
||||
<div className="armory-spec-box-name">{specs.secondary.name}</div>
|
||||
<div className="armory-spec-box-dist">{specs.secondary.dist.join(' / ')}</div>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<span className="armory-spec-box-na">N/A</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="armory-panels">
|
||||
<div className="armory-panel">
|
||||
<h2 className="armory-section-title">{t('stats')}</h2>
|
||||
{stats ? (
|
||||
<div className="armory-stats-grid">
|
||||
{statRows.map((r) => (
|
||||
<div className="armory-stat" key={r.label}>
|
||||
<span className="armory-stat-label">{r.label}</span>
|
||||
<span className="armory-stat-value">{r.value}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p className="armory-hint armory-stats-pending">{t('statsPending')}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="armory-panel">
|
||||
<h2 className="armory-section-title">{t('professions')}</h2>
|
||||
{professions.length ? (
|
||||
<div className="armory-prof-groups">
|
||||
{(['primary', 'secondary'] as const).map((kind) => {
|
||||
const list = professions.filter((p) => p.kind === kind)
|
||||
if (!list.length) return null
|
||||
return (
|
||||
<div className="armory-prof-group" key={kind}>
|
||||
<h3 className="armory-prof-grouptitle">
|
||||
{kind === 'primary' ? t('primaryProfs') : t('secondaryProfs')}
|
||||
</h3>
|
||||
{list.map((p) => (
|
||||
<div className="armory-prof-row" key={p.skill}>
|
||||
<span
|
||||
className="armory-prof-icon"
|
||||
style={{ backgroundImage: `url(${wowheadIcon(p.icon, 'small')})` }}
|
||||
/>
|
||||
<div className="armory-prof-body">
|
||||
<div className="armory-prof-head">
|
||||
<span className="armory-prof-name">
|
||||
{p.name}
|
||||
{p.rank ? <span className="armory-prof-rank"> · {p.rank}</span> : null}
|
||||
</span>
|
||||
<span className="armory-prof-value">
|
||||
{p.value}
|
||||
<span className="armory-prof-max"> / {p.max}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="armory-prof-bar">
|
||||
<span style={{ width: `${Math.round((p.value / Math.max(1, p.max)) * 100)}%` }} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<p className="armory-hint">{t('noProfessions')}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
||||
// ---- Pestaña PvP (sub-pestañas: Estadísticas + Rank mundo) ----
|
||||
const pvpStatsSub = (
|
||||
<div className="armory-panel">
|
||||
<div className="armory-pvp-tiles">
|
||||
<div className="armory-pvp-tile">
|
||||
<span className="armory-pvp-tile-num" style={{ color: '#ff5555' }}>
|
||||
{character.totalKills.toLocaleString(locale)}
|
||||
</span>
|
||||
<span className="armory-pvp-tile-lbl">{t('totalKills')}</span>
|
||||
</div>
|
||||
<div className="armory-pvp-tile">
|
||||
<span className="armory-pvp-tile-num" style={{ color: '#ff8888' }}>
|
||||
{character.todayKills.toLocaleString(locale)}
|
||||
</span>
|
||||
<span className="armory-pvp-tile-lbl">{t('todayKills')}</span>
|
||||
</div>
|
||||
<div className="armory-pvp-tile">
|
||||
<span className="armory-pvp-tile-num" style={{ color: '#e08a3a' }}>
|
||||
{character.yesterdayKills.toLocaleString(locale)}
|
||||
</span>
|
||||
<span className="armory-pvp-tile-lbl">{t('yesterdayKills')}</span>
|
||||
</div>
|
||||
<div className="armory-pvp-tile">
|
||||
<span className="armory-pvp-tile-num" style={{ color: '#ffd100' }}>
|
||||
{pvpCurrency.honor.toLocaleString(locale)}
|
||||
</span>
|
||||
<span className="armory-pvp-tile-lbl">{t('honorPoints')}</span>
|
||||
</div>
|
||||
<div className="armory-pvp-tile">
|
||||
<span className="armory-pvp-tile-num" style={{ color: '#9b59b6' }}>
|
||||
{pvpCurrency.arena.toLocaleString(locale)}
|
||||
</span>
|
||||
<span className="armory-pvp-tile-lbl">{t('arenaPoints')}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
const arenaSub = (
|
||||
<div className="armory-panel">
|
||||
<div className="armory-arena">
|
||||
{arena.map((b) => {
|
||||
const losses = Math.max(0, b.seasonGames - b.seasonWins)
|
||||
const winRate = b.seasonGames ? Math.round((b.seasonWins / b.seasonGames) * 100) : 0
|
||||
return (
|
||||
<div className="armory-arena-card" key={b.slot}>
|
||||
<div className="armory-arena-bracket">{b.bracket}</div>
|
||||
<span className={`armory-arena-mode ${b.seasonGames > 0 ? 'rated' : 'none'}`}>
|
||||
{b.seasonGames > 0 ? t('arenaRated') : t('arenaUnrated')}
|
||||
</span>
|
||||
<div className="armory-arena-rating">{b.personalRating}</div>
|
||||
<div className="armory-arena-rating-lbl">{t('arenaRating')}</div>
|
||||
{b.seasonGames > 0 ? (
|
||||
<div className="armory-arena-rows">
|
||||
<div className="armory-arena-row">
|
||||
<span>{t('arenaSeason')}</span>
|
||||
<span>
|
||||
<b className="armory-arena-w">{b.seasonWins}</b> / <b className="armory-arena-l">{losses}</b> ·{' '}
|
||||
{winRate}%
|
||||
</span>
|
||||
</div>
|
||||
<div className="armory-arena-row">
|
||||
<span>{t('arenaWeek')}</span>
|
||||
<span>
|
||||
{b.weekWins} / {Math.max(0, b.weekGames - b.weekWins)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="armory-arena-row">
|
||||
<span>MMR</span>
|
||||
<span>{b.mmr}</span>
|
||||
</div>
|
||||
{b.rank > 0 ? (
|
||||
<div className="armory-arena-row">
|
||||
<span>{t('arenaRank')}</span>
|
||||
<span>#{b.rank}</span>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
) : (
|
||||
<div className="armory-arena-nogames">{t('arenaNoGames')}</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
const pvpTab = (
|
||||
<ArmoryTabs
|
||||
tabs={[
|
||||
{ key: 'pvpstats', label: t('pvpStats'), icon: 'fas fa-skull', content: pvpStatsSub },
|
||||
{ key: 'arena', label: t('arena'), icon: 'fas fa-shield-halved', content: arenaSub },
|
||||
{
|
||||
key: 'battlegrounds',
|
||||
label: t('battlegrounds'),
|
||||
icon: 'fas fa-flag-checkered',
|
||||
content: (
|
||||
<ArmoryBattlegrounds
|
||||
locale={locale}
|
||||
rows={bgHistory.rows}
|
||||
matches={bgHistory.matches}
|
||||
wins={bgHistory.wins}
|
||||
losses={bgHistory.losses}
|
||||
winRate={bgHistory.winRate}
|
||||
labels={{
|
||||
history: t('bgHistory'),
|
||||
desc: t('bgDesc'),
|
||||
matches: t('bgMatches'),
|
||||
wins: t('bgWins'),
|
||||
losses: t('bgLosses'),
|
||||
winRate: t('bgWinRate'),
|
||||
result: t('bgResult'),
|
||||
win: t('bgWin'),
|
||||
loss: t('bgLoss'),
|
||||
kb: t('bgKb'),
|
||||
hk: t('bgHk'),
|
||||
deaths: t('bgDeaths'),
|
||||
damage: t('bgDamage'),
|
||||
healing: t('bgHealing'),
|
||||
honor: t('bgHonor'),
|
||||
date: t('bgDate'),
|
||||
none: t('bgNone'),
|
||||
battleground: t('battlegrounds'),
|
||||
}}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'pvprank',
|
||||
label: t('pvpRank'),
|
||||
icon: 'fas fa-trophy',
|
||||
content: (
|
||||
<ArmoryPvpRank
|
||||
locale={locale}
|
||||
initial={pvpRankData.entries}
|
||||
total={pvpRankData.total}
|
||||
pageSize={30}
|
||||
labels={{
|
||||
title: t('pvpRankTitle'),
|
||||
desc: t('pvpRankDesc'),
|
||||
search: t('searchPlayer'),
|
||||
empty: t('noPlayers'),
|
||||
character: t('rankPersonaje'),
|
||||
kills: t('rankKills'),
|
||||
playedTime: t('playedTime'),
|
||||
}}
|
||||
/>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)
|
||||
|
||||
const raidsTab = (
|
||||
<ArmoryRaids
|
||||
locale={locale}
|
||||
raids={raidProgress}
|
||||
labels={{
|
||||
bosses: t('raidBosses'),
|
||||
empty: t('raidNoData'),
|
||||
classic: t('expClassic'),
|
||||
tbc: t('expTbc'),
|
||||
wotlk: t('expWotlk'),
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
const dungeonsTab = (
|
||||
<ArmoryRaids
|
||||
locale={locale}
|
||||
raids={dungeonProgress}
|
||||
labels={{
|
||||
bosses: t('raidBosses'),
|
||||
empty: t('raidNoData'),
|
||||
classic: t('expClassic'),
|
||||
tbc: t('expTbc'),
|
||||
wotlk: t('expWotlk'),
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
// ---- Pestaña Talentos (toggle Primaria/Secundaria + árbol + glifos) ----
|
||||
const talentsTab = talentGroups.groups.length ? (
|
||||
<ArmoryTalentTab
|
||||
groups={talentGroups.groups}
|
||||
activeIndex={talentGroups.activeIndex}
|
||||
spellIcons={spellIcons}
|
||||
locale={locale}
|
||||
labels={{
|
||||
distribution: t('distribution'),
|
||||
glyphs: t('glyphs'),
|
||||
majorGlyphs: t('majorGlyphs'),
|
||||
minorGlyphs: t('minorGlyphs'),
|
||||
primary: t('primary'),
|
||||
secondary: t('secondary'),
|
||||
activeSpec: t('activeSpec'),
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<div className="armory-panel">
|
||||
<p className="armory-hint">{t('noTalents')}</p>
|
||||
</div>
|
||||
)
|
||||
|
||||
// ---- Pestaña Logros ----
|
||||
const logrosTab = (
|
||||
<ArmoryAchievements
|
||||
locale={locale}
|
||||
guid={id}
|
||||
categories={achOverview.categories}
|
||||
earnedPoints={achOverview.earnedPoints}
|
||||
totalCompleted={achOverview.totalCompleted}
|
||||
labels={{
|
||||
summary: t('achSummaryLine'),
|
||||
back: t('achBack'),
|
||||
reward: t('achReward'),
|
||||
empty: t('achEmptyCat'),
|
||||
of: t('achOf'),
|
||||
feats: t('achFeats'),
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
const questsTab = (
|
||||
<div className="armory-panel armory-quests-panel">
|
||||
<ArmoryQuests
|
||||
guid={id}
|
||||
locale={locale}
|
||||
initial={questData.entries}
|
||||
total={questData.total}
|
||||
grandTotal={qGrand}
|
||||
pageSize={15}
|
||||
statuses={[
|
||||
{ key: 'all', label: t('allStatuses'), count: qGrand },
|
||||
{ key: 'inprogress', label: t('qsInProgress'), count: questCounts.inprogress },
|
||||
{ key: 'complete', label: t('qsComplete'), count: questCounts.complete },
|
||||
{ key: 'failed', label: t('qsFailed'), count: questCounts.failed },
|
||||
{ key: 'rewarded', label: t('qsRewarded'), count: questCounts.rewarded },
|
||||
]}
|
||||
badgeLabels={{
|
||||
rewarded: t('bRewarded'),
|
||||
complete: t('bComplete'),
|
||||
inprogress: t('bInProgress'),
|
||||
failed: t('bFailed'),
|
||||
}}
|
||||
labels={{
|
||||
filterId: t('filterId'),
|
||||
filterName: t('filterName'),
|
||||
empty: t('noQuests'),
|
||||
quest: t('quest'),
|
||||
statusCol: t('statusCol'),
|
||||
title: t('quests'),
|
||||
pageOf: '',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
const mountsTab = (
|
||||
<ArmoryCollection
|
||||
items={mounts}
|
||||
locale={locale}
|
||||
pageSize={30}
|
||||
labels={{ title: t('mountsCollected', { n: mounts.length }), search: t('collSearch'), empty: t('noMounts') }}
|
||||
/>
|
||||
)
|
||||
const petsTab = (
|
||||
<ArmoryCollection
|
||||
items={pets}
|
||||
locale={locale}
|
||||
pageSize={30}
|
||||
labels={{ title: t('petsCollected', { n: pets.length }), search: t('collSearch'), empty: t('noPets') }}
|
||||
/>
|
||||
)
|
||||
|
||||
const repsTab = (
|
||||
<ArmoryReputations
|
||||
reputations={reputations}
|
||||
pageSize={30}
|
||||
labels={{ title: t('reputations'), search: t('repSearch'), empty: t('noReps') }}
|
||||
/>
|
||||
)
|
||||
|
||||
const tabs: ArmoryTab[] = [
|
||||
{ key: 'equip', label: t('tabEquip'), icon: 'fas fa-shield-alt', content: equipTab },
|
||||
{
|
||||
key: 'talents',
|
||||
label: t('talents'),
|
||||
icon: 'fas fa-tree',
|
||||
count: talentGroups.groups[talentGroups.activeIndex]?.total,
|
||||
content: talentsTab,
|
||||
},
|
||||
{ key: 'achievements', label: t('achievements'), icon: 'fas fa-trophy', count: activityData.total, content: logrosTab },
|
||||
{ key: 'raids', label: t('raids'), icon: 'fas fa-dragon', content: raidsTab },
|
||||
{ key: 'dungeons', label: t('dungeons'), icon: 'fas fa-dungeon', content: dungeonsTab },
|
||||
{ key: 'quests', label: t('quests'), icon: 'fas fa-scroll', count: questCount, content: questsTab },
|
||||
{ key: 'reputations', label: t('reputations'), icon: 'fas fa-handshake', count: reputations.length, content: repsTab },
|
||||
{ key: 'pvp', label: t('pvp'), icon: 'fas fa-khanda', content: pvpTab },
|
||||
{ key: 'mounts', label: t('mounts'), icon: 'fas fa-horse', count: mounts.length, content: mountsTab },
|
||||
{ key: 'pets', label: t('pets'), icon: 'fas fa-paw', count: pets.length, content: petsTab },
|
||||
]
|
||||
|
||||
return (
|
||||
<PageShell title={character.name}>
|
||||
<div className="main-wide">
|
||||
@@ -121,134 +584,26 @@ export default async function CharacterPage({
|
||||
<{character.guildName}>
|
||||
</Link>
|
||||
)}
|
||||
{realmName && <span className="armory-realm">{realmName}</span>}
|
||||
<span className="armory-achpoints" title={t('achievementPoints')}>
|
||||
<i className="fas fa-star" /> {achievementPoints.toLocaleString(locale)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ArmoryPaperdoll
|
||||
race={character.race}
|
||||
gender={character.gender}
|
||||
customizations={customizations}
|
||||
items={items}
|
||||
health={character.health}
|
||||
power={character.power}
|
||||
powerLabel={power.label}
|
||||
powerColor={power.color}
|
||||
locale={locale}
|
||||
labels={{
|
||||
loading: t('modelLoading'),
|
||||
unavailable: t('modelUnavailable'),
|
||||
health: t('health'),
|
||||
itemLevel: t('itemLevel'),
|
||||
model: t('model3d'),
|
||||
list: t('equipment'),
|
||||
}}
|
||||
/>
|
||||
|
||||
{specs.primary && (
|
||||
<div className="armory-panel armory-spec-panel">
|
||||
<h2 className="armory-section-title">{t('specialization')}</h2>
|
||||
<div className="armory-specs">
|
||||
<div className="armory-spec-box active">
|
||||
<span
|
||||
className="armory-spec-box-icon"
|
||||
style={{ backgroundImage: `url(${wowheadIcon(specs.primary.icon, 'medium')})` }}
|
||||
/>
|
||||
<div className="armory-spec-box-info">
|
||||
<div className="armory-spec-box-name">{specs.primary.name}</div>
|
||||
<div className="armory-spec-box-dist">{specs.primary.dist.join(' / ')}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className={`armory-spec-box ${specs.secondary ? '' : 'na'}`}>
|
||||
{specs.secondary ? (
|
||||
<>
|
||||
<span
|
||||
className="armory-spec-box-icon"
|
||||
style={{ backgroundImage: `url(${wowheadIcon(specs.secondary.icon, 'medium')})` }}
|
||||
/>
|
||||
<div className="armory-spec-box-info">
|
||||
<div className="armory-spec-box-name">{specs.secondary.name}</div>
|
||||
<div className="armory-spec-box-dist">{specs.secondary.dist.join(' / ')}</div>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<span className="armory-spec-box-na">N/A</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="armory-xpbar">
|
||||
<div className="armory-xpbar-head">
|
||||
<span className="armory-xpbar-label">{t('level')}</span>
|
||||
<span className="armory-xpbar-value">
|
||||
{character.level >= MAX_LEVEL ? `${character.level} (MAX)` : character.level}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{talents && talents.total > 0 && (
|
||||
<div className="armory-panel armory-talents-panel">
|
||||
<h2 className="armory-section-title">{t('talents')}</h2>
|
||||
<WowheadRefresh dep={`talents-${id}`} />
|
||||
<ArmoryTalents
|
||||
trees={talents.trees}
|
||||
spec={talents.spec}
|
||||
total={talents.total}
|
||||
maxPoints={Math.max(0, character.level - 9)}
|
||||
locale={locale}
|
||||
spellIcons={spellIcons}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activityData.entries.length > 0 && (
|
||||
<div className="armory-panel armory-activity-panel">
|
||||
<h2 className="armory-section-title">{t('recentActivity')}</h2>
|
||||
<ArmoryActivity
|
||||
guid={id}
|
||||
locale={locale}
|
||||
initial={activityData.entries}
|
||||
total={activityData.total}
|
||||
pageSize={10}
|
||||
labels={{ earned: t('earned'), search: t('achSearch'), empty: t('noAchievements') }}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="armory-panels">
|
||||
<div className="armory-panel">
|
||||
<h2 className="armory-section-title">{t('stats')}</h2>
|
||||
{stats ? (
|
||||
<div className="armory-stats-grid">
|
||||
{statRows.map((r) => (
|
||||
<div className="armory-stat" key={r.label}>
|
||||
<span className="armory-stat-label">{r.label}</span>
|
||||
<span className="armory-stat-value">{r.value}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p className="armory-hint armory-stats-pending">{t('statsPending')}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="armory-panel">
|
||||
<h2 className="armory-section-title">{t('professions')}</h2>
|
||||
{professions.length ? (
|
||||
<div className="armory-prof-list">
|
||||
{professions.map((p) => (
|
||||
<div className="armory-prof" key={p.skill}>
|
||||
<span className="armory-prof-nameblock">
|
||||
<span className="armory-prof-name">{p.name}</span>
|
||||
{p.rank ? <span className="armory-prof-rank">{p.rank}</span> : null}
|
||||
</span>
|
||||
<span className="armory-prof-value">
|
||||
{p.value}
|
||||
<span className="armory-prof-max"> / {p.max}</span>
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p className="armory-hint">{t('noProfessions')}</p>
|
||||
)}
|
||||
<div className="armory-xpbar-track">
|
||||
<span style={{ width: `${xpPct}%` }} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ArmoryTabs tabs={tabs} />
|
||||
</div>
|
||||
</div>
|
||||
</PageShell>
|
||||
|
||||
@@ -1,54 +1,248 @@
|
||||
import { notFound } from 'next/navigation'
|
||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import { Link } from '@/i18n/navigation'
|
||||
import { getGuild } from '@/lib/armory'
|
||||
import { raceName, className, classColor } from '@/lib/wow-data'
|
||||
import {
|
||||
getGuildInfo,
|
||||
getGuildRoster,
|
||||
getGuildRecentAchievements,
|
||||
getRealmName,
|
||||
getGuildAchievementOverview,
|
||||
getGuildRoleBreakdown,
|
||||
} from '@/lib/armory'
|
||||
import { getSession } from '@/lib/session'
|
||||
import { isGuildMemberByAccount } from '@/lib/armory'
|
||||
import { className, classColor } from '@/lib/wow-data'
|
||||
import { wowheadIcon } from '@/lib/wowhead'
|
||||
import { PageShell } from '@/components/PageShell'
|
||||
import { ArmoryGuildRoster } from '@/components/ArmoryGuildRoster'
|
||||
import { ArmoryAchievements } from '@/components/ArmoryAchievements'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
const PAGE_SIZE = 25
|
||||
|
||||
export default async function GuildPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ locale: string; guid: string }>
|
||||
searchParams: Promise<{ tab?: string }>
|
||||
}) {
|
||||
const { locale, guid } = await params
|
||||
const { tab } = await searchParams
|
||||
setRequestLocale(locale)
|
||||
const t = await getTranslations('Armory')
|
||||
|
||||
const guild = await getGuild(Number(guid))
|
||||
if (!guild) notFound()
|
||||
const guildId = Number(guid)
|
||||
const info = await getGuildInfo(guildId)
|
||||
if (!info) notFound()
|
||||
|
||||
const isLogros = tab === 'logros'
|
||||
const emblemHue = (info.emblem.bg * 7) % 360
|
||||
|
||||
return (
|
||||
<PageShell title={guild.name}>
|
||||
<div className="main-wide">
|
||||
<PageShell title={info.name}>
|
||||
<div className="main-wide armory-guild-page">
|
||||
<p className="forum-path">
|
||||
<Link href="/armory">← {t('backToArmory')}</Link>
|
||||
</p>
|
||||
|
||||
<div className="armory-char-sub">
|
||||
{guild.members.length} {t('members')}
|
||||
{guild.leaderName && (
|
||||
<>
|
||||
{' · '}
|
||||
{t('leader')}: {guild.leaderName}
|
||||
</>
|
||||
)}
|
||||
{/* Cabecera de hermandad */}
|
||||
<div className="armory-guild-head">
|
||||
<div className="armory-guild-emblem" style={{ background: `hsl(${emblemHue} 45% 22%)` }}>
|
||||
<i className="fas fa-dragon" style={{ color: `hsl(${(emblemHue + 40) % 360} 70% 65%)` }} />
|
||||
</div>
|
||||
<div className="armory-guild-headinfo">
|
||||
<h1 className="armory-guild-title">{info.name}</h1>
|
||||
<div className="armory-guild-realm">{/* reino */}</div>
|
||||
<div className="armory-guild-stats">
|
||||
<span className="armory-guild-stat">
|
||||
<i className="fas fa-shield" /> {info.guildPoints.toLocaleString(locale)}
|
||||
</span>
|
||||
<span className="armory-guild-stat">
|
||||
<i className="fas fa-users" /> {info.memberCount} {t('members')}
|
||||
</span>
|
||||
{info.createdYear > 0 && (
|
||||
<span className="armory-guild-stat muted">
|
||||
{t('guildFounded')} {info.createdYear}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="armory-list" style={{ marginTop: 16 }}>
|
||||
{guild.members.map((m) => (
|
||||
<Link key={m.guid} href={`/armory/character/${m.guid}`} className="armory-row">
|
||||
<span className="armory-name" style={{ color: classColor(m.class) }}>
|
||||
{m.name}
|
||||
</span>
|
||||
<span className="armory-meta">
|
||||
{t('level')} {m.level} · {raceName(m.race, locale)} · {className(m.class, locale)}
|
||||
</span>
|
||||
</Link>
|
||||
))}
|
||||
<div className="armory-guild-tabbar">
|
||||
<Link href={`/armory/guild/${guildId}`} className={`armory-guild-tab${!isLogros ? ' active' : ''}`}>
|
||||
{t('guild')}
|
||||
</Link>
|
||||
<Link href={`/armory/guild/${guildId}?tab=logros`} className={`armory-guild-tab${isLogros ? ' active' : ''}`}>
|
||||
{t('guildAchievements')}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{isLogros ? (
|
||||
<GuildLogros guildId={guildId} locale={locale} t={t} />
|
||||
) : (
|
||||
<GuildRoster guildId={guildId} locale={locale} info={info} t={t} />
|
||||
)}
|
||||
</div>
|
||||
</PageShell>
|
||||
)
|
||||
}
|
||||
|
||||
/* ---- Vista Hermandad (roster + barra lateral) ---- */
|
||||
async function GuildRoster({
|
||||
guildId,
|
||||
locale,
|
||||
info,
|
||||
t,
|
||||
}: {
|
||||
guildId: number
|
||||
locale: string
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
info: any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
t: any
|
||||
}) {
|
||||
const session = await getSession()
|
||||
const accountId = session.accountId ?? 0
|
||||
const [roster, recent, realm, roleBreak, isMember] = await Promise.all([
|
||||
getGuildRoster(guildId, { page: 1, pageSize: PAGE_SIZE, classes: [], roles: [], sort: 'rank' }),
|
||||
getGuildRecentAchievements(guildId, locale, 5),
|
||||
getRealmName(),
|
||||
getGuildRoleBreakdown(guildId),
|
||||
isGuildMemberByAccount(accountId, guildId),
|
||||
])
|
||||
const motdState: 'guest' | 'member' | 'nonmember' = !accountId ? 'guest' : isMember ? 'member' : 'nonmember'
|
||||
const roleRows: { key: 'tank' | 'healer' | 'dps'; label: string; color: string; count: number }[] = [
|
||||
{ key: 'tank', label: t('roleTank'), color: '#4a90d9', count: roleBreak.tank },
|
||||
{ key: 'healer', label: t('roleHealer'), color: '#4ade5f', count: roleBreak.healer },
|
||||
{ key: 'dps', label: t('roleDps'), color: '#d9534f', count: roleBreak.dps },
|
||||
]
|
||||
const maxRole = Math.max(1, roleBreak.tank, roleBreak.healer, roleBreak.dps)
|
||||
const maxCount = Math.max(1, ...info.classBreakdown.map((c: { count: number }) => c.count))
|
||||
const fmtDate = (unix: number) => {
|
||||
if (!unix) return ''
|
||||
const d = new Date(unix * 1000)
|
||||
return Number.isNaN(d.getTime()) ? '' : d.toLocaleDateString(locale, { day: '2-digit', month: '2-digit', year: 'numeric' })
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="armory-guild-layout">
|
||||
<div className="armory-guild-main">
|
||||
<h2 className="armory-guild-section">
|
||||
{t('guildMembers')} <span className="armory-guild-realm-inline">· {realm}</span>
|
||||
</h2>
|
||||
<ArmoryGuildRoster
|
||||
guildid={guildId}
|
||||
locale={locale}
|
||||
initial={roster.members}
|
||||
total={roster.total}
|
||||
pageSize={PAGE_SIZE}
|
||||
classes={info.classBreakdown.map((c: { class: number }) => c.class)}
|
||||
labels={{
|
||||
view: t('guildView'), sortRank: t('guildSortRank'), sortPoints: t('guildSortPoints'),
|
||||
sortLevel: t('guildSortLevel'), sortName: t('guildSortName'), filterClass: t('guildFilterClass'),
|
||||
allClasses: t('guildAllClasses'), filterRole: t('guildFilterRole'), allRoles: t('guildAllRoles'),
|
||||
roleTank: t('roleTank'), roleHealer: t('roleHealer'), roleDps: t('roleDps'),
|
||||
sortIlvl: t('guildSortIlvl'), ilvl: t('colIlvl'),
|
||||
name: t('colName'), race: t('colRace'), class: t('colClass'), role: t('colFunction'),
|
||||
level: t('colLevel'), rank: t('colRank'), points: t('guildSortPoints'),
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<aside className="armory-guild-side">
|
||||
<div className="armory-guild-card">
|
||||
<h3 className="armory-guild-card-title">{t('guildMotd')}</h3>
|
||||
{motdState === 'member' ? (
|
||||
<div className="armory-guild-motd">{info.motd?.trim() ? info.motd : t('guildMotdEmpty')}</div>
|
||||
) : motdState === 'guest' ? (
|
||||
<div className="armory-guild-motd-locked">
|
||||
<i className="fas fa-lock" />{' '}
|
||||
{t('guildMotdGuest')} <Link href="/my-account" className="armory-guild-login">{t('login')}</Link>
|
||||
</div>
|
||||
) : (
|
||||
<div className="armory-guild-motd-locked">
|
||||
<i className="fas fa-lock" /> {t('guildMotdLocked')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{recent.length > 0 && (
|
||||
<div className="armory-guild-card">
|
||||
<h3 className="armory-guild-card-title">{t('guildRecent')}</h3>
|
||||
<ul className="armory-guild-recent">
|
||||
{recent.map((a) => (
|
||||
<li key={a.id} className="armory-guild-recent-item">
|
||||
<img src={wowheadIcon(a.icon, 'medium')} alt="" className="armory-guild-recent-ico" loading="lazy" />
|
||||
<span className="armory-guild-recent-name">{a.name}</span>
|
||||
<span className="armory-guild-recent-date">{fmtDate(a.date)}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{info.classBreakdown.length > 0 && (
|
||||
<div className="armory-guild-card">
|
||||
<h3 className="armory-guild-card-title">{t('guildOverview')}</h3>
|
||||
<div className="armory-guild-chart-lbl">{t('guildClassBreak')}</div>
|
||||
<div className="armory-guild-chart">
|
||||
{info.classBreakdown.map((c: { class: number; count: number }) => (
|
||||
<div className="armory-guild-bar-col" key={c.class} title={`${className(c.class, locale)}: ${c.count}`}>
|
||||
<div className="armory-guild-bar-wrap">
|
||||
<div
|
||||
className="armory-guild-bar"
|
||||
style={{ height: `${Math.round((c.count / maxCount) * 100)}%`, background: classColor(c.class) }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="armory-guild-chart-lbl" style={{ marginTop: 14 }}>{t('guildRoleBreak')}</div>
|
||||
<div className="armory-guild-roles">
|
||||
{roleRows.map((r) => (
|
||||
<div className="armory-guild-role-row" key={r.key}>
|
||||
<span className="armory-guild-role-lbl" style={{ color: r.color }}>{r.label}</span>
|
||||
<div className="armory-guild-role-track">
|
||||
<div className="armory-guild-role-fill" style={{ width: `${Math.round((r.count / maxRole) * 100)}%`, background: r.color }} />
|
||||
</div>
|
||||
<span className="armory-guild-role-n">{r.count}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</aside>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/* ---- Vista Logros de hermandad (anillos por categoría) ---- */
|
||||
async function GuildLogros({
|
||||
guildId,
|
||||
locale,
|
||||
t,
|
||||
}: {
|
||||
guildId: number
|
||||
locale: string
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
t: any
|
||||
}) {
|
||||
const overview = await getGuildAchievementOverview(guildId, null, locale)
|
||||
return (
|
||||
<ArmoryAchievements
|
||||
locale={locale}
|
||||
guid={guildId}
|
||||
categories={overview.categories}
|
||||
earnedPoints={overview.earnedPoints}
|
||||
totalCompleted={overview.totalCompleted}
|
||||
apiPath="/api/armory/guild-achievements"
|
||||
idKey="guild"
|
||||
labels={{
|
||||
summary: t('achSummaryLine'), back: t('achBack'), reward: t('achReward'),
|
||||
empty: t('achEmptyCat'), of: t('achOf'), feats: t('achFeats'),
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user