diff --git a/frontend/components/employees/ContractTab.vue b/frontend/components/employees/ContractTab.vue
index 041c021..d81107c 100644
--- a/frontend/components/employees/ContractTab.vue
+++ b/frontend/components/employees/ContractTab.vue
@@ -162,9 +162,9 @@
-
+
@@ -235,6 +235,7 @@ defineProps<{
createContractNatureFieldClass: string
createContractFieldClass: string
createContractStartDateFieldClass: string
+ showsCreateContractEndDate: boolean
requiresCreateContractEndDate: boolean
createContractEndDateFieldClass: string
isCreateContractFormValid: boolean
diff --git a/frontend/composables/useEmployeeDetailPage.ts b/frontend/composables/useEmployeeDetailPage.ts
index 83fbe2f..5c807d4 100644
--- a/frontend/composables/useEmployeeDetailPage.ts
+++ b/frontend/composables/useEmployeeDetailPage.ts
@@ -11,7 +11,7 @@ import { getEmployeeRttSummary, createRttPayment } from '~/services/employee-rtt
import { getEmployee, updateEmployee } from '~/services/employees'
import { listPublicHolidays } from '~/services/public-holidays'
import { formatNullableYmdToFr, getTodayYmd, shiftYmd } from '~/utils/date'
-import { contractNatureLabel, isContractNature, requiresContractEndDate } from '~/utils/contract'
+import { contractNatureLabel, isContractNature, requiresContractEndDate, showsContractEndDate } from '~/utils/contract'
export const useEmployeeDetailPage = () => {
const route = useRoute()
@@ -99,6 +99,7 @@ export const useEmployeeDetailPage = () => {
const isContractEndDateValid = computed(() => contractForm.endDate !== '')
const showContractEndDateError = computed(() => validationTouched.endDate && !isContractEndDateValid.value)
+ const showsCreateContractEndDate = computed(() => showsContractEndDate(createContractForm.contractNature))
const requiresCreateContractEndDate = computed(() => requiresContractEndDate(createContractForm.contractNature))
const isCreateContractValid = computed(() => createContractForm.contractId !== '')
const isCreateContractNatureValid = computed(() => isContractNature(createContractForm.contractNature))
@@ -314,8 +315,8 @@ export const useEmployeeDetailPage = () => {
await loadEmployee()
}
- watch(requiresCreateContractEndDate, (required) => {
- if (!required) {
+ watch(showsCreateContractEndDate, (shows) => {
+ if (!shows) {
createContractForm.endDate = ''
}
})
@@ -353,6 +354,7 @@ export const useEmployeeDetailPage = () => {
createContractNatureFieldClass,
createContractFieldClass,
createContractStartDateFieldClass,
+ showsCreateContractEndDate,
requiresCreateContractEndDate,
createContractEndDateFieldClass,
isCreateContractFormValid,
diff --git a/frontend/pages/employees/[id].vue b/frontend/pages/employees/[id].vue
index a05f84a..a913583 100644
--- a/frontend/pages/employees/[id].vue
+++ b/frontend/pages/employees/[id].vue
@@ -78,6 +78,7 @@
:create-contract-nature-field-class="createContractNatureFieldClass"
:create-contract-field-class="createContractFieldClass"
:create-contract-start-date-field-class="createContractStartDateFieldClass"
+ :shows-create-contract-end-date="showsCreateContractEndDate"
:requires-create-contract-end-date="requiresCreateContractEndDate"
:create-contract-end-date-field-class="createContractEndDateFieldClass"
:is-create-contract-form-valid="isCreateContractFormValid"
@@ -131,6 +132,7 @@ const {
createContractNatureFieldClass,
createContractFieldClass,
createContractStartDateFieldClass,
+ showsCreateContractEndDate,
requiresCreateContractEndDate,
createContractEndDateFieldClass,
isCreateContractFormValid,
diff --git a/frontend/pages/employees/index.vue b/frontend/pages/employees/index.vue
index 76487a5..b67493b 100644
--- a/frontend/pages/employees/index.vue
+++ b/frontend/pages/employees/index.vue
@@ -154,7 +154,7 @@
La date de début est obligatoire.
-
+
@@ -199,7 +199,7 @@ import {listContracts} from '~/services/contracts'
import {createEmployee, deleteEmployee, listEmployees, updateEmployee} from '~/services/employees'
import {listSites} from '~/services/sites'
import SiteFilterSelector from '~/components/SiteFilterSelector.vue'
-import {contractNatureLabel, isContractNature, requiresContractEndDate} from '~/utils/contract'
+import {contractNatureLabel, isContractNature, requiresContractEndDate, showsContractEndDate} from '~/utils/contract'
useHead({
title: 'Employés'
@@ -264,6 +264,7 @@ const isSiteValid = computed(() => form.siteId !== '')
const isContractValid = computed(() => form.contractId !== '')
const isContractNatureValid = computed(() => isContractNature(form.contractNature))
const isContractStartDateValid = computed(() => form.contractStartDate !== '')
+const showsContractEndDateComputed = computed(() => showsContractEndDate(form.contractNature))
const requiresContractEndDateComputed = computed(() => requiresContractEndDate(form.contractNature))
const isContractEndDateValid = computed(() => {
if (!requiresContractEndDateComputed.value) return true
@@ -429,7 +430,7 @@ const handleSubmit = async () => {
contractId: Number(form.contractId),
contractNature: form.contractNature,
contractStartDate: form.contractStartDate,
- contractEndDate: requiresContractEndDateComputed.value ? form.contractEndDate : null
+ contractEndDate: form.contractEndDate || null
})
}
@@ -460,8 +461,8 @@ watch(isDrawerOpen, (isOpen) => {
}
})
-watch(requiresContractEndDateComputed, (required) => {
- if (!required) {
+watch(showsContractEndDateComputed, (shows) => {
+ if (!shows) {
form.contractEndDate = ''
}
})
diff --git a/frontend/utils/contract.ts b/frontend/utils/contract.ts
index 6b8a3a2..60aa7de 100644
--- a/frontend/utils/contract.ts
+++ b/frontend/utils/contract.ts
@@ -8,10 +8,14 @@ export const contractNatureLabel = (value?: ContractNature) => {
return 'CDI'
}
-export const requiresContractEndDate = (nature: ContractNature) => {
+export const showsContractEndDate = (nature: ContractNature) => {
return nature === 'CDD' || nature === 'INTERIM'
}
+export const requiresContractEndDate = (nature: ContractNature) => {
+ return nature === 'CDD'
+}
+
export const isContractNature = (value: string): value is ContractNature => {
return (CONTRACT_NATURES as readonly string[]).includes(value)
}