Skip to content

Commit

Permalink
fix: activity and comment display nothing (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
hudy9x authored Jun 6, 2024
1 parent 5f1f813 commit 6f1b657
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 14 deletions.
7 changes: 1 addition & 6 deletions packages/ui-app/app/_features/Activity/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import './style.css'
import { ActivityContextProvider } from './context'
import ActivityContainer from './ActivityContainer'
import { useSearchParams } from 'next/navigation'

export default function Activity() {
const sp = useSearchParams()
const taskId = sp.get('taskId')

// if (!taskId) return null
export default function Activity({ taskId }: { taskId: string }) {

return (
<ActivityContextProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default function useGetTaskChecklist(taskId: string) {
return
}

console.log('task checklist return ', data)
addTaskChecklist(taskId, data)
setCheclistLoading(false)

Expand Down
6 changes: 3 additions & 3 deletions packages/ui-app/app/_features/TaskComments/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ const CommentContext = createContext<ICommentContext>({
setComments: () => console.log(1)
})

export const CommentContextProvider = ({ children }: PropsWithChildren) => {
const sp = useSearchParams()
const taskId = sp.get('taskId')
export const CommentContextProvider = ({ taskId, children }: PropsWithChildren & { taskId: string }) => {
// const sp = useSearchParams()
// const taskId = sp.get('taskId')

const [comments, setComments] = useState<Comment[]>([] as Comment[])
const { user } = useUser()
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-app/app/_features/TaskComments/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CommentContextProvider } from './context'
import TaskCommentContainer from './TaskCommentContainer'

export default function TaskComments() {
export default function TaskComments({ taskId }: { taskId: string }) {
return (
<CommentContextProvider>
<CommentContextProvider taskId={taskId}>
<TaskCommentContainer />
</CommentContextProvider>
)
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-app/app/_features/TaskDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ export default function TaskDetail({
</Tab.List>

<Tab.Content value="task-activity">
<Activity />
<Activity taskId={id} />
</Tab.Content>
<Tab.Content value="task-attachment">
<FileControl />
</Tab.Content>
<Tab.Content value="task-comments">
<TaskComments />
<TaskComments taskId={id} />
</Tab.Content>
</Tab>
</section>
Expand Down
36 changes: 36 additions & 0 deletions packages/ui-app/app/_hooks/useTaskIdChange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { onPushStateRun } from "packages/ui-app/libs/pushState"
import { useEffect, useState } from "react"

export const useTaskIdChange = () => {
const [taskId, setTaskId] = useState('')
useEffect(() => {
const destroy = onPushStateRun((url: string) => {

const newUrl = new URL(url)
const taskId = newUrl.searchParams.get('taskId')
if (taskId) {
setTaskId(taskId)
}
// fn(taskId || '')
})

return () => {
destroy()
}
}, [])

useEffect(() => {
const newUrl = new URL(window.location.toString())
const taskId = newUrl.searchParams.get('taskId')
if (taskId) {
setTaskId(taskId)
// fn(taskId)
}

}, [])

return {
taskId
}

}

0 comments on commit 6f1b657

Please sign in to comment.