Files
frontend/src/types/index.ts
T
2026-06-02 11:04:38 +08:00

267 lines
5.6 KiB
TypeScript

export type UserRole = 'admin' | 'technician' | 'employee';
export interface User {
id: number;
username: string;
name: string;
email?: string;
phone?: string;
employeeNo?: string;
position?: string;
role: UserRole;
createdAt: string;
employeeSerials?: EmployeeSerial[];
}
export interface CreateUserRequest {
username?: string;
password?: string;
name: string;
email?: string;
phone: string;
employeeNo: string;
position: string;
role: UserRole;
}
export interface UpdateUserRequest {
name?: string;
email?: string;
phone?: string;
employeeNo?: string;
position?: string;
role?: UserRole;
}
export interface UserListFilter {
page?: number;
limit?: number;
role?: UserRole;
search?: string;
}
export interface UserListResponse {
data: User[];
pagination: EmployeeSerialPagination;
}
export interface Company {
id: number;
name: string;
status: 'active' | 'disabled';
createdAt: string;
serials?: Serial[];
}
export interface Serial {
id: number;
serialNumber: string;
companyId: number;
companyName: string;
status: 'active' | 'disabled';
validUntil: string;
createdAt: string;
}
export interface GenerateSerialRequest {
companyName: string;
serialOption: 'auto' | 'custom';
serialPrefix?: string;
quantity: number;
validOption: 'days' | 'date';
validDays?: number;
validUntil?: string;
}
export interface GenerateSerialResponse {
companyName: string;
serials: Array<{
serialNumber: string;
validUntil: string;
}>;
qrCode: string;
}
export interface AuthResponse {
token: string;
user: User;
}
export interface LoginRequest {
username: string;
password: string;
remember?: boolean;
}
export interface UpdateProfileRequest {
name?: string;
email?: string;
}
export interface ChangePasswordRequest {
currentPassword: string;
newPassword: string;
}
export interface ApiResponse<T> {
success: boolean;
data?: T;
error?: string;
}
export interface DashboardRecentAftersales {
serialNumber: string;
companyName: string;
serviceType: AftersalesServiceType;
workOrderStatus: AftersalesWorkOrderStatus;
authorizationStatus: AftersalesAuthorizationStatus;
technicianName: string;
createdAt: string;
}
export interface DashboardStats {
totalCompanies: number;
totalSerials: number;
totalEmployeeSerials: number;
activeSerials: number;
inactiveSerials: number;
totalAftersales: number;
pendingConfirmation: number;
closedAftersales: number;
rejectedAftersales: number;
monthlyData: Array<{
month: string;
companies: number;
serials: number;
}>;
recentCompanies: Company[];
recentSerials: Serial[];
recentAftersales: DashboardRecentAftersales[];
}
export interface CompanyFilter {
search?: string;
status?: 'all' | 'active' | 'expired';
}
export interface EmployeeSerial {
id?: number;
serialNumber: string;
companyName: string;
position: string;
employeeName: string;
employeeId?: number;
employee?: User;
isActive: boolean;
createdAt: string;
updatedAt?: string;
}
export interface EmployeeSerialFilter {
search?: string;
page?: number;
limit?: number;
}
export interface EmployeeSerialPagination {
page: number;
limit: number;
total: number;
totalPages: number;
}
export interface EmployeeSerialResponse {
data: EmployeeSerial[];
pagination: EmployeeSerialPagination;
}
export type AftersalesServiceType = 'software' | 'hardware' | 'maintenance';
export type AftersalesWorkOrderStatus = 'created' | 'pending_confirmation' | 'closed' | 'rejected';
export type AftersalesAuthorizationStatus = 'pending' | 'authorized' | 'unauthorized';
export interface AftersalesOrder {
id: number;
serialNumber: string;
companyName: string;
companyAddress: string;
contactName: string;
contactPhone: string;
serviceType: AftersalesServiceType;
issueDescription: string;
resolutionNote: string;
workOrderStatus: AftersalesWorkOrderStatus;
authorizationStatus: AftersalesAuthorizationStatus;
technicianId?: number;
createdBy?: number;
scannedAt?: string;
confirmedAt?: string;
rejectCount: number;
signature?: string;
responsibleSignature?: string;
siteImages?: string[];
createdAt: string;
updatedAt: string;
technician?: User;
creator?: User;
}
export interface AftersalesPublicView {
serialNumber: string;
companyName: string;
companyAddress: string;
contactName: string;
serviceType: AftersalesServiceType;
issueDescription: string;
resolutionNote: string;
workOrderStatus: AftersalesWorkOrderStatus;
authorizationStatus: AftersalesAuthorizationStatus;
technicianName: string;
createdAt: string;
confirmedAt?: string;
signature?: string;
responsibleSignature?: string;
siteImages?: string[];
}
export interface CreateAftersalesRequest {
companyName: string;
companyAddress: string;
contactName: string;
contactPhone: string;
serviceType: AftersalesServiceType;
issueDescription: string;
technicianId?: number;
}
export interface UpdateAftersalesRequest {
companyAddress?: string;
contactName?: string;
contactPhone?: string;
serviceType?: AftersalesServiceType;
issueDescription?: string;
resolutionNote?: string;
technicianId?: number;
}
export interface AftersalesListFilter {
page?: number;
limit?: number;
search?: string;
workOrderStatus?: AftersalesWorkOrderStatus;
serviceType?: AftersalesServiceType;
technicianId?: number;
mine?: boolean;
}
export interface AftersalesListResponse {
data: AftersalesOrder[];
pagination: EmployeeSerialPagination;
}
export interface CustomerConfirmRequest {
action: 'authorize' | 'reject';
signature?: string;
responsibleSignature?: string;
rejectReason?: string;
}