From 3b88876e6477faac7f5aa4c118c3ba631fe2d2c0 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 16 Dec 2025 16:34:37 -0300 Subject: [PATCH 1/2] fix bug on cycle edit --- .../Cycle/ActionModals/FormCycle/schema.ts | 22 +++++++++++++++++-- .../UpdateCycleModal/update-cycle.tsx | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/components/Cycle/ActionModals/FormCycle/schema.ts b/src/components/Cycle/ActionModals/FormCycle/schema.ts index 8c5fcc72c..10e9ebd3a 100644 --- a/src/components/Cycle/ActionModals/FormCycle/schema.ts +++ b/src/components/Cycle/ActionModals/FormCycle/schema.ts @@ -7,6 +7,24 @@ export const NewCycleSchema = Yup.object().shape({ active: Yup.mixed().oneOf(Object.values(CYCLE_STATUS)).required(), cadence: Yup.mixed().oneOf(Object.values(CADENCE)).required(), parentId: Yup.string().nullable(), - dateStart: Yup.date().required(), - dateEnd: Yup.date().required(), + dateStart: Yup.date() + .required() + .test( + 'is-not-before-end', + 'A data de início não pode ser anterior à data de fim.', + function (dateStart) { + const dataFimValue = this.parent.dateEnd + return dateStart <= dataFimValue + }, + ), + dateEnd: Yup.date() + .required() + .test( + 'is-not-after-start', + 'A data de fim não pode ser posterior à data de início.', + function (dateEnd) { + const dataInicioValue = this.parent.dateStart + return dateEnd >= dataInicioValue + }, + ), }) diff --git a/src/components/Cycle/ActionModals/UpdateCycleModal/update-cycle.tsx b/src/components/Cycle/ActionModals/UpdateCycleModal/update-cycle.tsx index 489e410e3..81553fefb 100644 --- a/src/components/Cycle/ActionModals/UpdateCycleModal/update-cycle.tsx +++ b/src/components/Cycle/ActionModals/UpdateCycleModal/update-cycle.tsx @@ -67,6 +67,8 @@ export const UpdateCycle = ({ teamId, parents, cycleId, onCancel }: UpdateCycleP period: cycle?.period ?? '', parentId: cycle?.cadence === CADENCE.YEARLY ? undefined : cycle?.parentId, active: cycle?.active ? CYCLE_STATUS.ACTIVE : CYCLE_STATUS.NOT_ACTIVE, + dateEnd: cycle?.dateEnd ? cycle?.dateEnd.split('T')[0] : '', + dateStart: cycle?.dateStart ? cycle?.dateStart.split('T')[0] : '', } return ( From 7fd7ed10be5ed41f7bac8554e06f07799222725e Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 18 Dec 2025 10:33:33 -0300 Subject: [PATCH 2/2] fix cycle update refetch --- src/components/Cycle/hooks/updateCycle/update-cycle.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/Cycle/hooks/updateCycle/update-cycle.tsx b/src/components/Cycle/hooks/updateCycle/update-cycle.tsx index 4be9b9041..88e6ffe22 100644 --- a/src/components/Cycle/hooks/updateCycle/update-cycle.tsx +++ b/src/components/Cycle/hooks/updateCycle/update-cycle.tsx @@ -1,5 +1,7 @@ import { useMutation } from '@apollo/client' +import GET_COMPANY_CYCLES from 'src/components/Report/hooks/getCompanyCycles/get-company-cycles.gql' + import GET_CYCLES from '../getCycles/get-cycles.gql' import UPDATE_CYCLE from './update-cycle.gql' @@ -13,6 +15,10 @@ export const useUpdateCycle = () => { query: GET_CYCLES, variables: query, }, + { + query: GET_COMPANY_CYCLES, + variables: query, + }, ], })