refactor(guides) : consolidate duplicate guide and Stygian logic

This commit is contained in:
2026-10-07 01:41:13 +07:00 Unverified
parent 3c8f60433a
commit b35c1a4471
17 changed files with 268 additions and 171 deletions
+8 -6
View File
@@ -9,6 +9,7 @@ import {
import { elementIconFilter } from "@/lib/catalog/element";
import { characterRarityGradientClass, rarityGradientClass } from "@/lib/catalog/rarity";
import type { getActiveCatalog } from "@/lib/guides/queries";
import { stygianBossPositionLabels, stygianBossPositions, stygianLevels } from "@/lib/stygian/constants";
import type { getStygianSchedule } from "@/lib/stygian/repository";
import { cn } from "@/lib/utils";
@@ -103,23 +104,24 @@ export function StygianGuide({ schedule, catalog }: { schedule: Schedule; catalo
return (
<Tabs defaultValue="110">
<TabsList aria-label="Stygian difficulty">
<TabsTrigger value="105">Level 105</TabsTrigger>
<TabsTrigger value="110">Level 110</TabsTrigger>
{stygianLevels.map((level) => (
<TabsTrigger key={level} value={String(level)}>Level {level}</TabsTrigger>
))}
</TabsList>
{([105, 110] as const).map((level) => (
{stygianLevels.map((level) => (
<TabsContent key={level} value={String(level)}>
<Tabs defaultValue="0">
<TabsList variant="line" className="grid w-full grid-cols-3 overflow-hidden group-data-horizontal/tabs:h-auto" aria-label={`Level ${level} bosses`}>
{[0, 1, 2].map((position) => {
{stygianBossPositions.map((position) => {
const boss = schedule.bosses.find((candidate) => candidate.level === level && candidate.position === position);
const label = boss?.name ?? `Boss ${position + 1}`;
const positionLabel = ["บน", "กลาง", "ล่าง"][position];
const positionLabel = stygianBossPositionLabels[position];
return <TabsTrigger key={position} value={String(position)} aria-label={`${positionLabel}: ${label}`} title={label} className="h-full min-w-0 flex-col justify-start overflow-hidden rounded-none px-1 py-2 data-active:bg-accent/50 data-active:ring-2 data-active:ring-primary data-active:ring-inset sm:px-2 sm:py-3">
<StygianBossTab boss={boss} position={position} priority={level === 110} />
</TabsTrigger>;
})}
</TabsList>
{[0, 1, 2].map((position) => <TabsContent key={position} value={String(position)} className="pt-4"><BossCard schedule={schedule} level={level} position={position} catalog={catalog} /></TabsContent>)}
{stygianBossPositions.map((position) => <TabsContent key={position} value={String(position)} className="pt-4"><BossCard schedule={schedule} level={level} position={position} catalog={catalog} /></TabsContent>)}
</Tabs>
</TabsContent>
))}