export type Paged<T> = {
  items: T[]
  total: number
  page: number
  pageSize: number
  totalPages: number
  hasNext: boolean
  hasPrev: boolean
}

export const SupplierType = {
  NhaCungCap: 1,
  NhaThauPhu: 2,
  ToDoi: 3,
  DonViDichVu: 4,
  ChuDauTu: 5,
  CaHai: 6,
} as const

export type SupplierType = typeof SupplierType[keyof typeof SupplierType]

export const SupplierTypeLabel: Record<SupplierType, string> = {
  1: 'Nhà cung cấp',
  2: 'Nhà thầu phụ',
  3: 'Tổ đội',
  4: 'Đơn vị dịch vụ',
  5: 'Chủ đầu tư',
  6: 'Cả hai (NCC & Thầu phụ)',
}

export const SupplierStatus = {
  DangHoatDong: 1,
  Blacklist: 2,
  NgungHopTac: 3,
} as const

export type SupplierStatus = typeof SupplierStatus[keyof typeof SupplierStatus]

export const SupplierStatusLabel: Record<SupplierStatus, string> = {
  1: 'Đang hoạt động',
  2: 'Blacklist',
  3: 'Ngừng hợp tác',
}

export type Supplier = {
  id: string
  code: string
  name: string
  type: SupplierType
  taxCode: string | null
  phone: string | null
  email: string | null
  address: string | null
  contactPerson: string | null
  note: string | null
  // Định danh
  packageCategory: string | null
  // Pháp lý & Hợp đồng
  officeAddress: string | null
  mailingAddress: string | null
  fax: string | null
  bankAccount: string | null
  secondaryBankAccount: string | null
  legalRepresentative: string | null
  legalRepTitle: string | null
  authorizationNote: string | null
  linkGuq: string | null
  linkGpkd: string | null
  linkHsnl: string | null
  // Liên hệ
  contactTitle: string | null
  contactPhone: string | null
  mailRecipient: string | null
  referralSource: string | null
  ownerPmh: string | null
  // Tình trạng
  status: SupplierStatus | null
  // Công bố: true = hiển thị ra ngoài (picker NCC), false = nháp/ẩn (S113)
  isPublic: boolean
  createdAt: string
  updatedAt: string | null
}

export type SupplierInput = Omit<Supplier, 'id' | 'createdAt' | 'updatedAt'>

export type Project = {
  id: string
  code: string
  name: string
  startDate: string | null
  endDate: string | null
  managerUserId: string | null
  budgetTotal: number | null
  note: string | null
  year: number | null
  investor: string | null
  location: string | null
  package: string | null
  createdAt: string
  updatedAt: string | null
}

export type ProjectInput = Omit<Project, 'id' | 'createdAt' | 'updatedAt'>

export type Department = {
  id: string
  code: string
  name: string
  parentId: string | null
  managerUserId: string | null
  note: string | null
  createdAt: string
  updatedAt: string | null
}

export type DepartmentInput = Omit<Department, 'id' | 'createdAt' | 'updatedAt'>
