diff --git a/src/components/KeyResult/Single/Drawer/Body/body.tsx b/src/components/KeyResult/Single/Drawer/Body/body.tsx index d4b4ad236..951a3e851 100644 --- a/src/components/KeyResult/Single/Drawer/Body/body.tsx +++ b/src/components/KeyResult/Single/Drawer/Body/body.tsx @@ -120,7 +120,7 @@ const KeyResultDrawerBody = ({ )} - + diff --git a/src/components/KeyResult/Single/Sections/Checklist/ActionButtons/create-task-in-kr.tsx b/src/components/KeyResult/Single/Sections/Checklist/ActionButtons/create-task-in-kr.tsx index 6bb951c6c..797eac597 100644 --- a/src/components/KeyResult/Single/Sections/Checklist/ActionButtons/create-task-in-kr.tsx +++ b/src/components/KeyResult/Single/Sections/Checklist/ActionButtons/create-task-in-kr.tsx @@ -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' @@ -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 @@ -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) @@ -109,28 +115,30 @@ export const CreateTaskButton = ({ /> )} - + {(teamId ?? hasData) && ( + + )} ) } diff --git a/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx b/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx index f1fa50fae..910dce4a6 100644 --- a/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx +++ b/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx @@ -55,7 +55,7 @@ export const KeyResultChecklist = ({ )} - {canCreate && ( + {canCreate && teamId && ( { const timelineSelector = buildPartialSelector('timeline') @@ -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) } @@ -105,13 +109,13 @@ export const KeyResultChecklistWrapper = ({ setHiddingModal(false) } - return ( + return isLoading || hasData ? ( ) : undefined} - ) + ) : // eslint-disable-next-line unicorn/no-null + null } diff --git a/src/components/Page/Team/Header/menu.tsx b/src/components/Page/Team/Header/menu.tsx index 71864281e..8418e01d7 100644 --- a/src/components/Page/Team/Header/menu.tsx +++ b/src/components/Page/Team/Header/menu.tsx @@ -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',