import 'package:pshared/models/describable.dart';
import 'package:pshared/models/permissions/bound.dart';
import 'package:pshared/models/permissions/bound/describable.dart';
import 'package:pshared/models/storable.dart';


class Organization implements PermissionBoundStorableDescribable {
  final Storable storable;
  final PermissionBound permissionBound;
  final Describable describable;

  @override
  String get id => storable.id;
  @override
  DateTime get createdAt => storable.createdAt;
  @override
  DateTime get updatedAt => storable.updatedAt;
  @override
  String get organizationRef => permissionBound.organizationRef;
  @override
  String get permissionRef => permissionBound.permissionRef;
  @override
  String get name => describable.name;
  @override
  String? get description => describable.description;

  final String timeZone;
  final String? logoUrl;
  final String tenantRef;

  const Organization({
    required this.storable,
    required this.describable,
    required this.timeZone,
    required this.permissionBound,
    required this.tenantRef,
    this.logoUrl,
  });


  Organization copyWith({
    Describable? describable,
    String? timeZone,
    String? Function()? logoUrl,
  }) => Organization(
    storable: storable, // Same Storable, same id
    describable: describableCopyWithOther(this.describable, describable),
    timeZone: timeZone ?? this.timeZone,
    logoUrl: logoUrl != null ? logoUrl() : this.logoUrl,
    permissionBound: permissionBound,
    tenantRef: tenantRef,
  );
}
