import 'package:freezed_annotation/freezed_annotation.dart';

part 'branch_dto.freezed.dart';
part 'branch_dto.g.dart';

@freezed
class CreateBranchRequest with _$CreateBranchRequest {
  const factory CreateBranchRequest({
    @JsonKey(name: 'branch_name') required String branchName,
    required String address,
    required String phone,
    @JsonKey(name: 'manager_name') String? managerName,
    @JsonKey(name: 'manager_phone') String? managerPhone,
    String? remark,
  }) = _CreateBranchRequest;

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

@freezed
class UpdateBranchRequest with _$UpdateBranchRequest {
  const factory UpdateBranchRequest({
    @JsonKey(name: 'branch_name') String? branchName,
    String? address,
    String? phone,
    @JsonKey(name: 'manager_name') String? managerName,
    @JsonKey(name: 'manager_phone') String? managerPhone,
    String? remark,
  }) = _UpdateBranchRequest;

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

@freezed
class BranchResponse with _$BranchResponse {
  const factory BranchResponse({
    required int id,
    @JsonKey(name: 'company_id') required int companyId,
    @JsonKey(name: 'branch_name') required String branchName,
    required String address,
    required String phone,
    @JsonKey(name: 'manager_name') String? managerName,
    @JsonKey(name: 'manager_phone') String? managerPhone,
    String? remark,
    @JsonKey(name: 'created_at') required DateTime createdAt,
    @JsonKey(name: 'updated_at') required DateTime updatedAt,
    @JsonKey(name: 'address_id') int? addressId,
  }) = _BranchResponse;

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

@freezed
class BranchListDto with _$BranchListDto {
  const factory BranchListDto({
    required int id,
    @JsonKey(name: 'company_id') required int companyId,
    @JsonKey(name: 'branch_name') required String branchName,
    required String address,
    required String phone,
    @JsonKey(name: 'manager_name') String? managerName,
  }) = _BranchListDto;

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