// dashboard_tasks_model.dart
class DashboardTasks {
  final bool success;
  final String message;
  final DashboardTasksData? data;
  final dynamic errors;
  final int statusCode;
  final DateTime timestamp;

  DashboardTasks({
    required this.success,
    required this.message,
    required this.data,
    this.errors,
    required this.statusCode,
    required this.timestamp,
  });

  factory DashboardTasks.fromJson(Map<String, dynamic> json) {
    return DashboardTasks(
      success: json['success'] ?? false,
      message: json['message'] ?? '',
      data: json['data'] != null ? DashboardTasksData.fromJson(json['data']) : null,
      errors: json['errors'],
      statusCode: json['statusCode'] ?? 0,
      timestamp: DateTime.parse(json['timestamp']),
    );
  }
}

class DashboardTasksData {
  final int totalTasks;
  final int completedTasks;

  DashboardTasksData({
    required this.totalTasks,
    required this.completedTasks,
  });

  factory DashboardTasksData.fromJson(Map<String, dynamic> json) {
    return DashboardTasksData(
      totalTasks: json['totalTasks'] ?? 0,
      completedTasks: json['completedTasks'] ?? 0,
    );
  }
}
