export type User = {
  id: string;
  email: string;
  passwordHash?: string;
  fullName: string;
  businessName?: string;
  businessAddress?: string;
  defaultHourlyRate: number;
  taxId?: string;
  currency: string;
  createdAt: string;
};

export type PasskeyCredential = {
  id: string;
  userId: string;
  credentialID: string;
  credentialPublicKey: string;
  counter: number;
  transports?: string[];
};

export type Challenge = {
  id: string;
  userId?: string;
  email?: string;
  challenge: string;
  type: "registration" | "authentication";
  createdAt: string;
};

export type Client = {
  id: string;
  userId: string;
  name: string;
  email?: string;
  address?: string;
  defaultHourlyRate: number;
  accentColor: string;
  archived: boolean;
  createdAt: string;
};

export type TimeEntryStatus = "logged" | "invoiced" | "paid";

export type TimeEntry = {
  id: string;
  userId: string;
  clientId: string;
  description: string;
  startTime: string;
  endTime?: string;
  durationMinutes: number;
  hourlyRate: number;
  billable: boolean;
  status: TimeEntryStatus;
  invoiceId?: string;
  createdAt: string;
};

export type InvoiceLineItem = {
  id: string;
  description: string;
  date: string;
  hours: number;
  rate: number;
  amount: number;
};

export type InvoiceStatus = "draft" | "sent" | "paid";

export type Invoice = {
  id: string;
  userId: string;
  clientId: string;
  invoiceNumber: string;
  issueDate: string;
  dueDate: string;
  status: InvoiceStatus;
  lineItems: InvoiceLineItem[];
  subtotal: number;
  taxRate: number;
  taxAmount: number;
  discount: number;
  total: number;
  paidAmount: number;
  notes?: string;
  createdAt: string;
};

export type DB = {
  users: User[];
  passkeys: PasskeyCredential[];
  challenges: Challenge[];
  clients: Client[];
  timeEntries: TimeEntry[];
  invoices: Invoice[];
};
