Remove ESLint configuration file and update type imports across components: Deleted eslint.config.js to streamline project setup. Updated type imports in layout, login, register, and other components to use direct imports for improved clarity and consistency. Enhanced error handling in various components and replaced apostrophes with HTML entities for better rendering.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Metadata } from "next";
|
||||
import type { ReactNode } from "react";
|
||||
import { Orbitron, Rajdhani } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import SessionProvider from "@/components/SessionProvider";
|
||||
@@ -23,7 +24,7 @@ export const metadata: Metadata = {
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
children: ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="fr" className={`${orbitron.variable} ${rajdhani.variable}`}>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useState, type FormEvent } from "react";
|
||||
import { signIn } from "next-auth/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
@@ -13,7 +13,7 @@ export default function LoginPage() {
|
||||
const [error, setError] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
const handleSubmit = async (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
setError("");
|
||||
setLoading(true);
|
||||
@@ -128,7 +128,7 @@ export default function LoginPage() {
|
||||
href="/register"
|
||||
className="text-pixel-gold hover:text-orange-400 transition"
|
||||
>
|
||||
S'inscrire
|
||||
S'inscrire
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
@@ -138,4 +138,3 @@ export default function LoginPage() {
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useRef } from "react";
|
||||
import { useState, useRef, type ChangeEvent, type FormEvent } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import Navigation from "@/components/Navigation";
|
||||
@@ -24,7 +24,7 @@ export default function RegisterPage() {
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const handleChange = (
|
||||
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
|
||||
e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
|
||||
) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
@@ -32,7 +32,7 @@ export default function RegisterPage() {
|
||||
});
|
||||
};
|
||||
|
||||
const handleAvatarUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const handleAvatarUpload = async (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
@@ -110,14 +110,14 @@ export default function RegisterPage() {
|
||||
|
||||
setUserId(data.userId);
|
||||
setStep(2);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
setError("Une erreur est survenue");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleStep2Submit = async (e: React.FormEvent) => {
|
||||
const handleStep2Submit = async (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
setError("");
|
||||
|
||||
@@ -245,7 +245,7 @@ export default function RegisterPage() {
|
||||
htmlFor="username"
|
||||
className="block text-sm font-semibold text-gray-300 mb-2 uppercase tracking-wider"
|
||||
>
|
||||
Nom d'utilisateur
|
||||
Nom d'utilisateur
|
||||
</label>
|
||||
<input
|
||||
id="username"
|
||||
@@ -413,7 +413,7 @@ export default function RegisterPage() {
|
||||
htmlFor="username-step2"
|
||||
className="block text-sm font-semibold text-gray-300 mb-2 uppercase tracking-wider"
|
||||
>
|
||||
Nom d'utilisateur
|
||||
Nom d'utilisateur
|
||||
</label>
|
||||
<input
|
||||
id="username-step2"
|
||||
|
||||
@@ -122,7 +122,7 @@ export default function AdminPanel({ initialPreferences }: AdminPanelProps) {
|
||||
Images de fond du site
|
||||
</h3>
|
||||
<p className="text-gray-400 text-sm">
|
||||
Ces préférences s'appliquent à tous les utilisateurs
|
||||
Ces préférences s'appliquent à tous les utilisateurs
|
||||
</p>
|
||||
</div>
|
||||
{!isEditing && (
|
||||
@@ -278,4 +278,3 @@ export default function AdminPanel({ initialPreferences }: AdminPanelProps) {
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -533,7 +533,7 @@ export default function EventsPageSection({
|
||||
...prev,
|
||||
[eventId]: true,
|
||||
}));
|
||||
} catch (err) {
|
||||
} catch {
|
||||
setError("Une erreur est survenue");
|
||||
} finally {
|
||||
setLoading((prev) => ({ ...prev, [eventId]: false }));
|
||||
@@ -559,7 +559,7 @@ export default function EventsPageSection({
|
||||
...prev,
|
||||
[eventId]: false,
|
||||
}));
|
||||
} catch (err) {
|
||||
} catch {
|
||||
setError("Une erreur est survenue");
|
||||
} finally {
|
||||
setLoading((prev) => ({ ...prev, [eventId]: false }));
|
||||
@@ -600,7 +600,7 @@ export default function EventsPageSection({
|
||||
</div>
|
||||
<p className="text-gray-400 text-sm max-w-2xl mx-auto">
|
||||
Rejoignez-nous pour des événements tech passionnants, des
|
||||
compétitions et des célébrations tout au long de l'année
|
||||
compétitions et des célébrations tout au long de l'année
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -100,11 +100,11 @@ export default function HeroSection() {
|
||||
|
||||
{/* Description */}
|
||||
<p className="text-white text-base md:text-lg max-w-3xl mx-auto mb-12 leading-relaxed px-4">
|
||||
Dans un monde numérique de technologie de pointe, où les systèmes d'IA
|
||||
évoluent et où d'anciens codes attendent d'être découverts. Partez
|
||||
pour un voyage épique pour forger des alliances, conquérir des défis
|
||||
et raconter votre histoire d'innovation au sein d'une communauté de
|
||||
gaming tech florissante.
|
||||
Dans un monde numérique de technologie de pointe, où les systèmes
|
||||
d'IA évoluent et où d'anciens codes attendent d'être
|
||||
découverts. Partez pour un voyage épique pour forger des alliances,
|
||||
conquérir des défis et raconter votre histoire d'innovation au
|
||||
sein d'une communauté de gaming tech florissante.
|
||||
</p>
|
||||
|
||||
{/* Call-to-Action Buttons */}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import { useState, useEffect, useRef, type ChangeEvent } from "react";
|
||||
|
||||
interface ImageSelectorProps {
|
||||
value: string;
|
||||
@@ -14,7 +14,6 @@ export default function ImageSelector({
|
||||
label,
|
||||
}: ImageSelectorProps) {
|
||||
const [availableImages, setAvailableImages] = useState<string[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const [urlInput, setUrlInput] = useState("");
|
||||
const [showGallery, setShowGallery] = useState(false);
|
||||
@@ -36,7 +35,7 @@ export default function ImageSelector({
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const handleFileUpload = async (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
@@ -153,9 +152,7 @@ export default function ImageSelector({
|
||||
</div>
|
||||
|
||||
{/* Chemin de l'image */}
|
||||
{value && (
|
||||
<p className="text-xs text-gray-400 truncate">{value}</p>
|
||||
)}
|
||||
{value && <p className="text-xs text-gray-400 truncate">{value}</p>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -204,4 +201,3 @@ export default function ImageSelector({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ export default function PlayerStats({ initialUserData }: PlayerStatsProps) {
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
if (data) {
|
||||
// Utiliser requestAnimationFrame pour éviter les cascades de rendu
|
||||
requestAnimationFrame(() => {
|
||||
setUserData({
|
||||
username: data.username || "Guest",
|
||||
avatar: data.avatar,
|
||||
@@ -60,10 +62,12 @@ export default function PlayerStats({ initialUserData }: PlayerStatsProps) {
|
||||
maxXp: data.maxXp || 5000,
|
||||
level: data.level || 1,
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// Utiliser les données de session si l'API échoue
|
||||
requestAnimationFrame(() => {
|
||||
setUserData({
|
||||
username: session.user.username || "Guest",
|
||||
avatar: null,
|
||||
@@ -74,8 +78,12 @@ export default function PlayerStats({ initialUserData }: PlayerStatsProps) {
|
||||
level: 1,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
});
|
||||
} else if (!initialUserData) {
|
||||
// Utiliser requestAnimationFrame pour éviter les cascades de rendu
|
||||
requestAnimationFrame(() => {
|
||||
setUserData(defaultUserData);
|
||||
});
|
||||
}
|
||||
}, [session, initialUserData]);
|
||||
|
||||
@@ -109,11 +117,13 @@ export default function PlayerStats({ initialUserData }: PlayerStatsProps) {
|
||||
clearTimeout(hpTimer);
|
||||
clearTimeout(xpTimer);
|
||||
};
|
||||
} else {
|
||||
}
|
||||
// Sinon, mettre à jour directement (pour les pages Client Components)
|
||||
// Utiliser requestAnimationFrame pour éviter les cascades de rendu
|
||||
requestAnimationFrame(() => {
|
||||
setHpPercentage(targetHpPercentage);
|
||||
setXpPercentage(targetXpPercentage);
|
||||
}
|
||||
});
|
||||
}, [targetHpPercentage, targetXpPercentage, initialUserData]);
|
||||
|
||||
const hpColor =
|
||||
@@ -126,7 +136,10 @@ export default function PlayerStats({ initialUserData }: PlayerStatsProps) {
|
||||
return (
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Avatar */}
|
||||
<Link href="/profile" className="cursor-pointer hover:opacity-80 transition-opacity">
|
||||
<Link
|
||||
href="/profile"
|
||||
className="cursor-pointer hover:opacity-80 transition-opacity"
|
||||
>
|
||||
<div className="w-10 h-10 rounded-full border border-pixel-gold/20 overflow-hidden bg-gray-900 flex items-center justify-center">
|
||||
{avatar ? (
|
||||
<img
|
||||
@@ -146,7 +159,10 @@ export default function PlayerStats({ initialUserData }: PlayerStatsProps) {
|
||||
<div className="flex flex-col gap-1.5 min-w-[200px]">
|
||||
{/* Username & Level */}
|
||||
<div className="flex items-center gap-2">
|
||||
<Link href="/profile" className="cursor-pointer hover:text-pixel-gold/80 transition-colors">
|
||||
<Link
|
||||
href="/profile"
|
||||
className="cursor-pointer hover:text-pixel-gold/80 transition-colors"
|
||||
>
|
||||
<div className="text-pixel-gold font-gaming font-bold text-sm tracking-wider">
|
||||
{username}
|
||||
</div>
|
||||
@@ -210,4 +226,3 @@ export default function PlayerStats({ initialUserData }: PlayerStatsProps) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useRef } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState, useRef, type ChangeEvent } from "react";
|
||||
|
||||
type CharacterClass =
|
||||
| "WARRIOR"
|
||||
@@ -45,7 +44,6 @@ export default function ProfileForm({
|
||||
initialProfile,
|
||||
backgroundImage,
|
||||
}: ProfileFormProps) {
|
||||
const router = useRouter();
|
||||
const [profile, setProfile] = useState<UserProfile>(initialProfile);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -67,7 +65,7 @@ export default function ProfileForm({
|
||||
const [confirmPassword, setConfirmPassword] = useState("");
|
||||
const [changingPassword, setChangingPassword] = useState(false);
|
||||
|
||||
const handleAvatarUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const handleAvatarUpload = async (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
@@ -325,7 +323,7 @@ export default function ProfileForm({
|
||||
{/* Username Field */}
|
||||
<div>
|
||||
<label className="block text-pixel-gold text-sm uppercase tracking-widest mb-2">
|
||||
Nom d'utilisateur
|
||||
Nom d'utilisateur
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import { type ReactNode } from "react";
|
||||
import { SessionProvider as NextAuthSessionProvider } from "next-auth/react";
|
||||
|
||||
export default function SessionProvider({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
export default function SessionProvider({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<NextAuthSessionProvider basePath="/api/auth">
|
||||
{children}
|
||||
</NextAuthSessionProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
import js from '@eslint/js';
|
||||
import tseslint from '@typescript-eslint/eslint-plugin';
|
||||
import tsparser from '@typescript-eslint/parser';
|
||||
import react from 'eslint-plugin-react';
|
||||
import reactHooks from 'eslint-plugin-react-hooks';
|
||||
import globals from 'globals';
|
||||
|
||||
export default [
|
||||
js.configs.recommended,
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
languageOptions: {
|
||||
parser: tsparser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.browser,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
'@typescript-eslint': tseslint,
|
||||
react,
|
||||
'react-hooks': reactHooks,
|
||||
},
|
||||
rules: {
|
||||
...tseslint.configs.recommended.rules,
|
||||
...react.configs.recommended.rules,
|
||||
...reactHooks.configs.recommended.rules,
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/prop-types': 'off',
|
||||
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'react/no-unescaped-entities': 'warn',
|
||||
'react/no-unknown-property': ['error', { ignore: ['jsx'] }],
|
||||
'react-hooks/set-state-in-effect': 'warn',
|
||||
'@typescript-eslint/triple-slash-reference': 'off',
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: [
|
||||
'node_modules/**',
|
||||
'.next/**',
|
||||
'out/**',
|
||||
'build/**',
|
||||
'dist/**',
|
||||
'*.config.js',
|
||||
'prisma/generated/**',
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -48,7 +48,10 @@ export function useBackgroundImage(
|
||||
if (preferences) {
|
||||
const imageKey = `${page}Background` as keyof Preferences;
|
||||
const customImage = preferences[imageKey];
|
||||
// Utiliser requestAnimationFrame pour éviter les cascades de rendu
|
||||
requestAnimationFrame(() => {
|
||||
setBackgroundImage(customImage || defaultImage);
|
||||
});
|
||||
}
|
||||
}, [preferences, page, defaultImage]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user