Files
AmirReza Jamali 86ed7bc665 Refactor tender detail models and UI components for improved clarity and functionality
- Updated the `Lot`, `Organization`, and `OrganizationAddress` models to enhance data mapping for tender details.
- Revised the `TenderData` model to include additional fields reflecting the API response structure.
- Improved UI components across desktop, mobile, and tablet views by commenting out unused sections for future use.
- Added new string constants for lot details in the tender information section.
- Enhanced unit tests to cover new model fields and ensure resilience to partial API payloads.
2026-06-05 19:42:09 +03:30

63 lines
2.7 KiB
Dart

// ignore_for_file: invalid_annotation_target
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:tm_app/core/utils/date_utils.dart';
import 'package:tm_app/data/services/model/lot/lot.dart';
import 'package:tm_app/data/services/model/organization/organization.dart';
part 'tender_data.freezed.dart';
part 'tender_data.g.dart';
// Fields mirror the /tenders/details/:id response so the tender-details page
// can show them: notice_type_code, form_type, notice_language_code, issue_date,
// issue_time, lots, official_languages. issue_date/issue_time reuse
// unixTimestampFromJson (epoch seconds, tolerant of ms/string) like the other
// timestamp fields. All fields are nullable to stay resilient to partial API
// payloads.
@freezed
abstract class TenderData with _$TenderData {
const factory TenderData({
required bool? success,
required String? message,
required String? id,
@JsonKey(name: 'tender_id') required String? tenderId,
@JsonKey(name: 'notice_publication_id')
required String? noticePublicationId,
@JsonKey(name: 'notice_type_code') required String? noticeTypeCode,
@JsonKey(name: 'form_type') required String? formType,
@JsonKey(name: 'notice_language_code') required String? noticeLanguageCode,
@JsonKey(name: 'issue_date', fromJson: unixTimestampFromJson)
required int? issueDate,
@JsonKey(name: 'issue_time', fromJson: unixTimestampFromJson)
required int? issueTime,
@JsonKey(name: 'publication_date', fromJson: unixTimestampFromJson)
required int? publicationDate,
required String? title,
required String? description,
@JsonKey(name: 'procurement_type_code')
required String? procurementTypeCode,
@JsonKey(name: 'procedure_code') required String? procedureCode,
@JsonKey(name: 'estimated_value') required int? estimatedValue,
required String? currency,
required String? duration,
@JsonKey(name: 'tender_deadline', fromJson: unixTimestampFromJson)
required int? tenderDeadline,
@JsonKey(name: 'submission_deadline', fromJson: unixTimestampFromJson)
required int? submissionDeadline,
@JsonKey(name: 'application_deadline', fromJson: unixTimestampFromJson)
required int? applicationDeadline,
@JsonKey(name: 'submission_url') required String? submissionUrl,
@JsonKey(name: 'country_code') required String? countryCode,
@JsonKey(name: 'duration_unit') required String? durationUnit,
@JsonKey(name: 'buyer_organization')
required Organization? buyerOrganization,
required List<Lot>? lots,
@JsonKey(name: 'official_languages')
required List<String>? officialLanguages,
required String? status,
}) = _TenderData;
factory TenderData.fromJson(Map<String, Object?> json) =>
_$TenderDataFromJson(json);
}