Skip to content

Commit 516a3b4

Browse files
committed
feat: enhance hackathon discussions with registration checks
- Updated HackathonDiscussions component to accept isRegistered prop. - Modified rendering logic in CommentsEmptyState and CommentInput to conditionally display content based on registration status. - Added registration prompts for unregistered users in discussions and comments sections. - Ensured consistent handling of registration state across discussion components.
1 parent bed6d9c commit 516a3b4

5 files changed

Lines changed: 54 additions & 16 deletions

File tree

app/(landing)/hackathons/[slug]/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ export default function HackathonPage() {
244244
)}
245245

246246
{activeTab === 'discussions' && (
247-
<HackathonDiscussions hackathonId={hackathonId} />
247+
<HackathonDiscussions
248+
hackathonId={hackathonId}
249+
isRegistered={isRegistered}
250+
/>
248251
)}
249252

250253
{activeTab === 'team-formation' && (

components/hackathons/discussion/comment.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import { Loader2 } from 'lucide-react';
1111
interface HackathonDiscussionsProps {
1212
hackathonId: string;
1313
organizationId?: string;
14+
isRegistered?: boolean;
1415
}
1516
export function HackathonDiscussions({
1617
hackathonId,
1718
organizationId,
19+
isRegistered = false,
1820
}: HackathonDiscussionsProps) {
1921
const [sortBy, setSortBy] = useState<
2022
'createdAt' | 'updatedAt' | 'totalReactions'
@@ -132,7 +134,12 @@ export function HackathonDiscussions({
132134
);
133135

134136
if (discussions.length === 0)
135-
return <CommentsEmptyState onAddComment={handleAddDiscussion} />;
137+
return (
138+
<CommentsEmptyState
139+
onAddComment={handleAddDiscussion}
140+
isRegistered={isRegistered}
141+
/>
142+
);
136143

137144
return (
138145
<div className='w-full'>
@@ -156,13 +163,24 @@ export function HackathonDiscussions({
156163
onUpdate={handleUpdateDiscussion}
157164
onDelete={handleDeleteDiscussion}
158165
onReport={handleReportDiscussion}
166+
isRegistered={isRegistered}
159167
/>
160168
))}
161169
</div>
162170

163-
<div className='mt-10 px-4 md:px-0'>
164-
<CommentInput onSubmit={handleAddDiscussion} />
165-
</div>
171+
{isRegistered && (
172+
<div className='mt-10 px-4 md:px-0'>
173+
<CommentInput onSubmit={handleAddDiscussion} />
174+
</div>
175+
)}
176+
177+
{!isRegistered && discussions.length > 0 && (
178+
<div className='mt-8 rounded-lg border border-gray-800 bg-gray-900/50 px-4 py-6 text-center md:px-6'>
179+
<p className='text-sm text-gray-400'>
180+
Register for this hackathon to join the discussion
181+
</p>
182+
</div>
183+
)}
166184

167185
{error && discussions.length > 0 && (
168186
<div className='mx-4 mt-4 rounded-md border border-red-500/50 bg-red-500/10 p-3 md:mx-0'>

components/project-details/comment-section/comment-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function CommentInput({
3232
return (
3333
<form
3434
onSubmit={handleSubmit}
35-
className='flex items-center gap-4 rounded-lg border border-neutral-800 bg-black px-6 py-5'
35+
className='flex items-center gap-4 rounded-lg border border-neutral-800 bg-black px-6 py-2'
3636
>
3737
<div className='shrink-0'>
3838
<Smile className='size-10 text-neutral-500' />

components/project-details/comment-section/comment-item.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface CommentItemProps {
2323
onDelete?: (commentId: string) => void;
2424
onReport?: (commentId: string, reason: string, description?: string) => void;
2525
currentUserId?: string;
26+
isRegistered?: boolean;
2627
}
2728

2829
export function CommentItem({
@@ -33,6 +34,7 @@ export function CommentItem({
3334
onDelete,
3435
onReport,
3536
currentUserId,
37+
isRegistered = false,
3638
}: CommentItemProps) {
3739
const [isLiked, setIsLiked] = useState(false);
3840
const [showReplies, setShowReplies] = useState(false);
@@ -158,14 +160,16 @@ export function CommentItem({
158160
<span className='text-xs text-zinc-400 md:text-sm'>
159161
{new Date(comment.createdAt).toLocaleDateString()}
160162
</span>
161-
<Button
162-
variant='ghost'
163-
size='sm'
164-
onClick={() => setShowReplyInput(!showReplyInput)}
165-
className='h-auto p-0 text-xs text-zinc-400 hover:bg-transparent hover:text-white md:text-sm'
166-
>
167-
Reply
168-
</Button>
163+
{isRegistered && (
164+
<Button
165+
variant='ghost'
166+
size='sm'
167+
onClick={() => setShowReplyInput(!showReplyInput)}
168+
className='h-auto p-0 text-xs text-zinc-400 hover:bg-transparent hover:text-white md:text-sm'
169+
>
170+
Reply
171+
</Button>
172+
)}
169173
{canEdit && (
170174
<Button
171175
variant='ghost'
@@ -304,6 +308,7 @@ export function CommentItem({
304308
onDelete={onDelete}
305309
onReport={onReport}
306310
currentUserId={currentUserId}
311+
isRegistered={isRegistered}
307312
/>
308313
))}
309314
</div>

components/project-details/comment-section/comments-empty-state.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ import LottieAnimation from '@/components/LottieAnimation';
55

66
interface CommentsEmptyStateProps {
77
onAddComment: (content: string) => void;
8+
isRegistered?: boolean;
89
}
910

10-
export function CommentsEmptyState({ onAddComment }: CommentsEmptyStateProps) {
11+
export function CommentsEmptyState({
12+
onAddComment,
13+
isRegistered = false,
14+
}: CommentsEmptyStateProps) {
1115
return (
1216
<div className='flex w-full flex-col'>
1317
<div className='flex flex-col items-center justify-center px-4 py-16 md:py-20'>
@@ -18,7 +22,15 @@ export function CommentsEmptyState({ onAddComment }: CommentsEmptyStateProps) {
1822
Be the first to Leave a Comment
1923
</h3>
2024
</div>
21-
<CommentInput onSubmit={onAddComment} />
25+
{isRegistered ? (
26+
<CommentInput onSubmit={onAddComment} />
27+
) : (
28+
<div className='rounded-lg border border-gray-800 bg-gray-900/50 px-4 py-6 text-center md:px-6'>
29+
<p className='text-sm text-gray-400'>
30+
Register for this hackathon to start the discussion
31+
</p>
32+
</div>
33+
)}
2234
</div>
2335
);
2436
}

0 commit comments

Comments
 (0)