feat : first commit

This commit is contained in:
2026-02-03 18:04:06 +01:00
parent 43b0364a5a
commit a5dcd5e3e9
101 changed files with 29976 additions and 96 deletions

View File

@@ -0,0 +1,38 @@
import type { AbsenceType } from './dto/absence-type'
import { extractItems } from '~/utils/api'
export const listAbsenceTypes = async () => {
const api = useApi()
const data = await api.get<AbsenceType[] | { 'hydra:member'?: AbsenceType[] }>(
'/absence_types',
{},
{ toast: false }
)
return extractItems<AbsenceType>(data)
}
export const createAbsenceType = async (
payload: Pick<AbsenceType, 'code' | 'label' | 'color'>
) => {
const api = useApi()
return api.post<AbsenceType>('/absence_types', payload, {
toastSuccessMessage: 'Type créé.'
})
}
export const updateAbsenceType = async (
id: number,
payload: Pick<AbsenceType, 'code' | 'label' | 'color'>
) => {
const api = useApi()
return api.patch<AbsenceType>(`/absence_types/${id}`, payload, {
toastSuccessMessage: 'Type mis à jour.'
})
}
export const deleteAbsenceType = async (id: number) => {
const api = useApi()
return api.delete(`/absence_types/${id}`, {}, {
toastSuccessMessage: 'Type supprimé.'
})
}

View File

@@ -0,0 +1,58 @@
import type { Absence } from './dto/absence'
import { extractItems } from '~/utils/api'
export const listAbsences = async () => {
const api = useApi()
const data = await api.get<Absence[] | { 'hydra:member'?: Absence[] }>(
'/absences',
{},
{ toast: false }
)
return extractItems<Absence>(data)
}
export const createAbsence = async (payload: {
employeeId: number
typeId: number
startDate: string
endDate: string
comment?: string
}) => {
const api = useApi()
return api.post<Absence>('/absences', {
employee: `/api/employees/${payload.employeeId}`,
type: `/api/absence_types/${payload.typeId}`,
startDate: payload.startDate,
endDate: payload.endDate,
comment: payload.comment
}, {
toastSuccessMessage: 'Absence créée.'
})
}
export const updateAbsence = async (payload: {
id: number
employeeId: number
typeId: number
startDate: string
endDate: string
comment?: string
}) => {
const api = useApi()
return api.patch<Absence>(`/absences/${payload.id}`, {
employee: `/api/employees/${payload.employeeId}`,
type: `/api/absence_types/${payload.typeId}`,
startDate: payload.startDate,
endDate: payload.endDate,
comment: payload.comment
}, {
toastSuccessMessage: 'Absence mise à jour.'
})
}
export const deleteAbsence = async (id: number) => {
const api = useApi()
return api.delete(`/absences/${id}`, {}, {
toastSuccessMessage: 'Absence supprimée.'
})
}

21
frontend/services/auth.ts Normal file
View File

@@ -0,0 +1,21 @@
import type { UserData } from './dto/user-data'
export const getCurrentUser = () => {
const api = useApi()
return api.get<UserData>('/me', {}, { toastErrorKey: 'errors.auth.session' })
}
export const login = (username: string, password: string) => {
const api = useApi()
return api.post('/login_check', { username, password }, {
toastErrorKey: 'errors.auth.login'
})
}
export const logout = () => {
const api = useApi()
return api.post('/logout', {}, {
toastErrorKey: 'errors.auth.logout',
toastSuccessKey: 'success.auth.logout'
})
}

View File

@@ -0,0 +1,6 @@
export type AbsenceType = {
id: number
code: string
label: string
color: string
}

View File

@@ -0,0 +1,11 @@
import type { Employee } from './employee'
import type { AbsenceType } from './absence-type'
export type Absence = {
id: number
startDate: string
endDate: string
comment?: string | null
employee: Employee
type: AbsenceType
}

View File

@@ -0,0 +1,5 @@
export type Employee = {
id: number
firstName: string
lastName: string
}

View File

@@ -0,0 +1,4 @@
export type UserData = {
id: number
username: string
}

View File

@@ -0,0 +1,36 @@
import type { Employee } from './dto/employee'
import { extractItems } from '~/utils/api'
export const listEmployees = async () => {
const api = useApi()
const data = await api.get<Employee[] | { 'hydra:member'?: Employee[] }>(
'/employees',
{},
{ toast: false }
)
return extractItems<Employee>(data)
}
export const createEmployee = async (payload: Pick<Employee, 'firstName' | 'lastName'>) => {
const api = useApi()
return api.post<Employee>('/employees', payload, {
toastSuccessMessage: 'Employé créé.'
})
}
export const updateEmployee = async (
id: number,
payload: Pick<Employee, 'firstName' | 'lastName'>
) => {
const api = useApi()
return api.patch<Employee>(`/employees/${id}`, payload, {
toastSuccessMessage: 'Employé mis à jour.'
})
}
export const deleteEmployee = async (id: number) => {
const api = useApi()
return api.delete(`/employees/${id}`, {}, {
toastSuccessMessage: 'Employé supprimé.'
})
}