import {
  Column, CreateDateColumn, DeleteDateColumn, Entity,
  PrimaryGeneratedColumn, UpdateDateColumn,
} from 'typeorm';

@Entity('crm_leads')
export class CrmLead {
  @PrimaryGeneratedColumn('uuid') id: string;

  @Column({ type: 'varchar', length: 200 }) name: string;
  @Column({ type: 'varchar', length: 200, nullable: true }) nameNe: string | null;
  @Column({ type: 'varchar', length: 20, nullable: true }) phone: string | null;
  @Column({ type: 'varchar', length: 100, nullable: true }) email: string | null;
  @Column({ type: 'text', nullable: true }) address: string | null;

  @Column({ type: 'varchar', length: 30, default: 'walk_in' })
  source: 'walk_in' | 'referral' | 'phone_call' | 'social_media' | 'advertisement' | 'other';

  @Column({ type: 'varchar', length: 20, default: 'new' })
  status: 'new' | 'contacted' | 'interested' | 'follow_up' | 'converted' | 'lost';

  @Column({ type: 'varchar', length: 30, nullable: true })
  interestedIn: 'savings' | 'loan' | 'both' | 'membership' | null;

  @Column({ type: 'decimal', precision: 15, scale: 2, nullable: true })
  estimatedAmount: number | null;

  @Column({ type: 'date', nullable: true }) followUpDate: string | null;

  @Column({ type: 'varchar', nullable: true }) assignedToId: string | null;
  @Column({ type: 'varchar', length: 200, nullable: true }) assignedToName: string | null;
  @Column({ type: 'varchar', nullable: true }) officeId: string | null;
  @Column({ type: 'varchar', nullable: true }) referredByMemberId: string | null;
  @Column({ type: 'varchar', length: 200, nullable: true }) referredByName: string | null;

  @Column({ type: 'text', nullable: true }) remarks: string | null;
  @Column({ type: 'varchar', nullable: true }) convertedMemberId: string | null;
  @Column({ type: 'date', nullable: true }) convertedDate: string | null;

  @Column({ type: 'varchar', nullable: true }) createdById: string | null;
  @Column({ type: 'varchar', length: 200, nullable: true }) createdByName: string | null;

  @CreateDateColumn() createdAt: Date;
  @UpdateDateColumn() updatedAt: Date;
  @DeleteDateColumn() deletedAt: Date | null;
}
