import React from 'react';
import { FormikProps } from 'formik';
import { Props as ButtonProps } from '../components/Button';
import { Field } from '../components/ListTable';

export interface Action extends ButtonProps {
  name: string;
}

export interface PanelProps {
  item: any;
  mutate: (item: any) => void;
}

export interface ServiceParams {
  route: string;
  name: string;
  tableFields: Field[];
  nameSingular?: string;
  default?: Record<string, any>;
  routes?: Record<string, React.FC>;
  actions?: Action[];
  rowLink?: (item: any) => string;
  Form?: React.FC<FormikProps<any>>;
  Panel?: React.FC<PanelProps>;
}

const ServiceContext = React.createContext<ServiceParams>({
  route: '',
  name: '',
  nameSingular: '',
  tableFields: [],
  default: {},
});

export const ServiceProvider = ServiceContext.Provider;
export default ServiceContext;
