Production deployment with Docker and full system fixes
- Added Docker support (Dockerfiles, docker-compose.yml) - Fixed authentication and authorization (token storage, CORS, permissions) - Fixed API response transformations for all modules - Added production deployment scripts and guides - Fixed frontend permission checks and module access - Added database seeding script for production - Complete documentation for deployment and configuration Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
134
frontend/src/lib/api/employees.ts
Normal file
134
frontend/src/lib/api/employees.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
import { api } from '../api'
|
||||
|
||||
export interface Employee {
|
||||
id: string
|
||||
uniqueEmployeeId: string
|
||||
firstName: string
|
||||
lastName: string
|
||||
firstNameAr?: string
|
||||
lastNameAr?: string
|
||||
email: string
|
||||
phone?: string
|
||||
mobile: string
|
||||
dateOfBirth?: string
|
||||
gender?: string
|
||||
nationality?: string
|
||||
nationalId?: string
|
||||
passportNumber?: string
|
||||
employmentType: string
|
||||
contractType?: string
|
||||
hireDate: string
|
||||
endDate?: string
|
||||
departmentId: string
|
||||
department?: any
|
||||
positionId: string
|
||||
position?: any
|
||||
reportingToId?: string
|
||||
reportingTo?: any
|
||||
baseSalary: number
|
||||
status: string
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface CreateEmployeeData {
|
||||
firstName: string
|
||||
lastName: string
|
||||
firstNameAr?: string
|
||||
lastNameAr?: string
|
||||
email: string
|
||||
phone?: string
|
||||
mobile: string
|
||||
dateOfBirth?: string
|
||||
gender?: string
|
||||
nationality?: string
|
||||
nationalId?: string
|
||||
employmentType: string
|
||||
contractType?: string
|
||||
hireDate: string
|
||||
departmentId: string
|
||||
positionId: string
|
||||
reportingToId?: string
|
||||
baseSalary: number
|
||||
}
|
||||
|
||||
export interface UpdateEmployeeData extends Partial<CreateEmployeeData> {}
|
||||
|
||||
export interface EmployeeFilters {
|
||||
search?: string
|
||||
departmentId?: string
|
||||
positionId?: string
|
||||
status?: string
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface EmployeesResponse {
|
||||
employees: Employee[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
totalPages: number
|
||||
}
|
||||
|
||||
export const employeesAPI = {
|
||||
// Get all employees with filters and pagination
|
||||
getAll: async (filters: EmployeeFilters = {}): Promise<EmployeesResponse> => {
|
||||
const params = new URLSearchParams()
|
||||
if (filters.search) params.append('search', filters.search)
|
||||
if (filters.departmentId) params.append('departmentId', filters.departmentId)
|
||||
if (filters.positionId) params.append('positionId', filters.positionId)
|
||||
if (filters.status) params.append('status', filters.status)
|
||||
if (filters.page) params.append('page', filters.page.toString())
|
||||
if (filters.pageSize) params.append('pageSize', filters.pageSize.toString())
|
||||
|
||||
const response = await api.get(`/hr/employees?${params.toString()}`)
|
||||
const { data, pagination } = response.data
|
||||
return {
|
||||
employees: data || [],
|
||||
total: pagination?.total || 0,
|
||||
page: pagination?.page || 1,
|
||||
pageSize: pagination?.pageSize || 20,
|
||||
totalPages: pagination?.totalPages || 0,
|
||||
}
|
||||
},
|
||||
|
||||
// Get single employee by ID
|
||||
getById: async (id: string): Promise<Employee> => {
|
||||
const response = await api.get(`/hr/employees/${id}`)
|
||||
return response.data.data
|
||||
},
|
||||
|
||||
// Create new employee
|
||||
create: async (data: CreateEmployeeData): Promise<Employee> => {
|
||||
const response = await api.post('/hr/employees', data)
|
||||
return response.data.data
|
||||
},
|
||||
|
||||
// Update existing employee
|
||||
update: async (id: string, data: UpdateEmployeeData): Promise<Employee> => {
|
||||
const response = await api.put(`/hr/employees/${id}`, data)
|
||||
return response.data.data
|
||||
},
|
||||
|
||||
// Delete employee
|
||||
delete: async (id: string): Promise<void> => {
|
||||
await api.delete(`/hr/employees/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Departments API
|
||||
export const departmentsAPI = {
|
||||
getAll: async (): Promise<any[]> => {
|
||||
const response = await api.get('/hr/departments')
|
||||
return response.data.data
|
||||
}
|
||||
}
|
||||
|
||||
// Positions API
|
||||
export const positionsAPI = {
|
||||
getAll: async (): Promise<any[]> => {
|
||||
const response = await api.get('/hr/positions')
|
||||
return response.data.data
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user