import BaseEntity from "./BaseEntity";
import { StringKeyValueEntity } from "./StringKeyValueEntity";

export class PlanEntity extends BaseEntity {
  group_uuid: string = "";
  name: string = "";
  datas: StringKeyValueEntity[] = [];
  timing_cycle: boolean = false;
  time_: string = "09:00:00";
  week_days: number = 0;

  public static copy(dest: PlanEntity, src?: PlanEntity) {
    if (!src) {
      src = new PlanEntity();
    }

    dest.uuid = src.uuid;
    dest.base_note = src.base_note;
    dest.name = src.name;
    dest.group_uuid = src.group_uuid;
    dest.datas = src.datas;
  }
}

export class PlanTreeItemEntity {
  uuid = "";
  parent = "";
  name = "";
  is_group = false;
  children: PlanTreeItemEntity[] = [];
  item_data: PlanEntity | null = null;

  constructor(
    uuid?: string,
    parent?: string,
    name?: string,
    is_group?: boolean,
    item_data?: any,
    children?: PlanTreeItemEntity[]
  ) {
    this.uuid = uuid ?? "";
    this.parent = parent ?? "";
    this.name = name ?? "";
    this.is_group = is_group ?? false;
    this.children = children ?? (Array.isArray(children) ? children : []);
    this.item_data = item_data;
  }
}
