Files
Kifi/kifi-app/lib/features/projects/domain/project_task.dart

62 lines
1.7 KiB
Dart

class ProjectTask {
final int id;
final int projectId;
final String title;
final String? description;
final String? assigneeName;
final int? assigneeUserId;
final String status;
final bool isBillable;
final double hourlyRate;
final double hoursLogged;
final DateTime? createdAt;
ProjectTask({
required this.id,
required this.projectId,
required this.title,
this.description,
this.assigneeName,
this.assigneeUserId,
this.status = 'TODO',
this.isBillable = false,
this.hourlyRate = 0.0,
this.hoursLogged = 0.0,
this.createdAt,
});
factory ProjectTask.fromJson(Map<String, dynamic> json) {
return ProjectTask(
id: json['id'] as int,
projectId: json['projectId'] as int,
title: json['title'] as String,
description: json['description'] as String?,
assigneeName: json['assigneeName'] as String?,
assigneeUserId: json['assigneeUserId'] as int?,
status: json['status'] as String? ?? 'TODO',
isBillable: json['isBillable'] as bool? ?? false,
hourlyRate: (json['hourlyRate'] as num?)?.toDouble() ?? 0.0,
hoursLogged: (json['hoursLogged'] as num?)?.toDouble() ?? 0.0,
createdAt: json['createdAt'] != null
? DateTime.parse(json['createdAt'])
: null,
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'projectId': projectId,
'title': title,
'description': description,
'assigneeName': assigneeName,
'assigneeUserId': assigneeUserId,
'status': status,
'isBillable': isBillable,
'hourlyRate': hourlyRate,
'hoursLogged': hoursLogged,
'createdAt': createdAt?.toIso8601String(),
};
}
}