import 'package:rasadyar_core/core.dart';

part 'user_local_model.g.dart';

@HiveType(typeId: authUserLocalModelTypeId)
class UserLocalModel extends HiveObject {
  @HiveField(0)
  String? username;

  @HiveField(1)
  String? password;

  @HiveField(2)
  String? token;

  @HiveField(3)
  String? refreshToken;

  @HiveField(5)
  Module? module;

  @HiveField(6)
  String? backend;

  @HiveField(7)
  List<String>? roles;

  UserLocalModel({
    this.username,
    this.password,
    this.token,
    this.refreshToken,
    this.module,
    this.backend,
    this.roles,
  });

  UserLocalModel copyWith({
    String? username,
    String? password,
    String? token,
    String? refreshToken,
    Module? module,
    String? backend,
    List<String>? roles,
  }) {
    return UserLocalModel(
      username: username ?? this.username,
      password: password ?? this.password,
      token: token ?? this.token,
      refreshToken: refreshToken ?? this.refreshToken,
      module: module ?? this.module,
      backend: backend ?? this.backend,
      roles: roles ?? this.roles,
    );
  }

  @override
  String toString() {
    return 'UserLocalModel{username: $username, password: $password, token: $token, refreshToken: $refreshToken, module: $module, backend: $backend, roles: $roles}';
  }
}

@HiveType(typeId: moduleTypeId)
enum Module {
  @HiveField(0)
  liveStocks,
  @HiveField(1)
  inspection,
  @HiveField(2)
  chicken,
}
