2
2
3
3
import { CommentCardContainer } from '@/app/detail/ui/styledComponent'
4
4
import { CopilotAvatar } from '@/components/atoms/CopilotAvatar'
5
+ import AttachmentLayout from '@/components/AttachmentLayout'
6
+ import { MAX_UPLOAD_LIMIT } from '@/constants/attachments'
5
7
import { selectAuthDetails } from '@/redux/features/authDetailsSlice'
6
8
import { selectTaskBoard } from '@/redux/features/taskBoardSlice'
7
9
import { selectTaskDetails } from '@/redux/features/taskDetailsSlice'
8
10
import { CreateComment } from '@/types/dto/comment.dto'
9
11
import { getMentionsList } from '@/utils/getMentionList'
12
+ import { deleteEditorAttachmentsHandler , uploadImageHandler } from '@/utils/inlineImage'
10
13
import { ArrowUpward } from '@mui/icons-material'
11
14
import { IconButton , InputAdornment , Stack } from '@mui/material'
12
15
import { useEffect , useState } from 'react'
@@ -23,7 +26,7 @@ export const CommentInput = ({ createComment, task_id }: Prop) => {
23
26
const [ isListOrMenuActive , setIsListOrMenuActive ] = useState ( false )
24
27
const { assigneeSuggestions } = useSelector ( selectTaskDetails )
25
28
const { tokenPayload } = useSelector ( selectAuthDetails )
26
- const { assignee } = useSelector ( selectTaskBoard )
29
+ const { assignee, token , activeTask } = useSelector ( selectTaskBoard )
27
30
const currentUserId = tokenPayload ?. internalUserId ?? tokenPayload ?. clientId
28
31
const currentUserDetails = assignee . find ( ( el ) => el . id === currentUserId )
29
32
@@ -77,6 +80,15 @@ export const CommentInput = ({ createComment, task_id }: Prop) => {
77
80
}
78
81
} , [ detail , isListOrMenuActive ] ) // Depend on detail to ensure the latest state is captured
79
82
83
+ const uploadFn = token
84
+ ? async ( file : File ) => {
85
+ if ( activeTask ) {
86
+ const fileUrl = await uploadImageHandler ( file , token ?? '' , activeTask . workspaceId , task_id )
87
+ return fileUrl
88
+ }
89
+ }
90
+ : undefined
91
+
80
92
return (
81
93
< Stack direction = "row" columnGap = { 2 } alignItems = "flex-start" >
82
94
< CopilotAvatar
@@ -99,7 +111,7 @@ export const CommentInput = ({ createComment, task_id }: Prop) => {
99
111
content = { detail }
100
112
getContent = { setDetail }
101
113
placeholder = "Leave a comment..."
102
- suggestions = { assigneeSuggestions }
114
+ // suggestions={assigneeSuggestions} enable this for mentions
103
115
editorClass = "tapwrite-comment-input"
104
116
hardbreak
105
117
onActiveStatusChange = { ( prop ) => {
@@ -113,6 +125,11 @@ export const CommentInput = ({ createComment, task_id }: Prop) => {
113
125
display : 'flex' ,
114
126
flexDirection : 'column' ,
115
127
} }
128
+ uploadFn = { uploadFn }
129
+ deleteEditorAttachments = { ( url ) => deleteEditorAttachmentsHandler ( url , token ?? '' , task_id , null ) }
130
+ attachmentLayout = { AttachmentLayout }
131
+ addAttachmentButton
132
+ maxUploadLimit = { MAX_UPLOAD_LIMIT }
116
133
/>
117
134
< InputAdornment
118
135
position = "end"
0 commit comments