// ignore_for_file: flutter_style_todos

import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'tasks_list.freezed.dart';
part 'tasks_list.g.dart';

@freezed
class IndividualTodo with _$IndividualTodo {
  const factory IndividualTodo({
    required String todo,
    required bool isCompleted,
    required DateTime dueDate,
  }) = _IndividualTodo;
  factory IndividualTodo.fromJson(Map<String, Object?> json) =>
      _$IndividualTodoFromJson(json);
}

@freezed
class TasksItem with _$TasksItem {
  const factory TasksItem({
    required String widgetType,
    required String name,
    required bool isExpanded,
    required List<String> taskList,
    required List<String> completedTaskList,
    required bool isVisible,
    @Default(-1) int id,
  }) = _TasksItem;

  factory TasksItem.fromJson(Map<String, Object?> json) =>
      _$TasksItemFromJson(json);
}

extension JsonWithoutId on TasksItem {
  Map<String, dynamic> toJsonWithoutId() {
    final map = toJson()..remove('id');
    // map['taskList'] = taskList.map((todo) => todo.toJson()).toList();
    //map['completedTaskList'] =
    //   completedTaskList.map((todo) => todo.toJson()).toList();
    return map;
  }
}
/*
extension JsonWithoutID on TODO {
  Map<String, dynamic> toJsonWithoutId() {
    final map = toJson()..remove('id');
    map['taskList'] = taskList.map((todo) => todo.toJson()).toList();
    map['completedTaskList'] =
        completedTaskList.map((todo) => todo.toJson()).toList();
    return map;
  }
}*/
