import { FormResponseAttributesFormCategory } from '@spiffy-ai/commerce-api-client';
import { AcceptableFormFieldType } from './response';

// Boundary types, these are generic objects not defined in the SDK but can be returned by the API
// as properties of the response attributes
export interface ApiReviewRichInformation {
  cons?: string[];
  pros?: string[];
  review_date?: string;
  reviewer_title?: string;
  product_familiarity?: 'IVE_TESTED_IT' | 'I_OWN_IT';
}

export interface ApiTextResponseAttributes {
  content: string;
}

export interface ApiSearchResponseAttributes {
  search_term: string;
  selected_filters?: string[];
  filters?: {
    [key: string]: string[];
  };
}

export interface ApiSearchResponseProductAttributes {
  response_id?: string;
}

export interface ApiProductSearchFilterResponseAttributes {
  filter_name: string;
}

export interface ApiReviewResponseAttributes {
  id?: string;
  product_id?: string;
  title?: string;
  reviewer?: string;
  review?: string;
  stars?: number;
  rich_information?: ApiReviewRichInformation;

  onClick?: () => void;
}

export interface ApiPageResponseAttributes {
  id?: string;
  title?: string;
  description?: string;
  url?: string;
}

export interface ApiFormResponseSchemaAttributes {
  properties: {
    [key: string]: {
      format?: 'email';
      type: AcceptableFormFieldType;
      title: string;
    };
  };
  required: Array<keyof ApiFormResponseSchemaAttributes['properties']>;
}

export interface ApiFormResponseAttributes {
  form_category?: FormResponseAttributesFormCategory;
  schema: ApiFormResponseSchemaAttributes;
}
