Fix notification event names and allow welcome onboarding
This commit is contained in:
@@ -43,6 +43,16 @@ type NotificationSwipeRowProps = {
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
function resolveEventName(name: TenantEvent['name'], t: (key: string, fallback?: string) => string): string {
|
||||
if (typeof name === 'string') {
|
||||
return name;
|
||||
}
|
||||
if (name && typeof name === 'object') {
|
||||
return name.de ?? name.en ?? Object.values(name)[0] ?? t('events.placeholders.untitled', 'Unbenanntes Event');
|
||||
}
|
||||
return t('events.placeholders.untitled', 'Unbenanntes Event');
|
||||
}
|
||||
|
||||
function NotificationSwipeRow({ item, onOpen, onMarkRead, children }: NotificationSwipeRowProps) {
|
||||
const { t } = useTranslation('management');
|
||||
const { successBg, successText, infoBg, infoText } = useAdminTheme();
|
||||
@@ -296,7 +306,7 @@ async function loadNotifications(
|
||||
});
|
||||
const lookup = new Map<number, string>();
|
||||
(events ?? []).forEach((event) => {
|
||||
lookup.set(event.id, typeof event.name === 'string' ? event.name : (event.name as Record<string, string>)?.en ?? '');
|
||||
lookup.set(event.id, resolveEventName(event.name, t));
|
||||
});
|
||||
|
||||
return (response.data ?? [])
|
||||
@@ -756,7 +766,7 @@ export default function MobileNotificationsPage() {
|
||||
<XStack alignItems="center" justifyContent="space-between" paddingVertical="$2">
|
||||
<YStack>
|
||||
<Text fontSize="$sm" fontWeight="700" color={text}>
|
||||
{ev.name}
|
||||
{resolveEventName(ev.name, t)}
|
||||
</Text>
|
||||
<Text fontSize="$xs" color={muted}>
|
||||
{ev.slug}
|
||||
|
||||
Reference in New Issue
Block a user