Refactor admin actions and improve code formatting: Standardize import statements, enhance error handling messages, and apply consistent formatting across event, user, and preference management functions for better readability and maintainability.
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
This commit is contained in:
@@ -19,7 +19,12 @@ interface AdminPanelProps {
|
||||
initialPreferences: SitePreferences;
|
||||
}
|
||||
|
||||
type AdminSection = "preferences" | "users" | "events" | "feedbacks" | "challenges";
|
||||
type AdminSection =
|
||||
| "preferences"
|
||||
| "users"
|
||||
| "events"
|
||||
| "feedbacks"
|
||||
| "challenges";
|
||||
|
||||
export default function AdminPanel({ initialPreferences }: AdminPanelProps) {
|
||||
const [activeSection, setActiveSection] =
|
||||
|
||||
@@ -37,4 +37,3 @@ export default function Footer() {
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { Avatar } from "@/components/ui";
|
||||
import { getCharacterClassIcon, getCharacterClassName, type CharacterClass } from "@/lib/character-classes";
|
||||
import {
|
||||
getCharacterClassIcon,
|
||||
getCharacterClassName,
|
||||
type CharacterClass,
|
||||
} from "@/lib/character-classes";
|
||||
|
||||
interface LeaderboardEntry {
|
||||
rank: number;
|
||||
@@ -99,7 +103,8 @@ export default function Leaderboard() {
|
||||
</span>
|
||||
{entry.characterClass && (
|
||||
<span className="text-xs text-gray-400 uppercase tracking-wider">
|
||||
[{getCharacterClassIcon(entry.characterClass)} {getCharacterClassName(entry.characterClass)}]
|
||||
[{getCharacterClassIcon(entry.characterClass)}{" "}
|
||||
{getCharacterClassName(entry.characterClass)}]
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -49,4 +49,3 @@ export default function BackgroundSection({
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ export default function Badge({
|
||||
}: BadgeProps) {
|
||||
const variantStyles = {
|
||||
default: {
|
||||
backgroundColor: "color-mix(in srgb, var(--accent-color) 20%, transparent)",
|
||||
backgroundColor:
|
||||
"color-mix(in srgb, var(--accent-color) 20%, transparent)",
|
||||
borderColor: "color-mix(in srgb, var(--accent-color) 50%, transparent)",
|
||||
color: "var(--accent-color)",
|
||||
},
|
||||
@@ -45,7 +46,8 @@ export default function Badge({
|
||||
color: "var(--yellow)",
|
||||
},
|
||||
danger: {
|
||||
backgroundColor: "color-mix(in srgb, var(--destructive) 20%, transparent)",
|
||||
backgroundColor:
|
||||
"color-mix(in srgb, var(--destructive) 20%, transparent)",
|
||||
borderColor: "color-mix(in srgb, var(--destructive) 50%, transparent)",
|
||||
color: "var(--destructive)",
|
||||
},
|
||||
@@ -66,4 +68,3 @@ export default function Badge({
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,4 +39,3 @@ export default function Card({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,4 +26,3 @@ export default function CloseButton({
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,7 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
{error && (
|
||||
<p className="text-red-400 text-xs mt-1">{error}</p>
|
||||
)}
|
||||
{error && <p className="text-red-400 text-xs mt-1">{error}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -46,4 +44,3 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
Input.displayName = "Input";
|
||||
|
||||
export default Input;
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ export default function Modal({
|
||||
<div
|
||||
className="fixed inset-0 z-[200] flex items-center justify-center p-4 backdrop-blur-sm"
|
||||
style={{
|
||||
backgroundColor: "color-mix(in srgb, var(--background) 80%, transparent)",
|
||||
backgroundColor:
|
||||
"color-mix(in srgb, var(--background) 80%, transparent)",
|
||||
}}
|
||||
onClick={closeOnOverlayClick ? onClose : undefined}
|
||||
>
|
||||
@@ -49,7 +50,8 @@ export default function Modal({
|
||||
className={`border-2 rounded-lg w-full ${sizeClasses[size]} max-h-[90vh] overflow-y-auto shadow-2xl`}
|
||||
style={{
|
||||
backgroundColor: "var(--card-hover)",
|
||||
borderColor: "color-mix(in srgb, var(--accent-color) 70%, transparent)",
|
||||
borderColor:
|
||||
"color-mix(in srgb, var(--accent-color) 70%, transparent)",
|
||||
}}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
@@ -58,4 +60,3 @@ export default function Modal({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,10 @@ interface ProgressBarProps extends HTMLAttributes<HTMLDivElement> {
|
||||
label?: string;
|
||||
}
|
||||
|
||||
const getGradientStyle = (variant: "hp" | "xp" | "default", percentage: number) => {
|
||||
const getGradientStyle = (
|
||||
variant: "hp" | "xp" | "default",
|
||||
percentage: number
|
||||
) => {
|
||||
if (variant === "hp") {
|
||||
if (percentage > 60) {
|
||||
return {
|
||||
@@ -50,7 +53,10 @@ export default function ProgressBar({
|
||||
return (
|
||||
<div className={className} {...props}>
|
||||
{showLabel && (
|
||||
<div className="flex justify-between text-xs mb-1" style={{ color: "var(--gray-400)" }}>
|
||||
<div
|
||||
className="flex justify-between text-xs mb-1"
|
||||
style={{ color: "var(--gray-400)" }}
|
||||
>
|
||||
<span>{label || variant.toUpperCase()}</span>
|
||||
<span>
|
||||
{value} / {max}
|
||||
@@ -74,7 +80,8 @@ export default function ProgressBar({
|
||||
<div
|
||||
className="absolute inset-0"
|
||||
style={{
|
||||
background: "linear-gradient(to right, transparent, color-mix(in srgb, var(--foreground) 10%, transparent), transparent)",
|
||||
background:
|
||||
"linear-gradient(to right, transparent, color-mix(in srgb, var(--foreground) 10%, transparent), transparent)",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@@ -88,4 +95,3 @@ export default function ProgressBar({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,10 @@ export default function StarRating({
|
||||
}}
|
||||
className={`transition-transform hover:scale-110 disabled:hover:scale-100 disabled:cursor-not-allowed ${sizeClasses[size]}`}
|
||||
style={{
|
||||
color: star <= displayValue ? "var(--accent-color)" : "var(--gray-500)",
|
||||
color:
|
||||
star <= displayValue
|
||||
? "var(--accent-color)"
|
||||
: "var(--gray-500)",
|
||||
}}
|
||||
aria-label={`Noter ${star} étoile${star > 1 ? "s" : ""}`}
|
||||
>
|
||||
@@ -69,11 +72,8 @@ export default function StarRating({
|
||||
))}
|
||||
</div>
|
||||
{showValue && value > 0 && (
|
||||
<p className="text-gray-500 text-xs text-center">
|
||||
{value}/5
|
||||
</p>
|
||||
<p className="text-gray-500 text-xs text-center">{value}/5</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,10 @@ interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
||||
}
|
||||
|
||||
const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
||||
({ label, error, showCharCount, maxLength, className = "", value, ...props }, ref) => {
|
||||
(
|
||||
{ label, error, showCharCount, maxLength, className = "", value, ...props },
|
||||
ref
|
||||
) => {
|
||||
const charCount = typeof value === "string" ? value.length : 0;
|
||||
|
||||
return (
|
||||
@@ -46,9 +49,7 @@ const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
||||
{charCount}/{maxLength} caractères
|
||||
</p>
|
||||
)}
|
||||
{error && (
|
||||
<p className="text-red-400 text-xs mt-1">{error}</p>
|
||||
)}
|
||||
{error && <p className="text-red-400 text-xs mt-1">{error}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -57,4 +58,3 @@ const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
||||
Textarea.displayName = "Textarea";
|
||||
|
||||
export default Textarea;
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ export default function ThemeToggle() {
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.borderColor = "var(--accent-color)";
|
||||
e.currentTarget.style.backgroundColor = "color-mix(in srgb, var(--accent-color) 10%, transparent)";
|
||||
e.currentTarget.style.backgroundColor =
|
||||
"color-mix(in srgb, var(--accent-color) 10%, transparent)";
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.borderColor = "var(--border)";
|
||||
@@ -28,4 +29,3 @@ export default function ThemeToggle() {
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,4 +12,3 @@ export { default as BackgroundSection } from "./BackgroundSection";
|
||||
export { default as Alert } from "./Alert";
|
||||
export { default as CloseButton } from "./CloseButton";
|
||||
export { default as ThemeToggle } from "./ThemeToggle";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user