import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
import { License } from './license.entity';

@Entity('webstore_config')
export class WebstoreConfig {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'uuid' })
  license_id: string;

  @Column({ type: 'boolean', default: false })
  is_active: boolean;

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

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

  @Column({ type: 'varchar', default: 'sandbox' })
  paypal_mode: string;

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

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

  @Column({ type: 'varchar', default: 'USD' })
  currency: string;

  @Column({ type: 'timestamptz', default: () => 'NOW()' })
  created_at: Date;

  @ManyToOne(() => License, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'license_id' })
  license: License;
}
