summaryrefslogtreecommitdiff
path: root/src/containers/Service/ServiceContext.tsx
blob: 0cccc939a47310c0ffed5de83b5455754311e8f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
  nameSingular?: string;
  tableFields: Field[];
  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;