import {
    BaseEntity,
    Column,
    Entity,
    OneToMany,
    PrimaryGeneratedColumn,
  } from "typeorm";
  import { Transaction } from "../transaction/transaction";
import { Notification } from "../notification/notification";
  @Entity({ name: "User" })
  export class User extends BaseEntity {
    @PrimaryGeneratedColumn("uuid")
    // @Generated("uuid")
    id: string;

    @Column({ name: "name"})
    name: string;

    @Column({ name: "email"})
    email: string; 
    
    @Column({ name: "password"})
    password: string;

    @Column({ name: "referredBy", nullable: true})
    referredBy: string;
    
    @Column({ name: "referredCode", nullable: true})
    referredCode: string;

    @Column({ name: "isAdmin", default: false})
    isAdmin: boolean;

    @Column({ name: "dob", nullable: true})
    dob: string;

    @Column({ name: "phone", nullable: true})
    phone: string;

    @Column({ name: "accountName", nullable: true})
    accountName: string;

    @Column({ name: "accountNumber", nullable: true})
    accountNumber: string;

    @Column({ name: "bsbNumber", nullable: true})
    bsbNumber: string;

    @Column({ name: "address", nullable: true})
    address: string;

    @Column({ name: "profileImg", nullable: true})
    profileImg: string;

    @Column({ name: "country", nullable: true})
    country: string;

    @Column({ name: "state", nullable: true})
    state: string;

    @Column({ name: "city", nullable: true})
    city: string;

    @Column({ name: "zipCode", nullable: true})
    zipCode: string;

    @Column({ name: "otpHash", nullable: true})
    otpHash: string;

    @Column({ name: "otpExpiry", type: "timestamp", nullable: true})
    otpExpiry: Date;

    @Column({ name: "otpAttempts", default: 0})
    otpAttempts: number;

 @OneToMany(type => Transaction, tr => tr.userId)
    transactions: Transaction[];

    @OneToMany(type => Notification, tr => tr.userId)
    notification: Notification[];
    @Column({ name: "created_at",
    type: "timestamp",
    default: () => "CURRENT_TIMESTAMP", })
    created_at: Date;
    
    @Column({ name: "updated_at",
    type: "timestamp",
    default: () => "CURRENT_TIMESTAMP", })
    updated_at: Date;
  
  }
  