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
22 changes: 20 additions & 2 deletions src/components/Cycle/ActionModals/FormCycle/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
),
})
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 6 additions & 0 deletions src/components/Cycle/hooks/updateCycle/update-cycle.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -13,6 +15,10 @@ export const useUpdateCycle = () => {
query: GET_CYCLES,
variables: query,
},
{
query: GET_COMPANY_CYCLES,
variables: query,
},
],
})

Expand Down
Loading