Skip to content

Commit bc3b26f

Browse files
authored
Fix/bud 131 (#635)
* fix bug on cycle edit * fix cycle update refetch
1 parent 5043a17 commit bc3b26f

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

src/components/Cycle/ActionModals/FormCycle/schema.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ export const NewCycleSchema = Yup.object().shape({
77
active: Yup.mixed().oneOf(Object.values(CYCLE_STATUS)).required(),
88
cadence: Yup.mixed().oneOf(Object.values(CADENCE)).required(),
99
parentId: Yup.string().nullable(),
10-
dateStart: Yup.date().required(),
11-
dateEnd: Yup.date().required(),
10+
dateStart: Yup.date()
11+
.required()
12+
.test(
13+
'is-not-before-end',
14+
'A data de início não pode ser anterior à data de fim.',
15+
function (dateStart) {
16+
const dataFimValue = this.parent.dateEnd
17+
return dateStart <= dataFimValue
18+
},
19+
),
20+
dateEnd: Yup.date()
21+
.required()
22+
.test(
23+
'is-not-after-start',
24+
'A data de fim não pode ser posterior à data de início.',
25+
function (dateEnd) {
26+
const dataInicioValue = this.parent.dateStart
27+
return dateEnd >= dataInicioValue
28+
},
29+
),
1230
})

src/components/Cycle/ActionModals/UpdateCycleModal/update-cycle.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ export const UpdateCycle = ({ teamId, parents, cycleId, onCancel }: UpdateCycleP
6767
period: cycle?.period ?? '',
6868
parentId: cycle?.cadence === CADENCE.YEARLY ? undefined : cycle?.parentId,
6969
active: cycle?.active ? CYCLE_STATUS.ACTIVE : CYCLE_STATUS.NOT_ACTIVE,
70+
dateEnd: cycle?.dateEnd ? cycle?.dateEnd.split('T')[0] : '',
71+
dateStart: cycle?.dateStart ? cycle?.dateStart.split('T')[0] : '',
7072
}
7173

7274
return (

src/components/Cycle/hooks/updateCycle/update-cycle.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { useMutation } from '@apollo/client'
22

3+
import GET_COMPANY_CYCLES from 'src/components/Report/hooks/getCompanyCycles/get-company-cycles.gql'
4+
35
import GET_CYCLES from '../getCycles/get-cycles.gql'
46

57
import UPDATE_CYCLE from './update-cycle.gql'
@@ -13,6 +15,10 @@ export const useUpdateCycle = () => {
1315
query: GET_CYCLES,
1416
variables: query,
1517
},
18+
{
19+
query: GET_COMPANY_CYCLES,
20+
variables: query,
21+
},
1622
],
1723
})
1824

0 commit comments

Comments
 (0)