import React from 'react'; import { FormikProps, FormikConfig } from 'formik'; import { DocumentNode } from 'graphql'; import { ApolloError } from 'apollo-server-core'; import { ProductVariant, Product, ProductVariantOption } from '../../types'; interface Comments { [name: string]: string; } interface Options { [name: string]: string; } export interface AddToCartFormikValues { quantity: number; comments: Comments; options?: Options; [otherValues: string]: any; } export interface AddToCartFormikErrors { quantity?: string; comments?: Comments; options?: Options; [otherValues: string]: any; } export interface AddToCartCallbackOptions { mutationId: string; quantity: number; product: Product; selectedVariation: ProductVariant; } export interface AddToCartFormProps { cartQuery?: DocumentNode; cartMutation?: DocumentNode; onAddToCartInit?: (opts: AddToCartCallbackOptions) => void; onAddToCartSuccess?: (opts: AddToCartCallbackOptions) => void; onAddToCartError?: (opts: AddToCartCallbackOptions & { error: Error | ApolloError; }) => void; children: (props: FormikProps) => React.ReactNode; initialValues: { [otherValues: string]: any; }; variant?: ProductVariant; product?: Product; getMissingOptions?(): ProductVariantOption[] | null; commentValidators: { [commentName: string]: ({ name, value }: { name?: string; value: string; }) => string; }; } declare const AddToCartFormik: ({ children, onAddToCartInit, onAddToCartError, onAddToCartSuccess, cartQuery, cartMutation, initialValues, variant, product, commentValidators, getMissingOptions, ...props }: AddToCartFormProps & FormikConfig) => React.JSX.Element; export default AddToCartFormik;