@@ -18,7 +18,7 @@ import store from '@/redux/store'
1818import { DateStringSchema } from '@/types/date'
1919import { UpdateTaskRequest } from '@/types/dto/tasks.dto'
2020import { WorkflowStateResponse } from '@/types/dto/workflowStates.dto'
21- import { IAssigneeCombined , InputValue , Sizes } from '@/types/interfaces'
21+ import { IAssigneeCombined , InputValue , Sizes , UserType } from '@/types/interfaces'
2222import { getAssigneeId , getAssigneeName , getUserIds , UserIdsType } from '@/utils/assignee'
2323import { createDateFromFormattedDateString , formatDate } from '@/utils/dateHelper'
2424import { getSelectedUserIds , getSelectorAssignee , getSelectorAssigneeFromTask } from '@/utils/selector'
@@ -28,6 +28,7 @@ import { Box, Skeleton, Stack, styled, Typography } from '@mui/material'
2828import { useEffect , useState } from 'react'
2929import { useSelector } from 'react-redux'
3030import { z } from 'zod'
31+ import { ClientDetailAppBridge } from '@/app/detail/ui/ClientDetailAppBridge'
3132
3233const StyledText = styled ( Typography ) ( ( { theme } ) => ( {
3334 color : theme . color . gray [ 500 ] ,
@@ -41,6 +42,7 @@ export const Sidebar = ({
4142 updateTask,
4243 disabled,
4344 workflowDisabled,
45+ userType,
4446} : {
4547 task_id : string
4648 selectedWorkflowState : WorkflowStateResponse
@@ -50,6 +52,7 @@ export const Sidebar = ({
5052 updateTask : ( payload : UpdateTaskRequest ) => void
5153 disabled : boolean
5254 workflowDisabled ?: false
55+ userType : UserType
5356} ) => {
5457 const { activeTask, workflowStates, assignee, previewMode } = useSelector ( selectTaskBoard )
5558 const { showSidebar, showConfirmAssignModal } = useSelector ( selectTaskDetails )
@@ -74,6 +77,10 @@ export const Sidebar = ({
7477
7578 const statusValue = _statusValue as WorkflowStateResponse //typecasting
7679
80+ const completedWorkflowState = workflowStates . find ( ( state ) => state . type === 'completed' )
81+
82+ const isTaskCompleted = activeTask ?. workflowStateId === completedWorkflowState ?. id
83+
7784 useEffect ( ( ) => {
7885 if ( activeTask && workflowStates && updateStatusValue ) {
7986 const currentTask = activeTask
@@ -406,6 +413,15 @@ export const Sidebar = ({
406413 title = "Reassign task?"
407414 />
408415 </ StyledModal >
416+ { userType == UserType . CLIENT_USER && ! previewMode && (
417+ < ClientDetailAppBridge
418+ isTaskCompleted = { isTaskCompleted }
419+ handleTaskComplete = { ( ) => {
420+ completedWorkflowState && updateStatusValue ( completedWorkflowState )
421+ completedWorkflowState && updateWorkflowState ( completedWorkflowState )
422+ } }
423+ />
424+ ) }
409425 </ Box >
410426 )
411427}
0 commit comments