Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/(admin)/workshops/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default function WorkshopsPage() {

return (
<main>
<Link href="/my-events">My Events</Link>
<h1>Workshops</h1>

{workshops.length === 0 ? (
Expand All @@ -69,7 +70,11 @@ export default function WorkshopsPage() {
<tbody>
{workshops.map(workshop => (
<tr key={workshop.id}>
<td>{workshop.name}</td>
<td>
<Link href={`/workshops/${workshop.id}`}>
{workshop.name}
</Link>
</td>
<td>{workshop.start_date ?? "Not set"}</td>
<td>{workshop.end_date ?? "Not set"}</td>
<td>{workshop.capacity ?? "Not set"}</td>
Expand Down
74 changes: 2 additions & 72 deletions app/(participant)/my-workshops/page.tsx
Original file line number Diff line number Diff line change
@@ -1,75 +1,5 @@
"use client";

import type { Workshop } from "@/types/workshop";
import { useEffect, useState } from "react";
import Link from "next/link";
import { fetchMyWorkshops } from "@/actions/supabase/queries/registrations";
import { redirect } from "next/navigation";

export default function MyWorkshopsPage() {
const [workshops, setWorkshops] = useState<Workshop[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);

useEffect(() => {
let ignore = false;

async function loadWorkshops() {
try {
const data = await fetchMyWorkshops();

if (!ignore) {
setWorkshops(data);
}
} catch (err) {
if (!ignore) {
setError(
err instanceof Error
? err.message
: "Could not load your workshops.",
);
}
} finally {
if (!ignore) {
setLoading(false);
}
}
}

loadWorkshops();

return () => {
ignore = true;
};
}, []);

if (loading) {
return <p>Loading your workshops...</p>;
}

if (error) {
return <p role="alert">{error}</p>;
}

return (
<main>
<h1>My workshops</h1>

{workshops.length === 0 ? (
<p>You haven’t registered for any workshops yet.</p>
) : (
<ul>
{workshops.map(workshop => (
<li key={workshop.id}>
<h2>
<Link href={`/workshops/${workshop.id}`}>{workshop.name}</Link>
</h2>
<p>Start date: {workshop.start_date ?? "Not set"}</p>
<p>End date: {workshop.end_date ?? "Not set"}</p>
<p>Location: {workshop.location ?? "Not set"}</p>
</li>
))}
</ul>
)}
</main>
);
redirect("/my-events");
}
3 changes: 3 additions & 0 deletions app/(participant)/workshops/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ export default function WorkshopDetailsPage() {

return (
<main>
<nav aria-label="Participant navigation">
<Link href="/my-events">My Events</Link>
</nav>
<h1>{workshop.name}</h1>

<p>{workshop.description ?? "No description provided."}</p>
Expand Down
135 changes: 135 additions & 0 deletions app/my-events/page.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
.page {
max-width: 960px;
margin: 0 auto;
padding: 32px 20px 64px;
color: #172b3a;
line-height: 1.5;
}

.nav {
display: flex;
gap: 24px;
margin-bottom: 28px;
}

.page a {
color: #224e6b;
text-underline-offset: 3px;
}

.header {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-bottom: 24px;
}

.header h1 {
font-size: 2rem;
margin-bottom: 8px;
}

.section {
margin-top: 32px;
}

.section h2 {
margin-bottom: 12px;
}

.count,
.meta {
color: #465e6e;
}

.count {
font-size: 1rem;
font-weight: 400;
}

.list {
list-style: none;
padding: 0;
display: grid;
gap: 16px;
}

.card {
border: 1px solid #b6c2cb;
border-radius: 8px;
padding: 20px;
overflow-wrap: anywhere;
}

.card h3 {
margin-bottom: 8px;
}

.empty {
padding: 20px;
border-radius: 8px;
background: #f2f5f7;
}

.page button {
min-height: 44px;
padding: 10px 16px;
border: 1px solid #224e6b;
border-radius: 4px;
color: #224e6b;
background: #fff;
font: inherit;
font-weight: 600;
cursor: pointer;
}

.page .cancel {
margin-top: 16px;
}

.confirmation {
margin-top: 16px;
padding: 16px;
border-left: 3px solid #224e6b;
background: #f2f5f7;
}

.confirmActions {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-top: 12px;
}

.page button:disabled {
cursor: wait;
opacity: 0.65;
}

.page :is(a, button, h1):focus-visible {
outline: 3px solid #2074a5;
outline-offset: 4px;
}

.error,
.success {
margin-bottom: 16px;
padding: 16px;
border-radius: 4px;
}

.error {
color: #a52020;
background: #fff1f1;
}

.error button {
margin-top: 12px;
}

.success {
color: #176336;
background: #edf8f0;
}
Loading
Loading