Skip to content
Open
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
10 changes: 2 additions & 8 deletions app/(public)/case/[caseNumber]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from "@/lib/constants/severity";
import { getSiteUrl } from "@/lib/utils/urls";
import { incidentDate } from "@/lib/utils/incident-date";
import { formatUsd } from "@/lib/utils/format";

export const revalidate = 60;

Expand Down Expand Up @@ -94,14 +95,7 @@ export default async function CasePage({ params }: PageProps) {
timeZone: "UTC",
}).format(new Date(incidentDate(post)));

const cost =
post.estimatedCostUsd != null
? post.estimatedCostUsd >= 1_000_000
? `$${(post.estimatedCostUsd / 1_000_000).toFixed(1)}M`
: post.estimatedCostUsd >= 1_000
? `$${(post.estimatedCostUsd / 1_000).toFixed(0)}k`
: `$${post.estimatedCostUsd}`
: null;
const cost = formatUsd(post.estimatedCostUsd);

const siteUrl = getSiteUrl();
const sourceDomain = getSourceDomain(post.sourceUrl);
Expand Down
10 changes: 2 additions & 8 deletions app/(public)/hall-of-fame/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fetchFeedPosts } from "@/lib/db/posts";
import { VoteButtons } from "@/components/post/VoteButtons";
import { Pagination } from "@/components/ui/Pagination";
import { EmptyState } from "@/components/ui/EmptyState";
import { formatUsd } from "@/lib/utils/format";

export const revalidate = 60;

Expand Down Expand Up @@ -86,14 +87,7 @@ export default async function HallOfFamePage({ searchParams }: PageProps) {
{posts.map((post, i) => {
const rank = rankOffset + i;
const isTop3 = rank < 3;
const cost =
post.estimatedCostUsd != null
? post.estimatedCostUsd >= 1_000_000
? `$${(post.estimatedCostUsd / 1_000_000).toFixed(1)}M`
: post.estimatedCostUsd >= 1_000
? `$${(post.estimatedCostUsd / 1_000).toFixed(0)}k`
: `$${post.estimatedCostUsd}`
: null;
const cost = formatUsd(post.estimatedCostUsd);

return (
<li
Expand Down
9 changes: 2 additions & 7 deletions app/api/og/[caseNumber]/route.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ImageResponse } from "next/og";
import { NextRequest } from "next/server";
import { SEVERITY_LABELS } from "@/lib/constants/severity";
import { formatUsd } from "@/lib/utils/format";

interface CaseData {
caseNumber: string;
Expand Down Expand Up @@ -69,13 +70,7 @@ export async function GET(
const damageLevel = data?.damageLevel ?? 3;
const severityLabel =
SEVERITY_LABELS[damageLevel as 1 | 2 | 3 | 4 | 5] ?? "Moderate";
const costFormatted = data?.estimatedCostUsd
? data.estimatedCostUsd >= 1_000_000
? `$${(data.estimatedCostUsd / 1_000_000).toFixed(1)}M`
: data.estimatedCostUsd >= 1_000
? `$${(data.estimatedCostUsd / 1_000).toFixed(0)}k`
: `$${data.estimatedCostUsd}`
: null;
const costFormatted = formatUsd(data?.estimatedCostUsd);

return new ImageResponse(
<div
Expand Down
11 changes: 3 additions & 8 deletions components/post/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { severityStyle } from "@/lib/constants/severity";
import { incidentDate } from "@/lib/utils/incident-date";
import type { Post } from "@/types";

import { formatUsd } from "@/lib/utils/format";

type PostCardProps = { post: Post; commentCount?: number };

export function PostCard({ post, commentCount }: PostCardProps) {
Expand All @@ -18,14 +20,7 @@ export function PostCard({ post, commentCount }: PostCardProps) {
timeZone: "UTC",
}).format(new Date(incidentDate(post)));

const cost =
post.estimatedCostUsd != null
? post.estimatedCostUsd >= 1_000_000
? `$${(post.estimatedCostUsd / 1_000_000).toFixed(1)}M`
: post.estimatedCostUsd >= 1_000
? `$${(post.estimatedCostUsd / 1_000).toFixed(0)}k`
: `$${post.estimatedCostUsd}`
: null;
const cost = formatUsd(post.estimatedCostUsd);

return (
<article className="group relative flex overflow-hidden rounded-sm border border-border-default bg-bg-surface transition-colors hover:border-border-strong hover:bg-bg-elevated">
Expand Down
2 changes: 1 addition & 1 deletion lib/resend/newsletter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Resend } from "resend";
import { getSiteUrl } from "@/lib/utils/urls";

const resend = new Resend(process.env.RESEND_API_KEY);
const resend = new Resend(process.env.RESEND_API_KEY || "re_dummy");
const FROM =
process.env.RESEND_NEWSLETTER_FROM ??
"AgentPostmortem <cases@agentpostmortem.com>";
Expand Down
2 changes: 1 addition & 1 deletion lib/resend/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Resend } from "resend";
import { EditTokenEmail } from "./templates/EditTokenEmail";
import { getSiteUrl } from "@/lib/utils/urls";

const resend = new Resend(process.env.RESEND_API_KEY);
const resend = new Resend(process.env.RESEND_API_KEY || "re_dummy");

interface SendEditTokenEmailParams {
to: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/schemas/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const submitSchema = z.object({
damageLevel: z.number().int().min(1).max(5) as z.ZodType<1 | 2 | 3 | 4 | 5>,

/** Approximate USD financial damage — 0 for reputational only */
estimatedCostUsd: z.number().int().min(0).max(100_000_000).optional(),
estimatedCostUsd: z.number().int().min(0).max(1_000_000_000_000).optional(),

/** Tags — at least one required */
tags: z
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,13 @@
"firefox >= 90",
"safari >= 15",
"edge >= 91"
]
],
"pnpm": {
"approvedBuilds": [
"esbuild",
"sharp",
"unrs-resolver",
"workerd"
]
}
}
9 changes: 9 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
allowBuilds:
'0': esbuild
'1': sharp
'2': unrs-resolver
'3': workerd
esbuild: set this to true or false
sharp: set this to true or false
unrs-resolver: set this to true or false
workerd: set this to true or false
Loading