import {
  InventoryLevelTypeName,
  LocationTypeName,
  ProductVariantTypeName
} from '../../models/shopify';
import * as AirtableFields from '../airtable/AirtableFieldDefaultConfigs';
import { InventoryLevelAirtableFields as ilaf } from '../airtable/ShopifyObjectAirtableFields';

import {
  getShopifyObjectAirtableFields
} from './getCreateTableProps';
import { getRecordLinkAirtableField } from './getCreateTablePropsUtil';

const {
  singleLineText,
  datetime,
  checkbox,
  integer,
  multiLineText,
} = AirtableFields;

export const getInventoryLevelAirtableFields:getShopifyObjectAirtableFields<InventoryLevelTypeName> = ({
  airtableTableLinks,
  baseSyncConfig,
}) => {
  const LocationAirtableFields:ilaf = {
    type: InventoryLevelTypeName,
    fields: {
      id: singleLineText,
      available: integer,
      incoming: integer,
      'product.title': singleLineText,
      'productVariant.title': singleLineText,
      'location.name': singleLineText,
      createdAt: datetime,
      updatedAt: datetime,
      productVariant: getRecordLinkAirtableField({
        shopifyObjectType: ProductVariantTypeName,
        airtableTableLinks,
        baseSyncConfig,
      }),
      location: getRecordLinkAirtableField({
        shopifyObjectType: LocationTypeName,
        airtableTableLinks,
        baseSyncConfig,
      }),
      'inventoryItem.id': singleLineText,
      'location.id': singleLineText,
      'location.isActive': checkbox,
      'productVariant.id': singleLineText,
      'productVariant.sku': singleLineText,
      'product.id': singleLineText,
      'product.handle': singleLineText,
      canDeactivate: checkbox,
      deactivationAlert: singleLineText,
      deactivationAlertHtml: multiLineText,
    }
  };

  return LocationAirtableFields;
};
