From 27e83ab28100c61ab558a2610d6be1f984a82b3c Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 11 Jun 2025 17:32:49 -0300 Subject: [PATCH 01/10] change bud kr checklist to wait until keyresult is loaded --- .../KeyResult/Single/Drawer/Body/body.tsx | 2 +- .../Single/Sections/Checklist/wrapper.tsx | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) 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/wrapper.tsx b/src/components/KeyResult/Single/Sections/Checklist/wrapper.tsx index 96200dca0..d5f94b75d 100644 --- a/src/components/KeyResult/Single/Sections/Checklist/wrapper.tsx +++ b/src/components/KeyResult/Single/Sections/Checklist/wrapper.tsx @@ -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, @@ -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('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 } From 7d82f403301e72ea144f90a7f8cc9d6ee72ea697 Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 12 Jun 2025 12:55:35 -0300 Subject: [PATCH 02/10] debug fix on objective header --- src/components/Page/Team/Header/menu.tsx | 29 +++++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/components/Page/Team/Header/menu.tsx b/src/components/Page/Team/Header/menu.tsx index 71864281e..a8f3ed14a 100644 --- a/src/components/Page/Team/Header/menu.tsx +++ b/src/components/Page/Team/Header/menu.tsx @@ -113,11 +113,13 @@ export const MenuHeader = ({ teamId, team }: MenuHeaderProperties) => { teamID: teamId, }, onCompleted: async (data) => { + console.log('Mutação concluída:', data) setObjectiveIDToEditMode(data.createObjective.id) setIsReloadNecessary(true) dispatchEventCreateDraftObjective({}) }, - onError: () => { + onError: (error) => { + console.error('Erro na mutação (capturado pelo onError):', error) toast({ title: intl.formatMessage(messages.draftObjectiveErrorToastMessage), status: 'error', @@ -127,17 +129,32 @@ export const MenuHeader = ({ teamId, team }: MenuHeaderProperties) => { ) const onCreateOKR = async (cycleID?: string) => { + console.log('onCreateOKR iniciado.') + console.log('Variáveis para createDraftObjective:', { cycleID }) + console.log('ownerID:', ownerID) + console.log('teamId:', teamId) + console.log('title:', intl.formatMessage(messages.draftObjectiveTitle)) + const valueStoraged = get(workflowControlStorageKey) + console.log('valueStoraged antes da mutação:', valueStoraged) - await createDraftObjective({ - variables: { - cycleID, - }, - }) + try { + await createDraftObjective({ + variables: { + cycleID, + }, + }) + console.log('createDraftObjective chamada com sucesso.') + } catch (error: unknown) { + console.error('Erro ao chamar createDraftObjective (fora do onError):', error) + } if (valueStoraged) { register(workflowControlStorageKey, false) + console.log('workflowControlStorageKey registrado como false.') } + + console.log('onCreateOKR finalizado.') } const handleViewOldCycles = () => { From e990b05d9fdeb3e1e8633b0712fa3dda33e5ff22 Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 13 Jun 2025 09:03:33 -0300 Subject: [PATCH 03/10] debug create task button --- .../Checklist/ActionButtons/create-task-in-kr.tsx | 8 +++++++- .../KeyResult/Single/Sections/Checklist/checklist.tsx | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) 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..f0cbc2e35 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 @@ -1,6 +1,6 @@ import { Button, Box, Spinner, StyleProps } from '@chakra-ui/react' import styled from '@emotion/styled' -import React, { Ref, useState } from 'react' +import React, { Ref, useEffect, useState } from 'react' import { useIntl } from 'react-intl' import { useRecoilValue } from 'recoil' @@ -62,6 +62,8 @@ export const CreateTaskButton = ({ return } + console.log('time quando clica no botão', teamId) + setIsSubmitting(true) await addNewTask({ team: teamId as string, @@ -86,6 +88,10 @@ export const CreateTaskButton = ({ if (onCreate) onCreate() } + useEffect(() => { + console.log('valor do time no botão de criar time', teamId) + }, [teamId]) + const toggleAdd = () => { setIsAdding((isAdding) => !isAdding) } diff --git a/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx b/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx index f1fa50fae..32ee751f2 100644 --- a/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx +++ b/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx @@ -1,6 +1,6 @@ import { Stack, StyleProps } from '@chakra-ui/react' import styled from '@emotion/styled' -import React, { useRef } from 'react' +import React, { useEffect, useRef } from 'react' import { Task } from 'src/services/new-task-management/@types/task.type' import { TaskSummary } from 'src/services/okr/key-result/@types' @@ -39,6 +39,10 @@ export const KeyResultChecklist = ({ }: KeyResultChecklistProperties) => { const createButtonReference = useRef(null) + useEffect(() => { + console.log('valor do time no checklist', teamId) + }, [teamId]) + return ( <> {nodes.length > 0 && ( From 32a256a46f2aa6eba50750247da474502a90b49e Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 13 Jun 2025 09:31:20 -0300 Subject: [PATCH 04/10] debug task creation --- .../ActionButtons/create-task-in-kr.tsx | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) 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 f0cbc2e35..d44668615 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 @@ -103,40 +103,42 @@ export const CreateTaskButton = ({ } return ( - - {isAdding && ( - - - - )} - - + + )} + + + ) ) } From 7a71523e678c95d10b82a54ce0acd5b7da164f98 Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 13 Jun 2025 09:38:13 -0300 Subject: [PATCH 05/10] debug task add button --- .../ActionButtons/create-task-in-kr.tsx | 72 +++++++++---------- .../Single/Sections/Checklist/checklist.tsx | 2 +- 2 files changed, 36 insertions(+), 38 deletions(-) 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 d44668615..276077fb3 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 @@ -90,7 +90,7 @@ export const CreateTaskButton = ({ useEffect(() => { console.log('valor do time no botão de criar time', teamId) - }, [teamId]) + }, []) const toggleAdd = () => { setIsAdding((isAdding) => !isAdding) @@ -103,42 +103,40 @@ export const CreateTaskButton = ({ } return ( - teamId && ( - - {isAdding && ( - - + {isAdding && ( + + + + )} + - - ) + + } + onClick={toggleAdd} + > + {label ?? intl.formatMessage(messages.newCheckMarkButtonLabel)} + + ) } diff --git a/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx b/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx index 32ee751f2..3d0327469 100644 --- a/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx +++ b/src/components/KeyResult/Single/Sections/Checklist/checklist.tsx @@ -59,7 +59,7 @@ export const KeyResultChecklist = ({ )} - {canCreate && ( + {canCreate && teamId && ( Date: Fri, 13 Jun 2025 10:03:01 -0300 Subject: [PATCH 06/10] debug button that add task --- .../ActionButtons/create-task-in-kr.tsx | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) 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 276077fb3..dc7497661 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 @@ -50,6 +50,7 @@ export const CreateTaskButton = ({ const [isAdding, setIsAdding] = useState(false) const [isSubmitting, setIsSubmitting] = useState(false) + const [teamID, setTeamID] = useState() const intl = useIntl() const userID = useRecoilValue(meAtom) const { dispatch } = useEvent(EventType.TASK_MANAGER_CREATE_TASK_CLICK) @@ -62,35 +63,38 @@ export const CreateTaskButton = ({ return } - console.log('time quando clica no botão', teamId) + console.log('time quando clica no botão', teamID) 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: '', - }) - - dispatch({ keyResultID }) - setIsSubmitting(false) - toggleAdd() - if (onCreate) onCreate() + if (teamID) { + await addNewTask({ + team: 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) + toggleAdd() + if (onCreate) onCreate() + } } useEffect(() => { console.log('valor do time no botão de criar time', teamId) - }, []) + setTeamID(teamId) + }, [teamId]) const toggleAdd = () => { setIsAdding((isAdding) => !isAdding) From 4d4fde1082bfb80c5812d382b8255ee0ec1b58bc Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 13 Jun 2025 10:24:03 -0300 Subject: [PATCH 07/10] debug new task button --- .../ActionButtons/create-task-in-kr.tsx | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) 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 dc7497661..23863ac8a 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 @@ -83,12 +83,12 @@ export const CreateTaskButton = ({ key_result: keyResultID, cycle: '', }) - - dispatch({ keyResultID }) - setIsSubmitting(false) - toggleAdd() - if (onCreate) onCreate() } + + dispatch({ keyResultID }) + setIsSubmitting(false) + toggleAdd() + if (onCreate) onCreate() } useEffect(() => { @@ -119,28 +119,30 @@ export const CreateTaskButton = ({ /> )} - + {teamID && ( + + )} ) } From 33ffe9e00f1fa5922820180320da853e21ead035 Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 13 Jun 2025 11:19:38 -0300 Subject: [PATCH 08/10] debug task --- .../ActionButtons/create-task-in-kr.tsx | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) 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 23863ac8a..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 @@ -1,6 +1,6 @@ import { Button, Box, Spinner, StyleProps } from '@chakra-ui/react' import styled from '@emotion/styled' -import React, { Ref, useEffect, useState } from 'react' +import React, { Ref, useState } from 'react' import { useIntl } from 'react-intl' import { useRecoilValue } from 'recoil' @@ -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' @@ -50,11 +51,13 @@ export const CreateTaskButton = ({ const [isAdding, setIsAdding] = useState(false) const [isSubmitting, setIsSubmitting] = useState(false) - const [teamID, setTeamID] = useState() const intl = useIntl() 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,12 +66,10 @@ export const CreateTaskButton = ({ return } - console.log('time quando clica no botão', teamID) - setIsSubmitting(true) - if (teamID) { + if (teamId || keyResult) { await addNewTask({ - team: teamID, + team: teamId ?? keyResult?.teamId ?? '', status: TASK_STATUS.pending, title, description: '', @@ -91,11 +92,6 @@ export const CreateTaskButton = ({ if (onCreate) onCreate() } - useEffect(() => { - console.log('valor do time no botão de criar time', teamId) - setTeamID(teamId) - }, [teamId]) - const toggleAdd = () => { setIsAdding((isAdding) => !isAdding) } @@ -119,7 +115,7 @@ export const CreateTaskButton = ({ /> )} - {teamID && ( + {(teamId ?? hasData) && (