Initial commit: RSVP Manager with React frontend and Express backend

This commit is contained in:
2025-04-29 13:08:01 -04:00
commit b80879f46b
17 changed files with 697 additions and 0 deletions

View File

@@ -0,0 +1,108 @@
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import {
Box,
Button,
TextField,
Typography,
Container,
} from '@mui/material';
import axios from 'axios';
const EventForm: React.FC = () => {
const navigate = useNavigate();
const [formData, setFormData] = useState({
title: '',
description: '',
date: '',
location: '',
});
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target;
setFormData((prev) => ({
...prev,
[name]: value,
}));
};
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
await axios.post('/api/events', formData);
navigate('/');
} catch (error) {
console.error('Error creating event:', error);
}
};
return (
<Container maxWidth="sm">
<Box sx={{ mt: 4 }}>
<Typography variant="h4" component="h1" gutterBottom>
Create New Event
</Typography>
<form onSubmit={handleSubmit}>
<TextField
fullWidth
label="Title"
name="title"
value={formData.title}
onChange={handleChange}
margin="normal"
required
/>
<TextField
fullWidth
label="Description"
name="description"
value={formData.description}
onChange={handleChange}
margin="normal"
multiline
rows={4}
/>
<TextField
fullWidth
label="Date and Time"
name="date"
type="datetime-local"
value={formData.date}
onChange={handleChange}
margin="normal"
required
InputLabelProps={{
shrink: true,
}}
/>
<TextField
fullWidth
label="Location"
name="location"
value={formData.location}
onChange={handleChange}
margin="normal"
required
/>
<Box sx={{ mt: 3, display: 'flex', gap: 2 }}>
<Button
variant="contained"
color="primary"
type="submit"
>
Create Event
</Button>
<Button
variant="outlined"
onClick={() => navigate('/')}
>
Cancel
</Button>
</Box>
</form>
</Box>
</Container>
);
};
export default EventForm;