diff --git a/frontend/composables/useHoursPage.ts b/frontend/composables/useHoursPage.ts index c59f541..f571c22 100644 --- a/frontend/composables/useHoursPage.ts +++ b/frontend/composables/useHoursPage.ts @@ -350,11 +350,30 @@ export const useHoursPage = () => { updatedAt: null }) - const isPresenceTracking = (employee: Employee) => employee.contract?.trackingMode === TRACKING_MODES.PRESENCE + // Résout le contrat à la date affichée (ligne du jour), avec repli sur le contrat courant. + const resolveDayContract = (employee: Employee) => { + const dayRow = dayContextByEmployeeId.value.get(employee.id) + if (dayRow?.hasContractAtDate) { + return { + trackingMode: dayRow.trackingMode ?? null, + weeklyHours: dayRow.weeklyHours ?? null, + type: dayRow.contractType ?? null, + name: dayRow.contractName ?? '' + } + } + return { + trackingMode: employee.contract?.trackingMode ?? null, + weeklyHours: employee.contract?.weeklyHours ?? null, + type: employee.contract?.type ?? null, + name: employee.contract?.name ?? '' + } + } + + const isPresenceTracking = (employee: Employee) => resolveDayContract(employee).trackingMode === TRACKING_MODES.PRESENCE const isTimeTracking = (employee: Employee) => !isPresenceTracking(employee) const is4hContract = (employeeId: number) => { const employee = employees.value.find((e) => e.id === employeeId) - return employee?.contract?.weeklyHours === 4 + return employee ? resolveDayContract(employee).weeklyHours === 4 : false } const isRowLocked = (employeeId: number) => { const row = rows.value[employeeId] @@ -365,8 +384,8 @@ export const useHoursPage = () => { } const contractLabel = (employee: Employee) => { - const contract = employee.contract - if (!contract) return '-' + const contract = resolveDayContract(employee) + if (!contract.type && !contract.name) return '-' if (contract.type === CONTRACT_TYPES.INTERIM) { return contract.name } diff --git a/frontend/services/dto/work-hour.ts b/frontend/services/dto/work-hour.ts index 03e6a41..2bdb72e 100644 --- a/frontend/services/dto/work-hour.ts +++ b/frontend/services/dto/work-hour.ts @@ -115,6 +115,10 @@ export type WorkHourDayContextRow = { formationLabel?: string | null virtualHolidayMinutes?: number contractNature?: 'CDI' | 'CDD' | 'INTERIM' | null + trackingMode?: TrackingMode | null + weeklyHours?: number | null + contractType?: string | null + contractName?: string | null } export type WorkHourDayContext = {