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

@Entity('franchises')
export class Franchises {
  @PrimaryGeneratedColumn({ type: 'int', name: 'id' })
  id: number;

  @Column('int', { name: 'user_id', nullable: false })
  userId: number;

  @Column('varchar', { length: 255, nullable: false, name: 'franchise_name' })
  franchiseName: string;

  @Column('varchar', { length: 255, nullable: true, name: 'company_name' })
  companyName: string | null;

  @Column('varchar', { length: 255, nullable: false })
  email: string;

  @Column('varchar', { length: 20, nullable: true, name: 'contact_no' })
  contactNo: string | null;

  @Column('text', { nullable: true })
  address: string | null;

  @Column('int', { nullable: true, name: 'country_id' })
  countryId: number | null;

  @Column('int', { nullable: true, name: 'state_id' })
  stateId: number | null;

  @Column('int', { nullable: true, name: 'city_id' })
  cityId: number | null;

  @Column('varchar', { length: 10, nullable: true, name: 'postal_code' })
  postal_code: string | null;

  @Column('int', { nullable: true, name: 'area_id' })
  areaId: number | null;

  @Column('varchar', { length: 50, nullable: true, name: 'gst_no' })
  gstNo: string | null;

  @Column('longtext', { nullable: true, name: 'service_area' })
  serviceArea: string | null;

  @Column('enum', {
    enum: ['active', 'inactive'],
    default: 'active',
    nullable: false,
  })
  status: 'active' | 'inactive';

  @CreateDateColumn({ name: 'created_at', type: 'timestamp' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at', type: 'timestamp' })
  updatedAt: Date;
}
