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
10 changes: 6 additions & 4 deletions src/app/demo-days/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Link from "next/link";
import { createClient } from "@/lib/supabase/server";
import { format } from "date-fns";
import type { Metadata } from "next";
import type { DemoDayWinnerWithProduct } from "@/types/database";

export const metadata: Metadata = {
title: "Demo Days Archive",
Expand All @@ -17,13 +18,14 @@ export default async function DemoDaysPage() {
.eq("status", "completed")
.order("week_of", { ascending: false });

const { data: winners } = await supabase
const { data: winnersData } = await supabase
.from("demo_day_winners")
.select("*, product:products(name, tagline, id)")
.order("rank", { ascending: true });
const winners = (winnersData ?? []) as DemoDayWinnerWithProduct[];

const winnersMap = new Map<string, typeof winners>();
winners?.forEach((w) => {
const winnersMap = new Map<string, DemoDayWinnerWithProduct[]>();
winners.forEach((w) => {
const existing = winnersMap.get(w.week_of) ?? [];
existing.push(w);
winnersMap.set(w.week_of, existing);
Expand Down Expand Up @@ -79,7 +81,7 @@ export default async function DemoDaysPage() {

{weekWinners.length > 0 && (
<div className="mt-4 space-y-2">
{weekWinners.map((w: { rank: number; vote_count: number; product: { id: string; name: string; tagline: string } | null }) => (
{weekWinners.map((w) => (
<div
key={w.rank}
className="flex items-center gap-3 rounded-xl bg-paper-bg p-3"
Expand Down
6 changes: 6 additions & 0 deletions src/types/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,9 @@ export interface DemoDayWinner {
vote_count: number;
product?: ProductWithCounts;
}

export type DemoDayWinnerProduct = Pick<Product, "id" | "name" | "tagline">;

export type DemoDayWinnerWithProduct = Omit<DemoDayWinner, "product"> & {
product: DemoDayWinnerProduct | null;
};