import { observable, makeObservable } from 'mobx';
import { IAutoRefill, IAutoRefillPayment, IRefill } from 'typings';

export default class AutoRefill implements IAutoRefill {
  constructor(state: IAutoRefill) {
    this.id = state.id;
    this.refillId = state.refillId;
    this.triggerType = state.triggerType;
    this.type = state.type;
    this.paymentMethod = state.paymentMethod;
    this.nextRefill = state.nextRefill && new Date(state.nextRefill);
    this.info = state.info;

    makeObservable(this, {
      id: observable,
      refillId: observable,
      triggerType: observable,
      type: observable,
      paymentMethod: observable,
      nextRefill: observable,
      info: observable,
    });
  }

  id: number;

  refillId: string;

  triggerType: string;

  type: number;

  paymentMethod: IAutoRefillPayment;

  nextRefill?: Date;

  info: IRefill;
}
