added selected items to rsvp form
This commit is contained in:
@@ -617,65 +617,83 @@ const RSVPForm: React.FC = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{neededItems.length > 0 && (
|
{neededItems.length > 0 && (
|
||||||
<FormControl fullWidth>
|
<>
|
||||||
<InputLabel>What items are you bringing?</InputLabel>
|
{formData.items_bringing.length > 0 && (
|
||||||
<Select
|
<Box sx={{ mb: 2 }}>
|
||||||
multiple
|
<Typography variant="subtitle2" gutterBottom sx={{ fontWeight: 500 }}>
|
||||||
name="items_bringing"
|
Items you're bringing:
|
||||||
value={formData.items_bringing}
|
</Typography>
|
||||||
onChange={handleItemsChange}
|
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 1 }}>
|
||||||
input={<OutlinedInput label="What items are you bringing?" />}
|
{formData.items_bringing.map((item) => (
|
||||||
renderValue={(selected) => (
|
<Chip
|
||||||
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>
|
key={item}
|
||||||
{selected.map((value) => (
|
label={item}
|
||||||
<Chip key={value} label={value} />
|
color="success"
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
|
||||||
open={isItemsSelectOpen} // Control open state
|
|
||||||
onOpen={() => setIsItemsSelectOpen(true)} // Set open when opened
|
|
||||||
onClose={() => setIsItemsSelectOpen(false)} // Set closed when closed
|
|
||||||
MenuProps={{
|
|
||||||
PaperProps: {
|
|
||||||
sx: {
|
|
||||||
maxHeight: 300, // Limit height of the dropdown
|
|
||||||
overflowY: 'auto',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MenuListProps: {
|
|
||||||
sx: {
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{neededItems.map((item) => (
|
|
||||||
<MenuItem key={item} value={item}>
|
|
||||||
<Checkbox checked={formData.items_bringing.includes(item)} />
|
|
||||||
<ListItemText primary={item} />
|
|
||||||
</MenuItem>
|
|
||||||
))}
|
|
||||||
<Box sx={{
|
|
||||||
position: 'sticky',
|
|
||||||
bottom: 0,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
backgroundColor: 'background.paper',
|
|
||||||
padding: 1,
|
|
||||||
zIndex: 1,
|
|
||||||
borderTop: '1px solid',
|
|
||||||
borderColor: 'divider',
|
|
||||||
textAlign: 'center',
|
|
||||||
}}>
|
|
||||||
<Button
|
|
||||||
variant="contained"
|
|
||||||
onClick={() => setIsItemsSelectOpen(false)}
|
|
||||||
fullWidth
|
|
||||||
>
|
|
||||||
Done
|
|
||||||
</Button>
|
|
||||||
</Box>
|
</Box>
|
||||||
</Select>
|
)}
|
||||||
</FormControl>
|
<FormControl fullWidth>
|
||||||
|
<InputLabel>What items are you bringing?</InputLabel>
|
||||||
|
<Select
|
||||||
|
multiple
|
||||||
|
name="items_bringing"
|
||||||
|
value={formData.items_bringing}
|
||||||
|
onChange={handleItemsChange}
|
||||||
|
input={<OutlinedInput label="What items are you bringing?" />}
|
||||||
|
renderValue={(selected) => (
|
||||||
|
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>
|
||||||
|
{selected.map((value) => (
|
||||||
|
<Chip key={value} label={value} />
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
open={isItemsSelectOpen} // Control open state
|
||||||
|
onOpen={() => setIsItemsSelectOpen(true)} // Set open when opened
|
||||||
|
onClose={() => setIsItemsSelectOpen(false)} // Set closed when closed
|
||||||
|
MenuProps={{
|
||||||
|
PaperProps: {
|
||||||
|
sx: {
|
||||||
|
maxHeight: 300, // Limit height of the dropdown
|
||||||
|
overflowY: 'auto',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MenuListProps: {
|
||||||
|
sx: {
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{neededItems.map((item) => (
|
||||||
|
<MenuItem key={item} value={item}>
|
||||||
|
<Checkbox checked={formData.items_bringing.includes(item)} />
|
||||||
|
<ListItemText primary={item} />
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
<Box sx={{
|
||||||
|
position: 'sticky',
|
||||||
|
bottom: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
backgroundColor: 'background.paper',
|
||||||
|
padding: 1,
|
||||||
|
zIndex: 1,
|
||||||
|
borderTop: '1px solid',
|
||||||
|
borderColor: 'divider',
|
||||||
|
textAlign: 'center',
|
||||||
|
}}>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
onClick={() => setIsItemsSelectOpen(false)}
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
Done
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
|
|||||||
Reference in New Issue
Block a user