Skip to content

Commit 1b9d42b

Browse files
committed
feat: Add conditional rendering for comment submission in replies-modal.jsx and article-modal.jsx
1 parent 28ea34c commit 1b9d42b

File tree

2 files changed

+36
-32
lines changed

2 files changed

+36
-32
lines changed

src/components/common/replies-modal.jsx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function RepliesModal({ comment, commentUrl, active, addCommentDe
1616
const [addComment, setAddComment] = useState(addCommentDefault)
1717
const [textNewComment, setTextNewComment] = useState('')
1818
const [comments, setComments] = useState(null)
19-
19+
const isProjectClosed = project.closed
2020
const fetchComents = async (page) => {
2121
const resp = await fetchGeneralComments(`${commentUrl}${page ? '?page=' + page : ''}`)
2222
setComments(resp);
@@ -74,21 +74,23 @@ export default function RepliesModal({ comment, commentUrl, active, addCommentDe
7474
/>
7575
}
7676
</div>
77-
<footer className="modal-card-foot has-background-white">
78-
{user ? <form action="submit" className="w-100" onSubmit={handlesubmit}>
79-
<p className="control has-icons-right ">
80-
<input className="input is-rounded" type="text" placeholder="Escribe un comentario....." value={textNewComment} onChange={(e) => setTextNewComment(e.target.value)} />
81-
<span className="icon is-small is-right is-clickable" onClick={handlesubmit}>
82-
<FontAwesomeIcon icon={faPaperPlane} />
83-
</span>
84-
</p>
85-
</form>
86-
:
87-
<div >
88-
<p>Inicia sesión <Link href="/auth/login"> aquí</Link> para poder comentar</p>
89-
</div>
90-
}
91-
</footer>
77+
{
78+
!isProjectClosed && <footer className="modal-card-foot has-background-white">
79+
{user ? <form action="submit" className="w-100" onSubmit={handlesubmit}>
80+
<p className="control has-icons-right ">
81+
<input className="input is-rounded" type="text" placeholder="Escribe un comentario....." value={textNewComment} onChange={(e) => setTextNewComment(e.target.value)} />
82+
<span className="icon is-small is-right is-clickable" onClick={handlesubmit}>
83+
<FontAwesomeIcon icon={faPaperPlane} />
84+
</span>
85+
</p>
86+
</form>
87+
:
88+
<div >
89+
<p>Inicia sesión <Link href="/auth/login"> aquí</Link> para poder comentar</p>
90+
</div>
91+
}
92+
</footer>
93+
}
9294
</div>}
9395
</div>
9496
</div>

src/components/pacto/body/pacto/article-modal.jsx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const ArticleModal = ({ article, active, closeCommentModal, liked, disliked, han
1616
const [comments, setComments] = useState(null)
1717
const { language } = useLanguage()
1818
const { user } = useAuthContext()
19+
const isProjectClosed = project.closed
1920

2021
useEffect(() => {
2122
fetchComments()
@@ -83,22 +84,23 @@ const ArticleModal = ({ article, active, closeCommentModal, liked, disliked, han
8384
}
8485
</div>
8586
</section>
86-
<footer className="modal-card-foot has-background-white">
87-
{user ? <form action="submit" className="w-100" onSubmit={handlesubmit}>
88-
<p className="control has-icons-right ">
89-
<input className="input is-rounded" type="text" placeholder="Escribe un comentario....." value={textNewComment} onChange={(e) => setTextNewComment(e.target.value)} />
90-
<span className="icon is-small is-right is-clickable" onClick={handlesubmit}>
91-
<FontAwesomeIcon icon={faPaperPlane} />
92-
</span>
93-
</p>
94-
95-
</form>
96-
:
97-
<div >
98-
<p>Inicia sesión <Link href="/auth/login"> aquí</Link> para poder comentar</p>
99-
</div>
100-
}
101-
</footer>
87+
{
88+
!isProjectClosed && <footer className="modal-card-foot has-background-white">
89+
{user ? <form action="submit" className="w-100" onSubmit={handlesubmit}>
90+
<p className="control has-icons-right ">
91+
<input className="input is-rounded" type="text" placeholder="Escribe un comentario....." value={textNewComment} onChange={(e) => setTextNewComment(e.target.value)} />
92+
<span className="icon is-small is-right is-clickable" onClick={handlesubmit}>
93+
<FontAwesomeIcon icon={faPaperPlane} />
94+
</span>
95+
</p>
96+
</form>
97+
:
98+
<div >
99+
<p>Inicia sesión <Link href="/auth/login"> aquí</Link> para poder comentar</p>
100+
</div>
101+
}
102+
</footer>
103+
}
102104
</div>
103105
</div>)
104106
}

0 commit comments

Comments
 (0)