Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UST-240] [Frontend] Improve the commenting process to make it more convenient and concise #569

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 12 additions & 6 deletions packages/frontend/src/routes/app/posts/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import { PostStatus, RelayRawPostStatus } from '@/types/Post'
import { VoteAction } from '@/types/Vote'
import checkVoteIsMine from '@/utils/helpers/checkVoteIsMine'
import { useQuery } from '@tanstack/react-query'
import React, { useMemo, useState } from 'react'
import { useNavigate, useParams } from 'react-router-dom'
import React, { useEffect, useMemo, useState } from 'react'
import { useLocation, useNavigate, useParams } from 'react-router-dom'

const PostDetailsPage: React.FC = () => {
const { id } = useParams()

const location = useLocation()
const navigate = useNavigate()

if (!id) {
Expand Down Expand Up @@ -69,7 +69,7 @@ const PostDetailsPage: React.FC = () => {
}
}, [data, userState])

const [isOpenComment, setIsOpenCommnet] = useState(false)
const [isOpenComment, setIsOpenComment] = useState(false)

const [errorMessage, setErrorMessage] = useState<string>()

Expand All @@ -85,7 +85,7 @@ const PostDetailsPage: React.FC = () => {
openForbidActionDialog()
return
}
setIsOpenCommnet((prev) => !prev)
setIsOpenComment((prev) => !prev)
}

const handleVote = async (voteType: VoteAction): Promise<boolean> => {
Expand Down Expand Up @@ -122,6 +122,12 @@ const PostDetailsPage: React.FC = () => {
}
}

useEffect(() => {
if (location.hash === '#comments') {
setIsOpenComment(true)
}
}, [location.hash])

if (!id || !post) return null

return (
Expand Down Expand Up @@ -154,7 +160,7 @@ const PostDetailsPage: React.FC = () => {
<CreateComment
postId={id}
isOpen={isOpenComment}
onClose={() => setIsOpenCommnet(false)}
onClose={() => setIsOpenComment(false)}
/>
<CommentNotification postId={id} />
<AuthErrorDialog
Expand Down
Loading