Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/components/KeyResult/Single/Drawer/Body/body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const KeyResultDrawerBody = ({
<Divider borderColor="gray.100" />
</>
)}
<KeyResultChecklistWrapper keyResultID={keyResultID} teamID={keyResult?.teamId} />
<KeyResultChecklistWrapper keyResultID={keyResultID} isLoading={isLoading} />
<Divider borderColor="gray.100" />
<KeyResultSectionOwner keyResultID={keyResultID} />
<Divider borderColor="gray.100" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { PlusOutline } from 'src/components/Icon'
import { NewTask } from 'src/components/Task/types'
import { useAddTask } from 'src/components/TaskManagement/hooks/use-add-task-new'
import { TASK_STATUS } from 'src/services/new-task-management/@types/task-status.enum'
import { keyResultAtomFamily } from 'src/state/recoil/key-result'
import meAtom from 'src/state/recoil/user/me'

import { EventType } from '../../../../../../state/hooks/useEvent/event-type'
Expand Down Expand Up @@ -54,6 +55,9 @@ export const CreateTaskButton = ({
const userID = useRecoilValue(meAtom)
const { dispatch } = useEvent(EventType.TASK_MANAGER_CREATE_TASK_CLICK)

const keyResult = useRecoilValue(keyResultAtomFamily(keyResultID))
const hasData = Boolean(keyResult?.teamId)

const handleNewCheckMark = async (title: NewTask['title']) => {
if (isSubmitting) return

Expand All @@ -63,22 +67,24 @@ export const CreateTaskButton = ({
}

setIsSubmitting(true)
await addNewTask({
team: teamId as string,
status: TASK_STATUS.pending,
title,
description: '',
initialDate: new Date(),
dueDate: new Date(),
priority: Math.floor(Math.random() * 4) + 1,
owner: userID,
attachments: [],
supportTeam: [],
tags: [],
orderindex: 0,
key_result: keyResultID,
cycle: '',
})
if (teamId || keyResult) {
await addNewTask({
team: teamId ?? keyResult?.teamId ?? '',
status: TASK_STATUS.pending,
title,
description: '',
initialDate: new Date(),
dueDate: new Date(),
priority: Math.floor(Math.random() * 4) + 1,
owner: userID,
attachments: [],
supportTeam: [],
tags: [],
orderindex: 0,
key_result: keyResultID,
cycle: '',
})
}

dispatch({ keyResultID })
setIsSubmitting(false)
Expand Down Expand Up @@ -109,28 +115,30 @@ export const CreateTaskButton = ({
/>
</StyledEditableWrapper>
)}
<Button
ref={createButtonReference}
variant="text"
p={0}
h="auto"
colorScheme="brand"
isDisabled={isSubmitting}
leftIcon={
<>
{isSubmitting && <Spinner color="brand.400" size="sm" mr={3} mt="0.1rem" />}
<PlusOutline
desc={intl.formatMessage(messages.newCheckMarkButtonIconDescription)}
stroke="currentColor"
fill="currentColor"
fontSize="xl"
/>
</>
}
onClick={toggleAdd}
>
{label ?? intl.formatMessage(messages.newCheckMarkButtonLabel)}
</Button>
{(teamId ?? hasData) && (
<Button
ref={createButtonReference}
variant="text"
p={0}
h="auto"
colorScheme="brand"
isDisabled={isSubmitting}
leftIcon={
<>
{isSubmitting && <Spinner color="brand.400" size="sm" mr={3} mt="0.1rem" />}
<PlusOutline
desc={intl.formatMessage(messages.newCheckMarkButtonIconDescription)}
stroke="currentColor"
fill="currentColor"
fontSize="xl"
/>
</>
}
onClick={toggleAdd}
>
{label ?? intl.formatMessage(messages.newCheckMarkButtonLabel)}
</Button>
)}
</Box>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const KeyResultChecklist = ({
</StyledStack>
)}

{canCreate && (
{canCreate && teamId && (
<CreateTaskButton
mt={5}
keyResultID={keyResultID}
Expand Down
19 changes: 12 additions & 7 deletions src/components/KeyResult/Single/Sections/Checklist/wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { KeyResult } from 'src/components/KeyResult/types'
import { useTeamTasksData } from 'src/components/TaskManagement/hooks/new-task/use-get-team-tasks'
import { TASK_STATUS } from 'src/services/new-task-management/@types/task-status.enum'
import { Task } from 'src/services/new-task-management/@types/task.type'
import { keyResultAtomFamily } from 'src/state/recoil/key-result'
import buildPartialSelector from 'src/state/recoil/key-result/build-partial-selector'
import {
keyResultCheckInCommentEnabled,
Expand All @@ -31,12 +32,12 @@ import { ToggleCollapse } from './toggle-collapse'

interface KeyResultChecklistWrapperProperties {
keyResultID?: string
teamID?: string
isLoading?: boolean
}

export const KeyResultChecklistWrapper = ({
keyResultID,
teamID,
isLoading,
}: KeyResultChecklistWrapperProperties) => {
const timelineSelector = buildPartialSelector<KeyResult['timeline']>('timeline')

Expand All @@ -56,6 +57,9 @@ export const KeyResultChecklistWrapper = ({

const intl = useIntl()

const keyResult = useRecoilValue(keyResultAtomFamily(keyResultID))
const hasData = Boolean(keyResult?.teamId)

const toggleChecklistCollapse = () => {
setIsChecklistOpen((previous) => !previous)
}
Expand Down Expand Up @@ -105,13 +109,13 @@ export const KeyResultChecklistWrapper = ({
setHiddingModal(false)
}

return (
return isLoading || hasData ? (
<Stack spacing={0}>
<Stack direction="row" alignItems="flex-start" position="relative">
<IntlLink
href={
teamID && keyResultID
? `/explore/${teamID}?activeTab=tasks&key_result_id__id=${keyResultID}`
keyResult?.teamId && keyResultID
? `/explore/${keyResult?.teamId}?activeTab=tasks&key_result_id__id=${keyResultID}`
: '#'
}
onClick={handleClose}
Expand Down Expand Up @@ -148,11 +152,12 @@ export const KeyResultChecklistWrapper = ({
nodes={tasks}
keyResultID={keyResultID}
canCreate={!canCreate}
teamId={teamID}
teamId={keyResult?.teamId}
onUpdate={refetch}
/>
</Collapse>
) : undefined}
</Stack>
)
) : // eslint-disable-next-line unicorn/no-null
null
}
3 changes: 2 additions & 1 deletion src/components/Page/Team/Header/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ export const MenuHeader = ({ teamId, team }: MenuHeaderProperties) => {
setIsReloadNecessary(true)
dispatchEventCreateDraftObjective({})
},
onError: () => {
onError: (error) => {
console.error('Erro na mutação (capturado pelo onError):', error)
toast({
title: intl.formatMessage(messages.draftObjectiveErrorToastMessage),
status: 'error',
Expand Down
Loading