diff --git a/components/ProfileForm.tsx b/components/ProfileForm.tsx index 77b3520..2c2d224 100644 --- a/components/ProfileForm.tsx +++ b/components/ProfileForm.tsx @@ -147,7 +147,9 @@ export default function ProfileForm({ setTimeout(() => setSuccess(null), 3000); } else { const errorData = await response.json(); - setError(errorData.error || "Erreur lors de la modification du mot de passe"); + setError( + errorData.error || "Erreur lors de la modification du mot de passe" + ); } } catch (err) { console.error("Error changing password:", err); @@ -238,6 +240,45 @@ export default function ProfileForm({ )} + + {/* Avatars par défaut */} +
+ +
+ {[ + "/avatar-1.jpg", + "/avatar-2.jpg", + "/avatar-3.jpg", + "/avatar-4.jpg", + "/avatar-5.jpg", + "/avatar-6.jpg", + ].map((defaultAvatar) => ( + + ))} +
+
+
- {uploadingAvatar ? "Upload en cours..." : "Changer l'avatar"} + {uploadingAvatar + ? "Upload en cours..." + : "Upload un avatar custom"}
@@ -270,9 +313,7 @@ export default function ProfileForm({ minLength={3} maxLength={20} /> -

- 3-20 caractères -

+

3-20 caractères

{/* Stats Display */} @@ -283,13 +324,17 @@ export default function ProfileForm({
-
Score
+
+ Score +
{formatNumber(profile.score)}
-
Niveau
+
+ Niveau +
Lv.{profile.level}
@@ -300,7 +345,9 @@ export default function ProfileForm({
HP - {profile.hp} / {profile.maxHp} + + {profile.hp} / {profile.maxHp} +
XP - {formatNumber(profile.xp)} / {formatNumber(profile.maxXp)} + + {formatNumber(profile.xp)} / {formatNumber(profile.maxXp)} +
- {changingPassword ? "Modification..." : "Modifier le mot de passe"} + {changingPassword + ? "Modification..." + : "Modifier le mot de passe"}
@@ -443,4 +494,3 @@ export default function ProfileForm({ ); } - diff --git a/components/WebpackErrorHandler.tsx b/components/WebpackErrorHandler.tsx new file mode 100644 index 0000000..634ea20 --- /dev/null +++ b/components/WebpackErrorHandler.tsx @@ -0,0 +1,84 @@ +"use client"; + +import { useEffect } from "react"; + +export default function WebpackErrorHandler() { + useEffect(() => { + // Listen for unhandled errors + const handleError = (event: ErrorEvent) => { + const error = event.error || event.message || ""; + const errorString = String(error); + + // Check if it's a webpack module loading error + if ( + errorString.includes("Cannot read properties of undefined") && + (errorString.includes("reading 'call'") || + errorString.includes("webpack") || + errorString.includes("react-server-dom-webpack")) + ) { + console.warn( + "Webpack module loading error detected, forcing page reload..." + ); + + // Clear all caches and reload + if (typeof window !== "undefined") { + // Clear service worker cache if exists + if ("serviceWorker" in navigator) { + navigator.serviceWorker.getRegistrations().then((registrations) => { + registrations.forEach((registration) => { + registration.unregister(); + }); + }); + } + + // Clear all caches + if ("caches" in window) { + caches.keys().then((names) => { + names.forEach((name) => { + caches.delete(name); + }); + }); + } + + // Force hard reload after a short delay + setTimeout(() => { + window.location.reload(); + }, 100); + } + } + }; + + // Listen for unhandled promise rejections + const handleRejection = (event: PromiseRejectionEvent) => { + const error = event.reason || ""; + const errorString = String(error); + + if ( + errorString.includes("Cannot read properties of undefined") && + (errorString.includes("reading 'call'") || + errorString.includes("webpack") || + errorString.includes("react-server-dom-webpack")) + ) { + console.warn( + "Webpack module loading error detected in promise, forcing page reload..." + ); + + if (typeof window !== "undefined") { + setTimeout(() => { + window.location.reload(); + }, 100); + } + } + }; + + window.addEventListener("error", handleError); + window.addEventListener("unhandledrejection", handleRejection); + + return () => { + window.removeEventListener("error", handleError); + window.removeEventListener("unhandledrejection", handleRejection); + }; + }, []); + + return null; +} diff --git a/next.config.js b/next.config.js index 159d810..91ef62f 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, -} - -module.exports = nextConfig +}; +module.exports = nextConfig; diff --git a/public/avatar-1.jpg b/public/avatar-1.jpg new file mode 100644 index 0000000..8806c27 Binary files /dev/null and b/public/avatar-1.jpg differ diff --git a/public/avatar-2.jpg b/public/avatar-2.jpg new file mode 100644 index 0000000..f6c1424 Binary files /dev/null and b/public/avatar-2.jpg differ diff --git a/public/avatar-3.jpg b/public/avatar-3.jpg new file mode 100644 index 0000000..54985d4 Binary files /dev/null and b/public/avatar-3.jpg differ diff --git a/public/avatar-4.jpg b/public/avatar-4.jpg new file mode 100644 index 0000000..9114498 Binary files /dev/null and b/public/avatar-4.jpg differ diff --git a/public/avatar-5.jpg b/public/avatar-5.jpg new file mode 100644 index 0000000..624f0b6 Binary files /dev/null and b/public/avatar-5.jpg differ diff --git a/public/avatar-6.jpg b/public/avatar-6.jpg new file mode 100644 index 0000000..de939ee Binary files /dev/null and b/public/avatar-6.jpg differ