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