import 'package:json_annotation/json_annotation.dart';

import '../global/utils.dart';

part 'user.g.dart';

@JsonSerializable()
class User {
  const User({
    this.id,
    required this.name,
    required this.familyId,
    required this.budgetId,
    this.email,
    this.username,
    this.createdAt,
    this.updatedAt,
    this.lastActivityAt,
    this.hide = false,
  });

  final int? id;
  final int familyId, budgetId;
  final String name;
  final String? username, email;

  @JsonKey(fromJson: boolFromJson, toJson: boolToJson)
  final bool hide;
  @JsonKey(fromJson: dateFromJson, toJson: dateToJson)
  final DateTime? createdAt;
  @JsonKey(fromJson: dateFromJson, toJson: dateToJson)
  final DateTime? updatedAt;
  @JsonKey(fromJson: dateFromJson, toJson: dateToJson)
  final DateTime? lastActivityAt;

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

  Map<String, dynamic> toJson() => _$UserToJson(this);
}
