- Implemented ProjectDetailsResponse and ProjectData models for handling project details. - Created ProjectsResponse and ProjectsPageData models for listing infrastructure projects. - Added InfraProjectScreen and InfraProjectDetailsScreen for displaying project information. - Integrated search functionality in InfraProjectScreen to filter projects. - Updated DailyTaskPlanningScreen and DailyProgressReportScreen to accept projectId as a parameter. - Removed unnecessary dependencies and cleaned up code for better maintainability.
223 lines
5.2 KiB
Dart
223 lines
5.2 KiB
Dart
class ProjectDetailsResponse {
|
|
final bool? success;
|
|
final String? message;
|
|
final ProjectData? data;
|
|
final dynamic errors;
|
|
final int? statusCode;
|
|
final DateTime? timestamp;
|
|
|
|
ProjectDetailsResponse({
|
|
this.success,
|
|
this.message,
|
|
this.data,
|
|
this.errors,
|
|
this.statusCode,
|
|
this.timestamp,
|
|
});
|
|
|
|
factory ProjectDetailsResponse.fromJson(Map<String, dynamic> json) {
|
|
return ProjectDetailsResponse(
|
|
success: json['success'] as bool?,
|
|
message: json['message'] as String?,
|
|
data: json['data'] != null ? ProjectData.fromJson(json['data']) : null,
|
|
errors: json['errors'],
|
|
statusCode: json['statusCode'] as int?,
|
|
timestamp: json['timestamp'] != null
|
|
? DateTime.tryParse(json['timestamp'])
|
|
: null,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'success': success,
|
|
'message': message,
|
|
'data': data?.toJson(),
|
|
'errors': errors,
|
|
'statusCode': statusCode,
|
|
'timestamp': timestamp?.toIso8601String(),
|
|
};
|
|
}
|
|
}
|
|
|
|
class ProjectData {
|
|
final String? id;
|
|
final String? name;
|
|
final String? shortName;
|
|
final String? projectAddress;
|
|
final String? contactPerson;
|
|
final DateTime? startDate;
|
|
final DateTime? endDate;
|
|
final ProjectStatus? projectStatus;
|
|
final Promoter? promoter;
|
|
final Pmc? pmc;
|
|
|
|
ProjectData({
|
|
this.id,
|
|
this.name,
|
|
this.shortName,
|
|
this.projectAddress,
|
|
this.contactPerson,
|
|
this.startDate,
|
|
this.endDate,
|
|
this.projectStatus,
|
|
this.promoter,
|
|
this.pmc,
|
|
});
|
|
|
|
factory ProjectData.fromJson(Map<String, dynamic> json) {
|
|
return ProjectData(
|
|
id: json['id'] as String?,
|
|
name: json['name'] as String?,
|
|
shortName: json['shortName'] as String?,
|
|
projectAddress: json['projectAddress'] as String?,
|
|
contactPerson: json['contactPerson'] as String?,
|
|
startDate: json['startDate'] != null
|
|
? DateTime.tryParse(json['startDate'])
|
|
: null,
|
|
endDate: json['endDate'] != null
|
|
? DateTime.tryParse(json['endDate'])
|
|
: null,
|
|
projectStatus: json['projectStatus'] != null
|
|
? ProjectStatus.fromJson(json['projectStatus'])
|
|
: null,
|
|
promoter: json['promoter'] != null
|
|
? Promoter.fromJson(json['promoter'])
|
|
: null,
|
|
pmc: json['pmc'] != null ? Pmc.fromJson(json['pmc']) : null,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'name': name,
|
|
'shortName': shortName,
|
|
'projectAddress': projectAddress,
|
|
'contactPerson': contactPerson,
|
|
'startDate': startDate?.toIso8601String(),
|
|
'endDate': endDate?.toIso8601String(),
|
|
'projectStatus': projectStatus?.toJson(),
|
|
'promoter': promoter?.toJson(),
|
|
'pmc': pmc?.toJson(),
|
|
};
|
|
}
|
|
}
|
|
|
|
class ProjectStatus {
|
|
final String? id;
|
|
final String? status;
|
|
|
|
ProjectStatus({this.id, this.status});
|
|
|
|
factory ProjectStatus.fromJson(Map<String, dynamic> json) {
|
|
return ProjectStatus(
|
|
id: json['id'] as String?,
|
|
status: json['status'] as String?,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'status': status,
|
|
};
|
|
}
|
|
}
|
|
|
|
class Promoter {
|
|
final String? id;
|
|
final String? name;
|
|
final String? email;
|
|
final String? contactPerson;
|
|
final String? address;
|
|
final String? gstNumber;
|
|
final String? contactNumber;
|
|
final int? sprid;
|
|
|
|
Promoter({
|
|
this.id,
|
|
this.name,
|
|
this.email,
|
|
this.contactPerson,
|
|
this.address,
|
|
this.gstNumber,
|
|
this.contactNumber,
|
|
this.sprid,
|
|
});
|
|
|
|
factory Promoter.fromJson(Map<String, dynamic> json) {
|
|
return Promoter(
|
|
id: json['id'] as String?,
|
|
name: json['name'] as String?,
|
|
email: json['email'] as String?,
|
|
contactPerson: json['contactPerson'] as String?,
|
|
address: json['address'] as String?,
|
|
gstNumber: json['gstNumber'] as String?,
|
|
contactNumber: json['contactNumber'] as String?,
|
|
sprid: json['sprid'] as int?,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'name': name,
|
|
'email': email,
|
|
'contactPerson': contactPerson,
|
|
'address': address,
|
|
'gstNumber': gstNumber,
|
|
'contactNumber': contactNumber,
|
|
'sprid': sprid,
|
|
};
|
|
}
|
|
}
|
|
|
|
class Pmc {
|
|
final String? id;
|
|
final String? name;
|
|
final String? email;
|
|
final String? contactPerson;
|
|
final String? address;
|
|
final String? gstNumber;
|
|
final String? contactNumber;
|
|
final int? sprid;
|
|
|
|
Pmc({
|
|
this.id,
|
|
this.name,
|
|
this.email,
|
|
this.contactPerson,
|
|
this.address,
|
|
this.gstNumber,
|
|
this.contactNumber,
|
|
this.sprid,
|
|
});
|
|
|
|
factory Pmc.fromJson(Map<String, dynamic> json) {
|
|
return Pmc(
|
|
id: json['id'] as String?,
|
|
name: json['name'] as String?,
|
|
email: json['email'] as String?,
|
|
contactPerson: json['contactPerson'] as String?,
|
|
address: json['address'] as String?,
|
|
gstNumber: json['gstNumber'] as String?,
|
|
contactNumber: json['contactNumber'] as String?,
|
|
sprid: json['sprid'] as int?,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'name': name,
|
|
'email': email,
|
|
'contactPerson': contactPerson,
|
|
'address': address,
|
|
'gstNumber': gstNumber,
|
|
'contactNumber': contactNumber,
|
|
'sprid': sprid,
|
|
};
|
|
}
|
|
}
|