171 lines
3.5 KiB
TypeScript
171 lines
3.5 KiB
TypeScript
// User types
|
|
export type UserRole = "SuperAdmin" | "Supervisor" | "Contractor" | "Employee";
|
|
|
|
export interface User {
|
|
id: number;
|
|
username: string;
|
|
name: string;
|
|
email: string;
|
|
password?: string;
|
|
role: UserRole;
|
|
department_id: number | null;
|
|
contractor_id: number | null;
|
|
is_active: boolean;
|
|
created_at: Date;
|
|
department_name?: string;
|
|
contractor_name?: string;
|
|
}
|
|
|
|
export interface JWTPayload {
|
|
id: number;
|
|
username: string;
|
|
role: UserRole;
|
|
departmentId: number | null;
|
|
exp: number;
|
|
iat: number;
|
|
}
|
|
|
|
// Department types
|
|
export interface Department {
|
|
id: number;
|
|
name: string;
|
|
created_at: Date;
|
|
}
|
|
|
|
export interface SubDepartment {
|
|
id: number;
|
|
department_id: number;
|
|
name: string;
|
|
primary_activity: string;
|
|
created_at: Date;
|
|
}
|
|
|
|
// Work allocation types
|
|
export type AllocationStatus = "Pending" | "InProgress" | "Completed" | "Cancelled";
|
|
|
|
export interface WorkAllocation {
|
|
id: number;
|
|
employee_id: number;
|
|
supervisor_id: number;
|
|
contractor_id: number;
|
|
sub_department_id: number | null;
|
|
activity: string | null;
|
|
description: string | null;
|
|
assigned_date: Date;
|
|
completion_date: Date | null;
|
|
status: AllocationStatus;
|
|
rate: number | null;
|
|
units: number | null;
|
|
total_amount: number | null;
|
|
created_at: Date;
|
|
employee_name?: string;
|
|
supervisor_name?: string;
|
|
contractor_name?: string;
|
|
sub_department_name?: string;
|
|
department_name?: string;
|
|
}
|
|
|
|
// Attendance types
|
|
export type AttendanceStatus = "CheckedIn" | "CheckedOut" | "Absent";
|
|
|
|
export interface Attendance {
|
|
id: number;
|
|
employee_id: number;
|
|
supervisor_id: number;
|
|
check_in_time: Date | null;
|
|
check_out_time: Date | null;
|
|
work_date: Date;
|
|
status: AttendanceStatus;
|
|
created_at: Date;
|
|
employee_name?: string;
|
|
supervisor_name?: string;
|
|
department_name?: string;
|
|
contractor_name?: string;
|
|
}
|
|
|
|
// Contractor rate types
|
|
export interface ContractorRate {
|
|
id: number;
|
|
contractor_id: number;
|
|
sub_department_id: number | null;
|
|
activity: string | null;
|
|
rate: number;
|
|
effective_date: Date;
|
|
created_at: Date;
|
|
contractor_name?: string;
|
|
sub_department_name?: string;
|
|
department_name?: string;
|
|
}
|
|
|
|
// API response types
|
|
export interface ApiError {
|
|
error: string;
|
|
details?: string;
|
|
}
|
|
|
|
export interface ApiSuccess<T> {
|
|
data: T;
|
|
message?: string;
|
|
}
|
|
|
|
export interface LoginResponse {
|
|
token: string;
|
|
user: Omit<User, "password">;
|
|
}
|
|
|
|
// Request body types
|
|
export interface LoginRequest {
|
|
username: string;
|
|
password: string;
|
|
}
|
|
|
|
export interface CreateUserRequest {
|
|
username: string;
|
|
name: string;
|
|
email: string;
|
|
password: string;
|
|
role: UserRole;
|
|
departmentId?: number | null;
|
|
contractorId?: number | null;
|
|
}
|
|
|
|
export interface UpdateUserRequest {
|
|
name?: string;
|
|
email?: string;
|
|
role?: UserRole;
|
|
departmentId?: number | null;
|
|
contractorId?: number | null;
|
|
isActive?: boolean;
|
|
}
|
|
|
|
export interface ChangePasswordRequest {
|
|
currentPassword: string;
|
|
newPassword: string;
|
|
}
|
|
|
|
export interface CreateWorkAllocationRequest {
|
|
employeeId: number;
|
|
contractorId: number;
|
|
subDepartmentId?: number | null;
|
|
activity?: string | null;
|
|
description?: string | null;
|
|
assignedDate: string;
|
|
rate?: number | null;
|
|
units?: number | null;
|
|
totalAmount?: number | null;
|
|
departmentId?: number | null;
|
|
}
|
|
|
|
export interface CheckInOutRequest {
|
|
employeeId: number;
|
|
workDate: string;
|
|
}
|
|
|
|
export interface CreateContractorRateRequest {
|
|
contractorId: number;
|
|
subDepartmentId?: number | null;
|
|
activity?: string | null;
|
|
rate: number;
|
|
effectiveDate: string;
|
|
}
|