fix: robustly handle other_items as string, string[], or undefined in Other Items section
This commit is contained in:
@@ -770,7 +770,13 @@ const EventAdmin: React.FC = () => {
|
||||
{(() => {
|
||||
const allOtherItems = rsvps
|
||||
.map(r => r.other_items)
|
||||
.filter((item): item is string => typeof item === 'string' && item.trim() !== '');
|
||||
.flatMap(item =>
|
||||
Array.isArray(item)
|
||||
? item.filter((s): s is string => typeof s === 'string' && s.trim() !== '')
|
||||
: typeof item === 'string' && item.trim() !== ''
|
||||
? [item]
|
||||
: []
|
||||
);
|
||||
return allOtherItems.length > 0
|
||||
? allOtherItems.join(', ')
|
||||
: 'No other items have been brought';
|
||||
|
||||
@@ -247,7 +247,13 @@ const EventView: React.FC = () => {
|
||||
{(() => {
|
||||
const allOtherItems = rsvps
|
||||
.map(r => r.other_items)
|
||||
.filter((item): item is string => typeof item === 'string' && item.trim() !== '');
|
||||
.flatMap(item =>
|
||||
Array.isArray(item)
|
||||
? item.filter((s): s is string => typeof s === 'string' && s.trim() !== '')
|
||||
: typeof item === 'string' && item.trim() !== ''
|
||||
? [item]
|
||||
: []
|
||||
);
|
||||
return allOtherItems.length > 0
|
||||
? allOtherItems.join(', ')
|
||||
: 'No other items have been brought';
|
||||
|
||||
Reference in New Issue
Block a user