import { IsOptional } from "class-validator";
import { Column, CreateDateColumn, Entity, JoinTable, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
import { User } from "../../users/entities/user.entity";

export enum FriendshipStatus {
	REQUESTED = 'R',
	ACCEPTED = 'A',
	DECLINED = 'D',
	BLOCKED = 'B',
}

@Entity('friendships')
export class Friendship {
	@PrimaryGeneratedColumn()
	id: number;

	@CreateDateColumn()
	date : Date;

	@ManyToOne(type => User, user => user.username)
	sender: User;

	@ManyToOne(type => User, user => user.username)
	receiver: User;

	@Column()
	senderUsername : string;

	@Column()
	receiverUsername : string;

	@Column({ type: 'enum', enum: FriendshipStatus, default: FriendshipStatus.REQUESTED})
	status: FriendshipStatus;
}
