fix: arthur issue

This commit is contained in:
Malopieds 2025-10-22 11:18:10 +02:00
parent 6ef6545814
commit c7384837c3

View File

@ -9,9 +9,17 @@ function Dashboard() {
const [dashboard, setDashboard] = useState<DashboardType | null>(null);
const username = localStorage.getItem("username");
useEffect(() => {
axios.get("/api/dashboard").then((res) => {
setDashboard(res.data);
});
axios
.get("/api/dashboard")
.then((res) => {
setDashboard(res.data);
})
.catch((err) => {
console.log(err);
if (err.response.status === 401 || err.response.status === 403) {
window.location.href = "/login";
}
});
}, []);
return (
@ -28,73 +36,79 @@ function Dashboard() {
</section>
{dashboard && (
<>
{ dashboard.jiRespo.length !== 0 && (
<section className="py-16">
<div className="container mx-auto">
<h3 className="text-2xl font-bold text-center mb-6">
Immersions - Respo
</h3>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6 gap-6">
{dashboard.jiRespo.map((jiRespo: Ji) => (
<div
key={jiRespo.id}
className="card card-compact bg-base-200 shadow-lg p-4"
>
<div className="card-body">
<h2 className="card-title">{jiRespo.name}</h2>
<p>{jiRespo.description}</p>
<div className="card-actions justify-end">
<Link to={`/immersion/${jiRespo.id}`} className="btn btn-primary btn-sm">
GO
</Link>
{dashboard.jiRespo.length !== 0 && (
<section className="py-16">
<div className="container mx-auto">
<h3 className="text-2xl font-bold text-center mb-6">
Immersions - Respo
</h3>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6 gap-6">
{dashboard.jiRespo.map((jiRespo: Ji) => (
<div
key={jiRespo.id}
className="card card-compact bg-base-200 shadow-lg p-4"
>
<div className="card-body">
<h2 className="card-title">{jiRespo.name}</h2>
<p>{jiRespo.description}</p>
<div className="card-actions justify-end">
<Link
to={`/immersion/${jiRespo.id}`}
className="btn btn-primary btn-sm"
>
GO
</Link>
</div>
</div>
</div>
</div>
))}
))}
</div>
</div>
</div>
</section>
)}
{ dashboard.sujetRespo.length !== 0 && (
<section className="py-8">
<div className="container mx-auto">
<h3 className="text-2xl font-bold text-center mb-6">Sujets - Respo</h3>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{dashboard.sujetRespo.map((sujet: Sujet) => (
<div
key={sujetRespo.id}
className="card card-compact bg-base-200 shadow-lg p-4"
>
<div className="card-body">
<h2 className="card-title">{sujetRespo.name}</h2>
{sujetRespo && (
<p className="text-lg">Linked to: {sujetRespo.name}</p>
)}
<div className="card-actions justify-end">
{false && (
<Link
to={`/subject/${sujetRespo.id}`}
className="btn btn-primary"
>
Learn More
</Link>
)}
</section>
)}
{dashboard.sujetRespo.length !== 0 && (
<section className="py-8">
<div className="container mx-auto">
<h3 className="text-2xl font-bold text-center mb-6">
Sujets - Respo
</h3>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{dashboard.sujetRespo.map((sujet: Sujet) => (
<div
key={sujetRespo.id}
className="card card-compact bg-base-200 shadow-lg p-4"
>
<div className="card-body">
<h2 className="card-title">{sujetRespo.name}</h2>
{sujetRespo && (
<Link
to={`/subject/${sujetRespo.id}`}
className="btn btn-primary"
>
See TP
</Link>
<p className="text-lg">
Linked to: {sujetRespo.name}
</p>
)}
<div className="card-actions justify-end">
{false && (
<Link
to={`/subject/${sujetRespo.id}`}
className="btn btn-primary"
>
Learn More
</Link>
)}
{sujetRespo && (
<Link
to={`/subject/${sujetRespo.id}`}
className="btn btn-primary"
>
See TP
</Link>
)}
</div>
</div>
</div>
</div>
))}
))}
</div>
</div>
</div>
</section>
</section>
)}
<section className="py-16">
<div className="container mx-auto">
@ -111,7 +125,10 @@ function Dashboard() {
<h2 className="card-title">{jiParticipant.name}</h2>
<p>{jiParticipant.description}</p>
<div className="card-actions justify-end">
<Link to={`/immersion/${jiParticipant.id}`} className="btn btn-primary">
<Link
to={`/immersion/${jiParticipant.id}`}
className="btn btn-primary"
>
Learn More
</Link>
</div>
@ -120,13 +137,15 @@ function Dashboard() {
))}
</div>
{dashboard.jiParticipant.length === 0 && (
<div className="container mx-auto text-center">
<h1 className="text-xl">You are not registered on any activities.</h1>
</div>
<div className="container mx-auto text-center">
<h1 className="text-xl">
You are not registered on any activities.
</h1>
</div>
)}
</div>
</section>
<section className="py-8">
<section className="py-8">
<div className="container mx-auto text-center">
<h4 className="text-2xl font-semibold">Messages</h4>
<p className="mt-4 text-gray-700">You have no messages</p>