import 'package:drift/drift.dart';
import 'package:uuid/uuid.dart';

class Tenants extends Table {
  TextColumn get localId => text().clientDefault(() => const Uuid().v7().toString())();
  TextColumn get serverId => text().nullable()();
  TextColumn get businessCode => text().unique()();
  TextColumn get businessName => text()();
  TextColumn get businessEmail => text().unique().nullable()();
  TextColumn get businessPhone => text().unique().nullable()();
  TextColumn get businessType => text().nullable()() ;
  TextColumn get localLogoPath => text().nullable()();
  TextColumn get serverLogoUrl => text().nullable()();
  TextColumn get subdomain => text().unique().nullable()();
  TextColumn get onlinStoreName => text().nullable()();
  TextColumn get onlineOpenTime => text().nullable()();
  TextColumn get onlineCloseTime => text().nullable()();
  BoolColumn get isCloseService => boolean().withDefault(const Constant(false))();
  IntColumn get preparationTimeMinutes => integer().withDefault(const Constant(0))();
  IntColumn get orderIntervalMinutes => integer().withDefault(const Constant(0))();
  BoolColumn get allowCod => boolean().withDefault(const Constant(false))();
  RealColumn get maxDeliveryRadiusKm => real().withDefault(const Constant(0.0))();
  TextColumn get deliveryFeeType => text().withDefault(const Constant('fixed'))();
  RealColumn get deliveryFlatFee => real().withDefault(const Constant(0.0))();
  RealColumn get deliveryFeePerKm => real().withDefault(const Constant(0.0))();
  RealColumn get deliveryBaseFee => real().withDefault(const Constant(0.0))();
  TextColumn get reviewDisplayType => text().withDefault(const Constant('rating_only'))();
  TextColumn get reviewDisplayPolicy => text().withDefault(const Constant('four_and_five_star_only'))();
  TextColumn get subscriptionLevel => text().withDefault(const Constant('standart'))();
  IntColumn get limitOutlet => integer().withDefault(const Constant(5))();
  DateTimeColumn get subscriptionExpiresAt => dateTime().nullable()();
  TextColumn get syncStatus => text().withDefault(const Constant('dirty'))();
  DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
  DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();

  @override
  // TODO: implement primaryKey
  Set<Column<Object>>? get primaryKey => {localId};
}