feat(alerts/ui): add shared renderAlertExpanded for DataTable rows

Extracts the per-row detail block used by Inbox/All/History DataTables
so the three pages share one rendering. Consumes AlertDto fields that
are nullable in the schema; hides missing fields instead of rendering
placeholders.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-21 10:01:39 +02:00
parent 4a63149338
commit b16ea8b185

View File

@@ -0,0 +1,41 @@
import type { AlertDto } from '../../api/queries/alerts';
import css from './alerts-page.module.css';
/**
* Shared DataTable expandedContent renderer for alert rows.
* Used by Inbox, All alerts, and History pages.
*/
export function renderAlertExpanded(alert: AlertDto) {
return (
<div className={css.expanded}>
{alert.message && (
<div className={css.expandedField}>
<span className={css.expandedLabel}>Message</span>
<p className={css.expandedValue}>{alert.message}</p>
</div>
)}
<div className={css.expandedGrid}>
<div className={css.expandedField}>
<span className={css.expandedLabel}>Fired at</span>
<span className={css.expandedValue}>{alert.firedAt ?? '—'}</span>
</div>
{alert.resolvedAt && (
<div className={css.expandedField}>
<span className={css.expandedLabel}>Resolved at</span>
<span className={css.expandedValue}>{alert.resolvedAt}</span>
</div>
)}
{alert.ackedAt && (
<div className={css.expandedField}>
<span className={css.expandedLabel}>Acknowledged at</span>
<span className={css.expandedValue}>{alert.ackedAt}</span>
</div>
)}
<div className={css.expandedField}>
<span className={css.expandedLabel}>Rule</span>
<span className={css.expandedValue}>{alert.ruleId ?? '—'}</span>
</div>
</div>
</div>
);
}