import { DealerStatus } from "@/contexts/sales/domain";
import {
  AggregateRoot,
  CurrencyData,
  IDomainError,
  Language,
  Name,
  Note,
  Percentage,
  Result,
  UniqueID,
} from "@shared/contexts";
import { ProfileLogotype } from "./ProfileLogotype";

export interface IProfileProps {
  name: Name;
  language: Language;
  status: DealerStatus;
  currency: CurrencyData;

  contactInformation: Note;
  defaultPaymentMethod: Note;
  defaultNotes: Note;
  defaultLegalTerms: Note;
  defaultQuoteValidity: Note;
  defaultTax: Percentage;

  logo: ProfileLogotype;
}

export interface IProfile {
  id: UniqueID;
  name: Name;
  language: Language;
  status: DealerStatus;
  currency: CurrencyData;

  contactInformation: Note;
  defaultPaymentMethod: Note;
  defaultNotes: Note;
  defaultLegalTerms: Note;

  defaultQuoteValidity: Note;
  defaultTax: Percentage;

  logo: ProfileLogotype;
}

export class Profile extends AggregateRoot<IProfileProps> implements IProfile {
  public static create(props: IProfileProps, id?: UniqueID): Result<Profile, IDomainError> {
    const profile = new Profile(props, id);
    return Result.ok<Profile>(profile);
  }

  get name(): Name {
    return this.props.name;
  }

  get language(): Language {
    return this.props.language;
  }

  get status(): DealerStatus {
    return this.props.status;
  }

  get currency(): CurrencyData {
    return this.props.currency;
  }

  get contactInformation(): Note {
    return this.props.contactInformation;
  }

  set contactInformation(newNote: Note) {
    this.props.contactInformation = newNote;
  }

  get defaultPaymentMethod(): Note {
    return this.props.defaultPaymentMethod;
  }

  set defaultPaymentMethod(newPaymentMethod: Note) {
    this.props.defaultPaymentMethod = newPaymentMethod;
  }

  get defaultNotes(): Note {
    return this.props.defaultNotes;
  }

  set defaultNotes(newDefaultNotes: Note) {
    this.props.defaultNotes = newDefaultNotes;
  }

  get defaultLegalTerms(): Note {
    return this.props.defaultLegalTerms;
  }

  set defaultLegalTerms(newDefaultLegalTerms: Note) {
    this.props.defaultLegalTerms = newDefaultLegalTerms;
  }

  get defaultQuoteValidity(): Note {
    return this.props.defaultQuoteValidity;
  }

  set defaultQuoteValidity(newDefaultQuoteValidity: Note) {
    this.props.defaultQuoteValidity = newDefaultQuoteValidity;
  }

  get defaultTax(): Percentage {
    return this.props.defaultTax;
  }

  set defaultTax(newDefaultTax: Percentage) {
    this.props.defaultTax = newDefaultTax;
  }

  get logo(): ProfileLogotype {
    return this.props.logo;
  }

  set logo(newLogo: ProfileLogotype) {
    this.props.logo = newLogo;
  }
}
