Skip to content

Commit 4a6ca06

Browse files
committed
fix typo
1 parent 202637a commit 4a6ca06

File tree

1 file changed

+42
-34
lines changed

1 file changed

+42
-34
lines changed

src/app/(polling)/poll/[id]/comments.tsx

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
"use client";
2-
import Image from "next/image";
32
import Link from "next/link";
43
import { useEffect, useState } from "react";
54
import { getTimeAgo } from "~/lib/utils";
65
import { createClient } from "~/utils/supabase/client";
6+
import CardReview from "./_components/card-review";
77

88
type Comment = {
99
content: string;
1010
created_at: string;
1111
id: number;
1212
poll_id: number;
1313
user_id: string;
14-
profiles: {
14+
users: {
1515
id: string;
1616
username: string | null;
1717
avatar_url: string | null;
18-
}[];
18+
};
1919
}[];
2020

2121
export function Comments({
@@ -60,42 +60,50 @@ export function Comments({
6060
},
6161
)
6262
.subscribe();
63-
}, [supabase, comments, setComments]);
63+
}, [supabase, comments]);
6464

6565
return comments != null
6666
? comments.map((comment) => {
67-
// @ts-expect-error supabase thinks profiles is an array
68-
const { username } = comment.profiles;
67+
// <li key={comment.id} className="px-3 py-2 bg-gray-100 rounded-lg">
68+
// <div className="w-full flex flex-col gap-2">
69+
// <p>{comment.content}</p>
70+
// <div className="flex items-center gap-1 bg-gray-200 w-fit py-0.5 px-2 rounded-full">
71+
// <Image
72+
// alt={`${username}'s Avatar`}
73+
// className="shrink-0 select-none rounded-full"
74+
// loading="eager"
75+
// src={`https://vercel.com/api/www/avatar/${username}?s=48`}
76+
// width={24}
77+
// height={24}
78+
// />
79+
// <div className="flex items-center gap-1">
80+
// <Link
81+
// href={`/${username}`}
82+
// className="font-medium hover:underline"
83+
// >
84+
// @{username}
85+
// </Link>
6986

87+
// <span className="text-xs text-gray-600">
88+
// {/* Date ago of the comment */}
89+
// {getTimeAgo(comment.created_at)}
90+
// </span>
91+
// </div>
92+
// </div>
93+
// </div>
94+
// </li>
7095
return (
71-
<li key={comment.id} className="px-3 py-2 bg-gray-100 rounded-lg">
72-
<div className="w-full flex flex-col gap-2">
73-
<p>{comment.content}</p>
74-
<div className="flex items-center gap-1 bg-gray-200 w-fit py-0.5 px-2 rounded-full">
75-
<Image
76-
alt={`${username}'s Avatar`}
77-
className="shrink-0 select-none rounded-full"
78-
loading="eager"
79-
src={`https://vercel.com/api/www/avatar/${username}?s=48`}
80-
width={24}
81-
height={24}
82-
/>
83-
<div className="flex items-center gap-1">
84-
<Link
85-
href={`/${username}`}
86-
className="font-medium hover:underline"
87-
>
88-
@{username}
89-
</Link>
90-
91-
<span className="text-xs text-gray-600">
92-
{/* Date ago of the comment */}
93-
{getTimeAgo(comment.created_at)}
94-
</span>
95-
</div>
96-
</div>
97-
</div>
98-
</li>
96+
<CardReview
97+
key={comment.id}
98+
content={comment.content}
99+
rating={3}
100+
title="Title"
101+
user={{
102+
avatar: comment.users.avatar_url ?? "",
103+
name: comment.users.username ?? "",
104+
}}
105+
createdAt="2021-08-01T12:00:00.000Z"
106+
/>
99107
);
100108
})
101109
: null;

0 commit comments

Comments
 (0)