move filter option configuration to constants.ts

This commit is contained in:
Pinapelz
2025-07-06 15:02:14 -07:00
parent b5c0c0a991
commit df79d68cb3
2 changed files with 37 additions and 30 deletions
+20 -30
View File
@@ -9,6 +9,8 @@ import DancerushScoreDisplay from "../components/displays/DancerushScoreDisplay"
type SortField = string;
type SortDirection = "asc" | "desc";
import { getFilterOptions } from "../types/constants";
const Score = () => {
const { user, isLoading, logout } = useAuth();
const navigate = useNavigate();
@@ -36,33 +38,24 @@ const Score = () => {
};
const renderRequestFilterMenu = () => {
if (gameName === "dancerush") {
const filterOptions = [
{ value: "timestamp", label: "Recent" },
{ value: "score", label: "Score" },
{ value: "lamp", label: "Rank" },
{ value: "lamo_diff", label: "Difficulty" },
];
return (
<div className="flex items-center space-x-2 bg-slate-900/50 backdrop-blur-sm rounded-xl p-1 border border-slate-800/50">
{filterOptions.map((option) => (
<button
key={option.value}
onClick={() => setRequestOrder(option.value)}
className={`px-4 py-2 rounded-lg text-sm font-medium transition-all duration-200 ${
requestOrder === option.value
? "bg-violet-600 text-white shadow-lg shadow-violet-500/25"
: "text-slate-300 hover:text-white hover:bg-slate-800/50"
}`}
>
{option.label}
</button>
))}
</div>
);
}
return null;
const filterOptions = getFilterOptions(gameName);
return (
<div className="flex items-center space-x-2 bg-slate-900/50 backdrop-blur-sm rounded-xl p-1 border border-slate-800/50">
{filterOptions.map((option) => (
<button
key={option.value}
onClick={() => setRequestOrder(option.value)}
className={`px-4 py-2 rounded-lg text-sm font-medium transition-all duration-200 ${
requestOrder === option.value
? "bg-violet-600 text-white shadow-lg shadow-violet-500/25"
: "text-slate-300 hover:text-white hover:bg-slate-800/50"
}`}
>
{option.label}
</button>
))}
</div>
);
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -167,9 +160,6 @@ const Score = () => {
{/* Filter Menu */}
<div className="flex items-center justify-between mb-6">
<div className="flex items-center space-x-4">
<span className="text-slate-300 text-sm font-medium">
Sort by:
</span>
{renderRequestFilterMenu()}
</div>
</div>
+17
View File
@@ -3,3 +3,20 @@ export const EamuseImportInfo: Record<string, { scorePage: string }> = {
scorePage: "https://p.eagate.573.jp/game/dan/1st/playdata/entrance.html#music_data",
},
};
export function getFilterOptions(game: string): { value: string; label: string }[] {
switch (game) {
case "dancerush":
return [
{ value: "timestamp", label: "Recent" },
{ value: "score", label: "Score" },
{ value: "lamp", label: "Rank" },
{ value: "lamp_diff", label: "Difficulty"}
];
default:
return [
{ value: "timestamp", label: "Recent" },
{ value: "score", label: "Score" },
];
}
}