WIP: update: adaptations to use the new backend #1

Draft
arthur.wambst wants to merge 21 commits from dev into master
Showing only changes of commit c7384837c3 - Show all commits

View File

@ -9,8 +9,16 @@ function Dashboard() {
const [dashboard, setDashboard] = useState<DashboardType | null>(null);
const username = localStorage.getItem("username");
useEffect(() => {
axios.get("/api/dashboard").then((res) => {
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";
}
});
}, []);
@ -28,7 +36,7 @@ function Dashboard() {
</section>
{dashboard && (
<>
{ dashboard.jiRespo.length !== 0 && (
{dashboard.jiRespo.length !== 0 && (
<section className="py-16">
<div className="container mx-auto">
<h3 className="text-2xl font-bold text-center mb-6">
@ -44,7 +52,10 @@ function Dashboard() {
<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">
<Link
to={`/immersion/${jiRespo.id}`}
className="btn btn-primary btn-sm"
>
GO
</Link>
</div>
@ -52,14 +63,15 @@ function Dashboard() {
</div>
))}
</div>
</div>
</section>
)}
{ dashboard.sujetRespo.length !== 0 && (
{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>
<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
@ -69,7 +81,9 @@ function Dashboard() {
<div className="card-body">
<h2 className="card-title">{sujetRespo.name}</h2>
{sujetRespo && (
<p className="text-lg">Linked to: {sujetRespo.name}</p>
<p className="text-lg">
Linked to: {sujetRespo.name}
</p>
)}
<div className="card-actions justify-end">
{false && (
@ -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>
@ -121,7 +138,9 @@ 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>
<h1 className="text-xl">
You are not registered on any activities.
</h1>
</div>
)}
</div>