import { Injectable } from '@angular/core';
import { LOCAL_STORAGE_KEYS } from 'src/assets/constants';
import { IPosConfigRapidInvoicePayload, IPosConfigRapidInvoiceResponse } from '../models';

@Injectable({ providedIn: 'root' })
export class PosConfigRapidInvoiceService {
  get(): IPosConfigRapidInvoiceResponse {
    const defaultPrice = Boolean(
      window.localStorage.getItem(LOCAL_STORAGE_KEYS.POS_CONFIG_RAPID_INVOICE) === 'true'
    );

    this.submit(defaultPrice);
    return defaultPrice;
  }

  submit(data: IPosConfigRapidInvoicePayload) {
    window.localStorage.setItem(LOCAL_STORAGE_KEYS.POS_CONFIG_RAPID_INVOICE, data.toString());
  }
}
