import 'package:rasadyar_core/core.dart';

part 'user_profile_model.freezed.dart';

part 'user_profile_model.g.dart';

@freezed
abstract class UserProfileModel with _$UserProfileModel {
  const factory UserProfileModel({
    required User user,
    required Role role,
    required List<Permission> permissions,
  }) = _UserProfileModel;

  factory UserProfileModel.fromJson(Map<String, dynamic> json) => _$UserProfileModelFromJson(json);
}

@freezed
abstract class User with _$User {
  const factory User({
    required int id,
    required String username,
    required String password,
    required String firstName,
    required String lastName,
    required bool isActive,
    required String mobile,
    required String phone,
    required String nationalCode,
    required DateTime birthdate,
    required String nationality,
    required String ownership,
    required String address,
    required String photo,
    required int province,
    required int city,
    required bool otpStatus,
    required String cityName,
    required String provinceName,
  }) = _User;



  factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
}

@freezed
abstract class Role with _$Role {
  const factory Role({
    required int id,
    required String roleName,
    required String description,
    required RoleType type,
    required List<dynamic> permissions,
  }) = _Role;

  factory Role.fromJson(Map<String, dynamic> json) => _$RoleFromJson(json);
}

@freezed
abstract class RoleType with _$RoleType {
  const factory RoleType({String? key, required String name}) = _RoleType;

  factory RoleType.fromJson(Map<String, dynamic> json) => _$RoleTypeFromJson(json);
}

@freezed
abstract class Permission with _$Permission {
  const factory Permission({required String pageName, required List<String> pageAccess}) =
  _Permission;

  factory Permission.fromJson(Map<String, dynamic> json) => _$PermissionFromJson(json);
}
