// Import and re-export shared entity types
import type {
  User,
  Product,
  Order,
  Stocktaking,
  Suppliers,
  StockAlerts,
  ApiResponse,
  PaginatedResponse,
  ErrorResponse,
} from "@shared/types";

export type {
  User,
  Product,
  Order,
  Stocktaking,
  Suppliers,
  StockAlerts,
  ApiResponse,
  PaginatedResponse,
  ErrorResponse,
};

// Auto-generated types (from Model Contract)

export interface CreateUserInput {
  username: string;
  passwordHash: string;
  nickname?: string;
  role?: string;
  phone?: string;
  avatarUrl?: string;
}

export interface CreateProductInput {
  userId: string;
  title: string;
  description?: string;
  price?: number;
  stock?: number;
  images?: Record<string, unknown>;
}

export interface CreateOrderInput {
  userId: string;
  status?: string;
  totalAmount?: number;
  addressId?: string;
}

export interface CreateStocktakingInput {
  userId?: string;
  warehouse?: string;
  productName?: string;
  expectedQty?: number;
  actualQty?: number;
  diff?: number;
}

export interface CreateSuppliersInput {
  userId?: string;
  name: string;
  contact?: string;
  phone?: string;
  email?: string;
  address?: string;
}

export interface CreateStockAlertsInput {
  userId?: string;
  productName: string;
  currentQty?: number;
  threshold?: number;
}

export interface UpdateUserInput {
  username?: string;
  passwordHash?: string;
  nickname?: string;
  role?: string;
  phone?: string;
  avatarUrl?: string;
}

export interface UpdateProductInput {
  userId?: string;
  title?: string;
  description?: string;
  price?: number;
  stock?: number;
  images?: Record<string, unknown>;
}

export interface UpdateOrderInput {
  userId?: string;
  status?: string;
  totalAmount?: number;
  addressId?: string;
}

export interface UpdateStocktakingInput {
  userId?: string;
  warehouse?: string;
  productName?: string;
  expectedQty?: number;
  actualQty?: number;
  diff?: number;
}

export interface UpdateSuppliersInput {
  userId?: string;
  name?: string;
  contact?: string;
  phone?: string;
  email?: string;
  address?: string;
}

export interface UpdateStockAlertsInput {
  userId?: string;
  productName?: string;
  currentQty?: number;
  threshold?: number;
}

// ─── Auth ───────────────────────────────────────────
export interface LoginInput {
  username: string;
  password: string;
}

export interface RegisterInput {
  username: string;
  password: string;
  nickname?: string;
}

export interface AuthResponse {
  token: string;
  user: User;
}

// ─── API ────────────────────────────────────────────
// ─── JWT ────────────────────────────────────────────
export interface JwtPayload {
  userId: string;
  username: string;
  role: string;
  iat?: number;
  exp?: number;
}
