import {
	PrimaryColumn,
	Entity,
	Index,
	JoinColumn,
	Column,
	ManyToOne,
} from "typeorm";
import { User } from "./user.js";
import { id } from "../id.js";

@Entity()
export class VerifiedBadgeRequest {
	@PrimaryColumn(id())
	public id: string;

	@Index()
	@Column("timestamp with time zone", {
		comment: "The created date of the VerifiedBadgeRequest.",
	})
	public createdAt: Date;

	@Column("timestamp with time zone", {
		nullable: true,
	})
	public resolvedAt: Date | null;

	@Index()
	@Column(id())
	public userId: User["id"];

	@ManyToOne((type) => User, {
		onDelete: "CASCADE",
	})
	@JoinColumn()
	public user: User | null;

	@Column({
		...id(),
		nullable: true,
	})
	public resolverId: User["id"] | null;

	@ManyToOne((type) => User, {
		onDelete: "SET NULL",
	})
	@JoinColumn()
	public resolver: User | null;

	@Index()
	@Column("varchar", {
		length: 16,
		default: "pending",
	})
	public status: "pending" | "approved" | "rejected";

	@Column("varchar", {
		length: 2048,
		default: "",
	})
	public comment: string;
}
