Fix item handling in RSVP submission and admin view - Improved type handling, JSON parsing, and UI display
This commit is contained in:
@@ -403,6 +403,7 @@ const EventAdmin: React.FC = () => {
|
|||||||
label={item}
|
label={item}
|
||||||
color="success"
|
color="success"
|
||||||
size="small"
|
size="small"
|
||||||
|
variant={claimedItems.includes(item) ? "filled" : "outlined"}
|
||||||
/>
|
/>
|
||||||
)) : (
|
)) : (
|
||||||
<Typography variant="body2" color="text.secondary">
|
<Typography variant="body2" color="text.secondary">
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ const RSVPForm: React.FC = () => {
|
|||||||
...formData,
|
...formData,
|
||||||
items_bringing: JSON.stringify(formData.items_bringing)
|
items_bringing: JSON.stringify(formData.items_bringing)
|
||||||
};
|
};
|
||||||
await axios.post(`/api/events/${slug}/rsvp`, submissionData);
|
const response = await axios.post(`/api/events/${slug}/rsvp`, submissionData);
|
||||||
|
|
||||||
// Update the needed and claimed items
|
// Update the needed and claimed items
|
||||||
const [eventResponse, rsvpsResponse] = await Promise.all([
|
const [eventResponse, rsvpsResponse] = await Promise.all([
|
||||||
@@ -166,9 +166,10 @@ const RSVPForm: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all claimed items from existing RSVPs
|
// Get all claimed items from existing RSVPs including the new submission
|
||||||
const claimed = new Set<string>();
|
const claimed = new Set<string>();
|
||||||
rsvpsResponse.data.forEach((rsvp: any) => {
|
const allRsvps = [...rsvpsResponse.data, response.data];
|
||||||
|
allRsvps.forEach((rsvp: any) => {
|
||||||
try {
|
try {
|
||||||
let rsvpItems: string[] = [];
|
let rsvpItems: string[] = [];
|
||||||
if (typeof rsvp.items_bringing === 'string') {
|
if (typeof rsvp.items_bringing === 'string') {
|
||||||
|
|||||||
Reference in New Issue
Block a user