From 865b41114060765308d560181f4996c0aa7a3e74 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Fri, 26 Mar 2021 01:06:44 +0300
Subject: refactor: move Service to lib/

---
 src/lib/ServiceContext.tsx | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 src/lib/ServiceContext.tsx

(limited to 'src/lib/ServiceContext.tsx')

diff --git a/src/lib/ServiceContext.tsx b/src/lib/ServiceContext.tsx
new file mode 100644
index 0000000..93cac4e
--- /dev/null
+++ b/src/lib/ServiceContext.tsx
@@ -0,0 +1,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;
+  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;
-- 
cgit v1.2.3

