diff --git a/frontend/src/components/Footer.jsx b/frontend/src/components/Footer.jsx index 1c673df..b2189dd 100644 --- a/frontend/src/components/Footer.jsx +++ b/frontend/src/components/Footer.jsx @@ -1,125 +1,119 @@ import { Link, useLocation } from 'react-router-dom' import { useAuth } from '../context/AuthContext' - + +function FooterLink({ to, children, className = '', pathname }) { + return pathname === to ? ( + {children} + ) : ( + + {children} + + ) +} + export default function Footer() { const { pathname } = useLocation() const { user } = useAuth() const isLoggedIn = !!user - - function FooterLink({ to, children, className=''}) { - return pathname === to ? ( - {children} - ) : ( - - {children} - - ) - } + return ( ) -} \ No newline at end of file +} diff --git a/frontend/src/context/AuthContext.jsx b/frontend/src/context/AuthContext.jsx index 552cb66..5035bb7 100644 --- a/frontend/src/context/AuthContext.jsx +++ b/frontend/src/context/AuthContext.jsx @@ -1,3 +1,5 @@ +/* eslint-disable react-refresh/only-export-components */ + import { createContext, useContext, useState } from 'react' const AuthContext = createContext(null) diff --git a/frontend/src/pages/Admin.jsx b/frontend/src/pages/Admin.jsx index 4272e81..94c0750 100644 --- a/frontend/src/pages/Admin.jsx +++ b/frontend/src/pages/Admin.jsx @@ -56,7 +56,7 @@ export default function Admin() { if (!handleAuthError(e)) setError(e.message) }) .finally(() => setLoading(false)) - }, []) + }, [handleAuthError]) const handleDraw = async () => { setShowConfirm(false) @@ -94,7 +94,7 @@ export default function Admin() { const csv = [header, ...rows] .map((row) => row.map((cell) => `"${String(cell).replace(/"/g, '""')}"`).join(';')) .join('\n') - const blob = new Blob([`${csv}`], { type: 'text/csv;charset=utf-8;' }) + const blob = new Blob(['\uFEFF' + csv], { type: 'text/csv;charset=utf-8;' }) const url = URL.createObjectURL(blob) const link = document.createElement('a') link.href = url diff --git a/frontend/src/pages/MesGains.jsx b/frontend/src/pages/MesGains.jsx index dcb45f3..d432a44 100644 --- a/frontend/src/pages/MesGains.jsx +++ b/frontend/src/pages/MesGains.jsx @@ -50,7 +50,20 @@ export default function MesGains() { } }, [handleAuthError]) - useEffect(() => { fetchGains() }, [fetchGains]) + useEffect(() => { + const loadGains = async () => { + try { + const data = await myGainsApi() + setGains(data.gains) + } catch (err) { + if (!handleAuthError(err)) setError(err.message) + } finally { + setLoading(false) + } + } + + loadGains() +}, [handleAuthError]) return (
diff --git a/frontend/src/pages/Profile.jsx b/frontend/src/pages/Profile.jsx index 612d848..5861aef 100644 --- a/frontend/src/pages/Profile.jsx +++ b/frontend/src/pages/Profile.jsx @@ -1,20 +1,12 @@ import { useState } from 'react' -import { useNavigate } from 'react-router-dom' import UserNav from '../components/UserNav' -import { changePasswordApi, deleteAccountApi } from '../services/auth' +import { changePasswordApi} from '../services/auth' import { useHandleAuthError } from '../hooks/useHandleAuthError' -import { useAuth } from '../context/AuthContext' export default function Profile() { const user = JSON.parse(localStorage.getItem('user') || '{}') const initials = `${(user.firstname || '?')[0]}${(user.lastname || '?')[0]}`.toUpperCase() const handleAuthError = useHandleAuthError() - const { logout } = useAuth() - const navigate = useNavigate() - - const [showDeleteModal, setShowDeleteModal] = useState(false) - const [deleting, setDeleting] = useState(false) - const [deleteError, setDeleteError] = useState('') const [pwForm, setPwForm] = useState({ currentPassword: '', newPassword: '', confirmPassword: '' }) const [showPw, setShowPw] = useState({ current: false, new: false, confirm: false }) diff --git a/frontend/src/pages/SaisirCodeUnique.jsx b/frontend/src/pages/SaisirCodeUnique.jsx index 60e4bf9..3b3ccba 100644 --- a/frontend/src/pages/SaisirCodeUnique.jsx +++ b/frontend/src/pages/SaisirCodeUnique.jsx @@ -17,7 +17,6 @@ export default function SaisirCodeUnique() { const [code, setCode] = useState('') const [loading, setLoading] = useState(false) const [gain, setGain] = useState(null) - const [claim, setClaim] = useState(null) const [wonAt, setWonAt] = useState(null) const [showDetail, setShowDetail] = useState(false) @@ -27,7 +26,6 @@ export default function SaisirCodeUnique() { try { const data = await participateApi(code.trim().toUpperCase()) setGain(data.gain) - setClaim(data.claim) setWonAt(new Date()) } catch (err) { if (!handleAuthError(err)) { @@ -40,7 +38,6 @@ export default function SaisirCodeUnique() { const handleClose = () => { setGain(null) - setClaim(null) setWonAt(null) setShowDetail(false) setCode('')