277 lines
6.2 KiB
TypeScript
277 lines
6.2 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;
|
|
// Common fields for Employee and Contractor
|
|
phone_number?: string | null;
|
|
aadhar_number?: string | null;
|
|
bank_account_number?: string | null;
|
|
bank_name?: string | null;
|
|
bank_ifsc?: string | null;
|
|
// Contractor-specific fields
|
|
contractor_agreement_number?: string | null;
|
|
pf_number?: string | null;
|
|
esic_number?: string | null;
|
|
}
|
|
|
|
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;
|
|
completed_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"
|
|
| "HalfDay"
|
|
| "Late";
|
|
|
|
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;
|
|
remark?: string | null;
|
|
created_at: Date;
|
|
employee_name?: string;
|
|
supervisor_name?: string;
|
|
department_name?: string;
|
|
contractor_name?: string;
|
|
}
|
|
|
|
// Employee swap types
|
|
export type SwapReason = "LeftWork" | "Sick" | "FinishedEarly" | "Other";
|
|
export type SwapStatus = "Active" | "Completed" | "Cancelled";
|
|
|
|
export interface EmployeeSwap {
|
|
id: number;
|
|
employee_id: number;
|
|
original_department_id: number;
|
|
target_department_id: number;
|
|
original_contractor_id: number | null;
|
|
target_contractor_id: number | null;
|
|
swap_reason: SwapReason;
|
|
reason_details: string | null;
|
|
work_completion_percentage: number;
|
|
swap_date: Date;
|
|
swapped_by: number;
|
|
status: SwapStatus;
|
|
created_at: Date;
|
|
completed_at: Date | null;
|
|
// Joined fields
|
|
employee_name?: string;
|
|
original_department_name?: string;
|
|
target_department_name?: string;
|
|
original_contractor_name?: string;
|
|
target_contractor_name?: string;
|
|
swapped_by_name?: string;
|
|
}
|
|
|
|
export interface CreateSwapRequest {
|
|
employeeId: number;
|
|
targetDepartmentId: number;
|
|
targetContractorId?: number;
|
|
swapReason: SwapReason;
|
|
reasonDetails?: string;
|
|
workCompletionPercentage?: number;
|
|
swapDate: string;
|
|
}
|
|
|
|
export interface UpdateAttendanceStatusRequest {
|
|
status: AttendanceStatus;
|
|
remark?: 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;
|
|
// Common fields for Employee and Contractor
|
|
phoneNumber?: string | null;
|
|
aadharNumber?: string | null;
|
|
bankAccountNumber?: string | null;
|
|
bankName?: string | null;
|
|
bankIfsc?: string | null;
|
|
// Contractor-specific fields
|
|
contractorAgreementNumber?: string | null;
|
|
pfNumber?: string | null;
|
|
esicNumber?: string | null;
|
|
}
|
|
|
|
export interface UpdateUserRequest {
|
|
name?: string;
|
|
email?: string;
|
|
role?: UserRole;
|
|
departmentId?: number | null;
|
|
contractorId?: number | null;
|
|
isActive?: boolean;
|
|
// Common fields for Employee and Contractor
|
|
phoneNumber?: string | null;
|
|
aadharNumber?: string | null;
|
|
bankAccountNumber?: string | null;
|
|
bankName?: string | null;
|
|
bankIfsc?: string | null;
|
|
// Contractor-specific fields
|
|
contractorAgreementNumber?: string | null;
|
|
pfNumber?: string | null;
|
|
esicNumber?: string | null;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
// Standard rate types
|
|
export interface StandardRate {
|
|
id: number;
|
|
sub_department_id: number | null;
|
|
activity: string | null;
|
|
rate: number;
|
|
effective_date: Date;
|
|
created_by: number;
|
|
created_at: Date;
|
|
sub_department_name?: string;
|
|
department_name?: string;
|
|
department_id?: number;
|
|
created_by_name?: string;
|
|
}
|
|
|
|
export interface CreateStandardRateRequest {
|
|
subDepartmentId?: number | null;
|
|
activity?: string | null;
|
|
rate: number;
|
|
effectiveDate: string;
|
|
}
|