Ajout des notification + page employé (#6)
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled

| Numéro du ticket | Titre du ticket |
|------------------|-----------------|
|                  |                 |

## Description de la PR

## Modification du .env

## Check list

- [ ] Pas de régression
- [ ] TU/TI/TF rédigée
- [ ] TU/TI/TF OK
- [ ] CHANGELOG modifié

Reviewed-on: #6
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #6.
This commit is contained in:
2026-03-10 12:35:17 +00:00
committed by Autin
parent ae42c70d50
commit f493ea237b
126 changed files with 9215 additions and 935 deletions

View File

@@ -6,6 +6,7 @@ type ListAbsencesFilters = {
from?: string
to?: string
siteIds?: number[]
employeeId?: number
}
export const listAbsences = async (filters: ListAbsencesFilters = {}) => {
@@ -20,6 +21,9 @@ export const listAbsences = async (filters: ListAbsencesFilters = {}) => {
if (filters.siteIds && filters.siteIds.length > 0) {
query['employee.site[]'] = filters.siteIds.map((id) => `/api/sites/${id}`)
}
if (filters.employeeId) {
query.employee = `/api/employees/${filters.employeeId}`
}
const data = await api.get<Absence[] | { 'hydra:member'?: Absence[] }>(
'/absences',
query,

View File

@@ -0,0 +1,14 @@
export type EmployeeLeaveSummary = {
year: number
isSupported: boolean
ruleCode: string
acquiredDays: number
remainingDays: number
takenDays: number
acquiredSaturdays: number
remainingSaturdays: number
takenSaturdays: number
fractionedDays: number
accruingDays: number
}

View File

@@ -0,0 +1,24 @@
export type EmployeeRttWeekSummary = {
month: number
weekNumber: number
weekStart: string
weekEnd: string
recoveryMinutes: number
}
export type RttMonthPayment = {
month: number
paidMinutes25: number
paidMinutes50: number
}
export type EmployeeRttSummary = {
year: number
carryFromPreviousYearMinutes: number
currentYearRecoveryMinutes: number
totalPaidMinutes: number
availableMinutes: number
weeks: EmployeeRttWeekSummary[]
monthPayments: RttMonthPayment[]
}

View File

@@ -1,6 +1,16 @@
import type { Site } from './site'
import type { Contract } from './contract'
export type ContractHistoryItem = {
contractId?: number | null
contractName?: string | null
weeklyHours?: number | null
contractNature: 'CDI' | 'CDD' | 'INTERIM'
startDate: string
endDate?: string | null
comment?: string | null
}
export type Employee = {
id: number
firstName: string
@@ -10,5 +20,6 @@ export type Employee = {
currentContractNature?: 'CDI' | 'CDD' | 'INTERIM'
currentContractStartDate?: string | null
currentContractEndDate?: string | null
contractHistory?: ContractHistoryItem[]
displayOrder?: number
}

View File

@@ -0,0 +1,9 @@
export type NotificationItem = {
id: number
actorName: string
message: string
category: string
target: string
isRead: boolean
createdAt: string
}

View File

@@ -15,6 +15,7 @@ export type WorkHour = {
isPresentAfternoon?: boolean
isSiteValid?: boolean
isValid?: boolean
updatedAt?: string | null
}
export type WorkHourEntryPayload = {

View File

@@ -0,0 +1,18 @@
import type { EmployeeLeaveSummary } from './dto/employee-leave-summary'
export const getEmployeeLeaveSummary = async (employeeId: number, year?: number) => {
const api = useApi()
const query: Record<string, string> = {}
if (year) query.year = String(year)
return api.get<EmployeeLeaveSummary>(`/employees/${employeeId}/leave-summary`, query, { toast: false })
}
export const updateFractionedDays = async (employeeId: number, fractionedDays: number, year?: number) => {
const api = useApi()
const body: Record<string, unknown> = { fractionedDays }
if (year) body.year = year
return api.patch(`/employees/${employeeId}/fractioned-days`, body)
}

View File

@@ -0,0 +1,15 @@
import type { EmployeeRttSummary } from './dto/employee-rtt-summary'
export const getEmployeeRttSummary = async (employeeId: number, year?: number) => {
const api = useApi()
const query = year ? { year } : {}
return api.get<EmployeeRttSummary>(`/employees/${employeeId}/rtt-summary`, query, { toast: false })
}
export const createRttPayment = async (employeeId: number, month: number, minutes: number, rate: '25' | '50', year?: number) => {
const api = useApi()
const body: Record<string, unknown> = { month, minutes, rate }
if (year) body.year = year
return api.patch(`/employees/${employeeId}/rtt-payments`, body)
}

View File

@@ -21,6 +21,11 @@ export const listScopedEmployees = async () => {
return extractItems<Employee>(data)
}
export const getEmployee = async (id: number) => {
const api = useApi()
return api.get<Employee>(`/employees/${id}`, {}, { toast: false })
}
export const createEmployee = async (payload: {
firstName: string
lastName: string
@@ -51,24 +56,43 @@ export const updateEmployee = async (
firstName: string
lastName: string
siteId?: number | null
contractId: number
contractId?: number
contractNature?: 'CDI' | 'CDD' | 'INTERIM'
contractStartDate?: string
contractEndDate?: string | null
contractPaidLeaveSettled?: boolean
contractComment?: string | null
displayOrder?: number
}
) => {
const api = useApi()
return api.patch<Employee>(`/employees/${id}`, {
const body: Record<string, unknown> = {
firstName: payload.firstName,
lastName: payload.lastName,
site: payload.siteId ? `/api/sites/${payload.siteId}` : null,
contract: `/api/contracts/${payload.contractId}`,
contractNature: payload.contractNature,
contractStartDate: payload.contractStartDate,
contractEndDate: payload.contractEndDate ?? null,
displayOrder: payload.displayOrder
}, {
}
if (payload.contractId !== undefined) {
body.contract = `/api/contracts/${payload.contractId}`
}
if (payload.contractNature !== undefined) {
body.contractNature = payload.contractNature
}
if (payload.contractStartDate !== undefined) {
body.contractStartDate = payload.contractStartDate
}
if (payload.contractEndDate !== undefined) {
body.contractEndDate = payload.contractEndDate ?? null
}
if (payload.contractPaidLeaveSettled !== undefined) {
body.contractPaidLeaveSettled = payload.contractPaidLeaveSettled
}
if (payload.contractComment !== undefined) {
body.contractComment = payload.contractComment ?? null
}
return api.patch<Employee>(`/employees/${id}`, body, {
toastSuccessKey: 'success.employee.update',
toastErrorKey: 'errors.employee.update'
})

View File

@@ -0,0 +1,40 @@
import type { NotificationItem } from './dto/notification'
import { extractItems } from '~/utils/api'
export const listUnreadNotifications = async () => {
const api = useApi()
const data = await api.get<NotificationItem[] | { 'hydra:member'?: NotificationItem[] }>(
'/notifications/unread',
{},
{ toast: false }
)
return extractItems<NotificationItem>(data)
}
export const listTodayNotifications = async () => {
const api = useApi()
const data = await api.get<NotificationItem[] | { 'hydra:member'?: NotificationItem[] }>(
'/notifications/today',
{},
{ toast: false }
)
return extractItems<NotificationItem>(data)
}
export const listHistoryNotifications = async () => {
const api = useApi()
const data = await api.get<NotificationItem[] | { 'hydra:member'?: NotificationItem[] }>(
'/notifications/history',
{},
{ toast: false }
)
return extractItems<NotificationItem>(data)
}
export const markAllNotificationsRead = async () => {
const api = useApi()
return api.post('/notifications/mark-all-read', {}, { toast: false })
}