Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

disable comment input box while user was logged out (#651)

Vivek Kumar90d2abb55f40
diff --git a/apps/web/src/app/[locale]/challenge/_components/comments/comment-input.tsx b/apps/web/src/app/[locale]/challenge/_components/comments/comment-input.tsx
index 4f1db3af..49deca3b 100644
--- a/apps/web/src/app/[locale]/challenge/_components/comments/comment-input.tsx
+++ b/apps/web/src/app/[locale]/challenge/_components/comments/comment-input.tsx
@@ -52,11 +52,16 @@ export function CommentInput({ mode, onCancel, onChange, value, placeholder, onS
<div className="flex flex-col rounded-xl rounded-br-lg bg-neutral-100 backdrop-blur-sm dark:border-zinc-700 dark:bg-zinc-700/90">
{commentMode === 'editor' && (
<Textarea
+ disabled={!session?.user}
autoFocus
className="resize-none border-0 px-3 py-2 focus-visible:ring-0 md:max-h-[calc(100vh_-_232px)]"
onChange={(e) => onChange(e.target.value)}
onKeyDown={handleEnterKey}
- placeholder={placeholder ?? 'Enter your comment here.'}
+ placeholder={
+ placeholder ?? !session?.user
+ ? 'You need to be logged in to comment.'
+ : 'Enter your comment here.'
+ }
ref={textAreaRef}
value={value}
/>