Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export function DataTable({
<Tooltip>
<FormSheetStatusReportUpdate
defaultValues={{
status: getNextStatus(updates[updates.length - 1].status),
status: getNextStatus(
updates[updates.length - 1]?.status ?? "investigating",
),
}}
onSubmit={async (values) => {
await createStatusReportUpdateMutation.mutateAsync({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export const columns: ColumnDef<StatusReport>[] = [
{
id: "startedAt",
accessorFn: (row) =>
row.updates.sort((a, b) => a.date.getTime() - b.date.getTime())[0]?.date,
row.updates.sort((a, b) => a.date.getTime() - b.date.getTime())[0]
?.date ?? row.createdAt,
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Started At" />
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ export default function Page() {
const firstUpdate = updates[updates.length - 1];
const lastUpdate = updates[0];
// NOTE: updates are sorted descending by date
const startedAt = firstUpdate.date;
const startedAt =
firstUpdate?.date ?? report.createdAt ?? new Date();
// HACKY: LEGACY: only resolved via report and not via report update
const isReportResolvedOnly =
report.status === "resolved" &&
lastUpdate.status !== "resolved";
lastUpdate?.status !== "resolved";
return (
<StatusEvent key={report.id}>
<StatusEventAside>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function ReportPage() {

// HACKY: LEGACY: only resolved via report and not via report update
const isReportResolvedOnly =
report.status === "resolved" && lastUpdate.status !== "resolved";
report.status === "resolved" && lastUpdate?.status !== "resolved";

return (
<div className="flex flex-col gap-4">
Expand All @@ -54,7 +54,9 @@ export default function ReportPage() {
</div>
<StatusEvent>
<StatusEventAside>
<StatusEventDate date={firstUpdate.date} />
<StatusEventDate
date={firstUpdate?.date ?? report.createdAt ?? new Date()}
/>
</StatusEventAside>
<StatusEventContent hoverable={false}>
<StatusEventTitle className="inline-flex gap-1">
Expand Down
6 changes: 5 additions & 1 deletion apps/status-page/src/components/status-page/status-feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
type StatusReport = {
id: number;
title: string;
createdAt?: Date | null;
affected: string[];
updates: {
date: Date;
Expand Down Expand Up @@ -68,7 +69,10 @@ export function StatusFeed({
title: report.title,
type: "report" as const,
// FIXME: we have a flicker here when the report is updated
startDate: report.updates[report.updates.length - 1]?.date || new Date(),
startDate:
report.updates[report.updates.length - 1]?.date ??
report.createdAt ??
new Date(),
data: report,
})),
...maintenances.map((maintenance) => ({
Expand Down
Loading