Add navigation to RSVP form from event cards
This commit is contained in:
@@ -40,7 +40,7 @@ const App: React.FC = () => {
|
|||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<EventList />} />
|
<Route path="/" element={<EventList />} />
|
||||||
<Route path="/create" element={<EventForm />} />
|
<Route path="/create" element={<EventForm />} />
|
||||||
<Route path="/events/:slug" element={<RSVPForm />} />
|
<Route path="/events/:slug/rsvp" element={<RSVPForm />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ interface Event {
|
|||||||
description: string;
|
description: string;
|
||||||
date: string;
|
date: string;
|
||||||
location: string;
|
location: string;
|
||||||
|
slug: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EventList: React.FC = () => {
|
const EventList: React.FC = () => {
|
||||||
@@ -35,6 +36,10 @@ const EventList: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleEventClick = (event: Event) => {
|
||||||
|
navigate(`/events/${event.slug}/rsvp`);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 4 }}>
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 4 }}>
|
||||||
@@ -53,7 +58,15 @@ const EventList: React.FC = () => {
|
|||||||
<Grid container spacing={3}>
|
<Grid container spacing={3}>
|
||||||
{events.map((event) => (
|
{events.map((event) => (
|
||||||
<Grid item xs={12} key={event.id}>
|
<Grid item xs={12} key={event.id}>
|
||||||
<Card>
|
<Card
|
||||||
|
onClick={() => handleEventClick(event)}
|
||||||
|
sx={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
'&:hover': {
|
||||||
|
boxShadow: 6,
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Typography variant="h5" component="h2">
|
<Typography variant="h5" component="h2">
|
||||||
{event.title}
|
{event.title}
|
||||||
|
|||||||
Reference in New Issue
Block a user