import { Entity, Column } from 'typeorm';
import { BaseEntity } from '@genex/common';

export enum DisputeType {
  BUYER_CLAIM = 'buyer_claim',
  SELLER_CLAIM = 'seller_claim',
  REFUND_REQUEST = 'refund_request',
}

export enum DisputeStatus {
  PENDING = 'pending',
  PROCESSING = 'processing',
  RESOLVED = 'resolved',
  REJECTED = 'rejected',
}

@Entity('disputes')
export class Dispute extends BaseEntity {
  @Column({ name: 'order_id', type: 'uuid' })
  orderId: string;

  @Column({ name: 'plaintiff_id', type: 'uuid' })
  plaintiffId: string;

  @Column({ name: 'defendant_id', type: 'uuid', nullable: true })
  defendantId: string;

  @Column({ type: 'varchar', length: 30 })
  type: DisputeType;

  @Column({ type: 'varchar', length: 20, default: DisputeStatus.PENDING })
  status: DisputeStatus;

  @Column({ type: 'decimal', precision: 18, scale: 2 })
  amount: string;

  @Column({ type: 'text', nullable: true })
  description: string;

  @Column({ type: 'text', nullable: true })
  resolution: string;

  @Column({ name: 'resolved_at', type: 'timestamptz', nullable: true })
  resolvedAt: Date;
}
