import {
  Order
} from '../../../models';
import {
  CheckboxField,
  DatetimeField,
  FloatField,
  IntegerField,
  MultiLineTextField,
  MultipleSelectsField,
  SingleLineTextField,
  SingleSelectField,
  UrlField
} from '../AirtableFields';

import {
  ShopifyObjectAirtableFields
} from './ShopifyObjectAirtableFields';

export const OrderCurrencyFields = [
  'cartDiscountAmount',
  'currentCartDiscountAmount',
  'currentSubtotalPrice',
  'currentTotalDiscounts',
  'currentTotalDuties',
  'currentTotalPrice',
  'currentTotalTax',
  'netPayment',
  'originalTotalDuties',
  'originalTotalPrice',
  'refundDiscrepancy',
  'subtotalPrice',
  'totalCapturable',
  'totalDiscounts',
  'totalOutstanding',
  'totalPrice',
  'totalReceived',
  'totalRefunded',
  'totalRefundedShipping',
  'totalShippingPrice',
  'totalTax',
  'totalTipReceived'
] as const;

export const OrderDatetimeFieldNames = [
  'cancelledAt',
  'closedAt',
  'createdAt',
  'processedAt',
  'updatedAt',
] as const;
export type OrderDatetimeFieldName = typeof OrderDatetimeFieldNames[number];

export const OrderSingleSelectFieldNames = [
  'cancelReason',
  'currencyCode',
  'displayFinancialStatus',
  'displayFulfillmentStatus',
  'presentmentCurrencyCode',
  'riskLevel',
] as const;
export type OrderSingleSelectFieldNames = typeof OrderSingleSelectFieldNames[number];

export const OrderCheckboxFieldNames = [
  'canMarkAsPaid',
  'canNotifyCustomer',
  'capturable',
  'closed',
  'confirmed',
  'customerAcceptsMarketing',
  'edited',
  'fulfillable',
  'fullyPaid',
  'hasTimelineComment',
  'merchantEditable',
  'refundable',
  'requiresShipping',
  'restockable',
  'taxesIncluded',
  'test',
  'unpaid',
] as const;
export const OrderSingleLineTextFieldNames = [
  'id',
  'legacyResourceId',
  'name',
  'note',
  'phone',
  'email',
  'customerLocale',
  'discountCode',
  'clientIp',
  'physicalLocationId',
  'publicationId',

  'billingAddressId',
  'billingAddressPhone',
  'billingAddressAddress1',
  'billingAddressAddress2',
  'billingAddressCity',
  'billingAddressCompany',
  'billingAddressCountry',
  'billingAddressCountryCodeV2',
  'billingAddressFirstName',
  'billingAddressLastName',

  'billingAddressProvince',
  'billingAddressProvinceCode',
  'billingAddressZip',

  'displayAddressId',
  'displayAddressPhone',
  'displayAddressAddress1',
  'displayAddressAddress2',
  'displayAddressCity',
  'displayAddressCompany',
  'displayAddressCountry',
  'displayAddressCountryCodeV2',
  'displayAddressFirstName',
  'displayAddressLastName',

  'displayAddressProvince',
  'displayAddressProvinceCode',
  'displayAddressZip',

  'shippingAddressId',
  'shippingAddressPhone',
  'shippingAddressAddress1',
  'shippingAddressAddress2',
  'shippingAddressCity',
  'shippingAddressCompany',
  'shippingAddressCountry',
  'shippingAddressCountryCodeV2',
  'shippingAddressFirstName',
  'shippingAddressLastName',

  'shippingAddressProvince',
  'shippingAddressProvinceCode',
  'shippingAddressZip',
] as const;

export const OrderJsonFieldNames = [
  'lineItems_json',
  'currentTaxLines_json',
  'customAttributes_json',
  'customer_json',
  'customerJourneySummary_json',
  'disputes_json',
  'fulfillments_json',
  'paymentCollectionDetails_json',
  'risks_json',
  'shippingLine_json',
  'taxLines_json',
  'transactions_json',
] as const;
export type OrderJsonFieldNames = typeof OrderJsonFieldNames[number];

export const OrderIntegerFieldNames = [
  'currentSubtotalLineItemsQuantity',
  'subtotalLineItemsQuantity',
] as const;
export type OrderIntegerFieldNames = typeof OrderIntegerFieldNames[number];

export type OrderSingleLineTextFieldNames = typeof OrderSingleLineTextFieldNames[number];
export type OrderCheckboxFieldNames = typeof OrderCheckboxFieldNames[number];

export type OrderCurrencyFields = typeof OrderCurrencyFields[number];

export const OrderMultipleSelectFieldNames = [
  'merchantEditableErrors',
  'paymentGatewayNames',
  'tags',
] as const;
export type OrderMultipleSelectFieldNames = typeof OrderMultipleSelectFieldNames[number];

export const OrderFloatFieldNames = [
  'currentTotalWeight',
  'totalWeight',

  'billingAddressLatitude',
  'billingAddressLongitude',

  'displayAddressLatitude',
  'displayAddressLongitude',

  'shippingAddressLatitude',
  'shippingAddressLongitude',
] as const;
export type OrderFloatFieldNames = typeof OrderFloatFieldNames[number];
export const OrderUrlFieldNames = [] as const;
export type OrderUrlFieldNames = typeof OrderUrlFieldNames[number];

export interface OrderAirtableFields extends ShopifyObjectAirtableFields<Order> {
  type: Order['type'];
  fields: {
    [K in OrderCurrencyFields]: FloatField;
  } & {
    [K in OrderDatetimeFieldName]: DatetimeField;
  } & {
    [K in OrderSingleSelectFieldNames]: SingleSelectField;
  } & {
    [K in OrderCheckboxFieldNames]: CheckboxField;
  } & {
    [K in OrderIntegerFieldNames]: IntegerField;
  } & {
    [K in OrderSingleLineTextFieldNames]: SingleLineTextField;
  } & {
    [K in OrderJsonFieldNames]: MultiLineTextField;
  } & {
    [K in OrderMultipleSelectFieldNames]: MultipleSelectsField;
  } & {
    [K in OrderFloatFieldNames]: FloatField;
  } & {
    [K in OrderUrlFieldNames]: UrlField;
  };
  // &
  // AddressFields<BillingAddressProps> &
  // AddressFields<DisplayAddressProps> &
  // AddressFields<ShippingAddressProps>;
};
