editable property added to deck short dto

This commit is contained in:
magdo committed 2025-10-26 21:27:00 +01:00
1 parent b75d27c7c8
commit fe8d5a53a5
4 files changed
+17 -5

No files matched your search

@@ -1,6 +1,7 @@
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm';
import { OrganizationAggregate } from '../Organization/OrganizationAggregate';
import { UserAggregate } from '../User/UserAggregate';
import { logError } from '../../Application/Services/Logger';
export enum Type {
LUCK = 0,
@@ -86,4 +87,11 @@ export class DeckAggregate {
@ManyToOne(() => UserAggregate, { eager: false })
@JoinColumn({ name: 'user_id' })
user!: UserAggregate | null;
isEditable() {
// A deck is editable if the user is the creator
return (userId: string) => {
return this.user?.id.toString() === userId;
};
}
}