/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable no-underscore-dangle */
import Gantt from 'frappe-gantt';
import { GanttTask } from './types.d';

export default class Task<T extends object> implements GanttTask<T> {
  id: Gantt.Task['id'];

  name: Gantt.Task['name'];

  start: Gantt.Task['start'];

  end: Gantt.Task['end'];

  _progress: Gantt.Task['progress'];

  _dependencies: Gantt.Task['dependencies'];

  custom_class: Gantt.Task['custom_class'];

  source: T;

  constructor(options = {}) {
    this._dependencies = '';
    this.id = '';
    this.name = '';
    this.start = '';
    this.end = '';
    this._progress = 0.52;
    this.source = {} as T;
    Object.assign(this, options);
  }

  get progress(): Gantt.Task['progress'] {
    return this._progress || 0.52;
  }

  set progress(value: Gantt.Task['progress']) {
    this._progress = value || 0.52;
  }

  setDependencies(value: string): void {
    this._dependencies = value;
  }

  set dependencies(value: string) {
    this._dependencies = value;
  }

  get dependencies(): Gantt.Task['dependencies'] {
    return this._dependencies;
  }
}
