Fix TypeScript errors in EventForm for FormData handling

This commit is contained in:
2025-05-01 08:35:09 -04:00
parent cdf8bff0ec
commit 4bf54e54c0

View File

@@ -12,14 +12,22 @@ import {
} from '@mui/material'; } from '@mui/material';
import axios from 'axios'; import axios from 'axios';
interface FormData {
title: string;
description: string;
date: string;
location: string;
needed_items: string[];
}
const EventForm: React.FC = () => { const EventForm: React.FC = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const [formData, setFormData] = useState({ const [formData, setFormData] = useState<FormData>({
title: '', title: '',
description: '', description: '',
date: '', date: '',
location: '', location: '',
needed_items: [] as string[], needed_items: [],
}); });
const [wallpaper, setWallpaper] = useState<File | null>(null); const [wallpaper, setWallpaper] = useState<File | null>(null);
const [currentItem, setCurrentItem] = useState(''); const [currentItem, setCurrentItem] = useState('');
@@ -71,7 +79,7 @@ const EventForm: React.FC = () => {
if (key === 'needed_items') { if (key === 'needed_items') {
submitData.append(key, JSON.stringify(value)); submitData.append(key, JSON.stringify(value));
} else { } else {
submitData.append(key, value); submitData.append(key, String(value));
} }
}); });