From 756a8e7de9df0a6886d523ba91a13deb98abb2a8 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Thu, 14 Mar 2024 12:00:46 +0100
Subject: [PATCH] WIP: make deployable

---
 pages/_app.tsx                                | 24 ++++++++---------
 pages/api/auth/[...nextauth].ts               | 20 +++++++-------
 src/api/api.ts                                |  1 -
 src/api/base.ts                               |  1 -
 src/api/common.ts                             |  1 -
 src/api/configuration.ts                      |  1 -
 src/api/index.ts                              |  1 -
 src/components/fdos/create.tsx                | 27 +++++++++----------
 src/components/profiles/index.ts              |  4 +--
 src/components/profiles/list.tsx              |  2 +-
 src/components/profiles/show.tsx              |  8 +++---
 src/components/repositories/list.tsx          |  2 +-
 .../profiles => interfaces}/IProfile.tsx      |  2 +-
 src/interfaces/IRepository.tsx                |  2 +-
 src/interfaces/index.d.ts                     |  2 +-
 src/providers/dataProvider.tsx                |  4 +--
 16 files changed, 49 insertions(+), 53 deletions(-)
 rename src/{components/profiles => interfaces}/IProfile.tsx (58%)

diff --git a/pages/_app.tsx b/pages/_app.tsx
index bce8840..b52c4ee 100644
--- a/pages/_app.tsx
+++ b/pages/_app.tsx
@@ -98,7 +98,7 @@ const App = (props: React.PropsWithChildren) => {
         return {
           name: user.name,
           avatar: user.image,
-          data: data,
+          data
         }
       }
 
@@ -130,16 +130,16 @@ const App = (props: React.PropsWithChildren) => {
               show: '/fdo/show/:id',
               create: '/fdo'
             }, {
-                name: 'repositories',
-                list: '/repositories',
-                show: '/repositories/show/:id'
-              }, {
-                name: 'info',
-                show: '/info'
-              }, {
-              name: "profiles",
-              list: "/profiles",
-              show: "/profiles/show/:id"
+              name: 'repositories',
+              list: '/repositories',
+              show: '/repositories/show/:id'
+            }, {
+              name: 'info',
+              show: '/info'
+            }, {
+              name: 'profiles',
+              list: '/profiles',
+              show: '/profiles/show/:id'
             }]}
           >
             {props.children}
@@ -149,7 +149,7 @@ const App = (props: React.PropsWithChildren) => {
         </RefineSnackbarProvider>
       </ColorModeContextProvider>
     </RefineKbarProvider>
-  </>;
+  </>
 }
 
 function MyApp ({
diff --git a/pages/api/auth/[...nextauth].ts b/pages/api/auth/[...nextauth].ts
index 462fb1d..aae8fd3 100644
--- a/pages/api/auth/[...nextauth].ts
+++ b/pages/api/auth/[...nextauth].ts
@@ -1,12 +1,12 @@
 import NextAuth from 'next-auth'
 import KeycloakProvider from 'next-auth/providers/keycloak'
-//import { UnstorageAdapter } from '@auth/unstorage-adapter'
-//import { createStorage } from 'unstorage'
+// import { UnstorageAdapter } from '@auth/unstorage-adapter'
+// import { createStorage } from 'unstorage'
 
-//const storage = createStorage()
+// const storage = createStorage()
 
 export const authOptions = {
-  //adapter: UnstorageAdapter(storage),
+  // adapter: UnstorageAdapter(storage),
   session: {
     maxAge: 172800 // 48h
   },
@@ -35,15 +35,17 @@ export const authOptions = {
     },
     async session ({ session, user, token }: any) {
       console.log('### session', session, user, token, '### ### ###')
-      return { ...session,
-        account: token.account,
+      return {
+        ...session,
+        account: token.account
       }
     },
     async jwt ({ token, user, account, profile, isNewUser }: any) {
       console.log('### jwt', token, user, account, profile, isNewUser, '### ### ###')
-      if ( account ) {
-        return { ...token,
-          account: account
+      if (account) {
+        return {
+          ...token,
+          account
         }
       }
       return token
diff --git a/src/api/api.ts b/src/api/api.ts
index cac6a40..3e8cfae 100644
--- a/src/api/api.ts
+++ b/src/api/api.ts
@@ -1,4 +1,3 @@
-/* tslint:disable */
 /* eslint-disable */
 /**
  * FDO Manager Service API
diff --git a/src/api/base.ts b/src/api/base.ts
index 78b555a..89b54ab 100644
--- a/src/api/base.ts
+++ b/src/api/base.ts
@@ -1,4 +1,3 @@
-/* tslint:disable */
 /* eslint-disable */
 /**
  * FDO Manager Service API
diff --git a/src/api/common.ts b/src/api/common.ts
index e97d5bf..9b2273c 100644
--- a/src/api/common.ts
+++ b/src/api/common.ts
@@ -1,4 +1,3 @@
-/* tslint:disable */
 /* eslint-disable */
 /**
  * FDO Manager Service API
diff --git a/src/api/configuration.ts b/src/api/configuration.ts
index cc56d02..e8efb77 100644
--- a/src/api/configuration.ts
+++ b/src/api/configuration.ts
@@ -1,4 +1,3 @@
-/* tslint:disable */
 /* eslint-disable */
 /**
  * FDO Manager Service API
diff --git a/src/api/index.ts b/src/api/index.ts
index 4e2f60d..10f5653 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,4 +1,3 @@
-/* tslint:disable */
 /* eslint-disable */
 /**
  * FDO Manager Service API
diff --git a/src/components/fdos/create.tsx b/src/components/fdos/create.tsx
index 17be4c9..214590b 100644
--- a/src/components/fdos/create.tsx
+++ b/src/components/fdos/create.tsx
@@ -1,10 +1,9 @@
-import { IResourceComponentsProps, useList, HttpError } from '@refinedev/core'
-import { useGetIdentity } from "@refinedev/core";
+import { IResourceComponentsProps, useList, HttpError, useGetIdentity } from '@refinedev/core'
 import { Create, SaveButton } from '@refinedev/mui'
 import { useTheme, styled } from '@mui/material/styles'
 
-import Skeleton from '@mui/material/Skeleton';
-import Stack from '@mui/material/Stack';
+import Skeleton from '@mui/material/Skeleton'
+import Stack from '@mui/material/Stack'
 import Box from '@mui/material/Box'
 import TextField from '@mui/material/TextField'
 import InputLabel from '@mui/material/InputLabel'
@@ -51,9 +50,9 @@ const StepRepository: React.FC<any> = ({ control, register, errors }) => {
           name="profile"
           render={({ field }) => {
             return (
-              profileList.isLoading ?
-              <Skeleton><Select></Select></Skeleton> :
-              <Select
+              profileList.isLoading
+                ? <Skeleton><Select></Select></Skeleton>
+                : <Select
                 {...field}
                 error={!!errors.profile}
                 labelId="profile-select-label"
@@ -73,9 +72,9 @@ const StepRepository: React.FC<any> = ({ control, register, errors }) => {
           name="repository"
           render={({ field }) => {
             return (
-              repositoryList.isLoading ?
-              <Skeleton><Select></Select></Skeleton> :
-              <Select
+              repositoryList.isLoading
+                ? <Skeleton><Select></Select></Skeleton>
+                : <Select
                 {...field}
                 error={!!errors.repository}
                 labelId="repository-select-label"
@@ -141,11 +140,11 @@ const StepData: React.FC<any> = ({ register, errors }) => {
 }
 
 export const FdoCreate: React.FC<IResourceComponentsProps> = () => {
-  const identity = useGetIdentity()
-  const access_token = identity.data?.data?.account?.access_token
+  const identity = useGetIdentity<any>()
+  const accessToken = identity.data?.data?.account?.access_token
 
-  console.log('access_token: ', access_token)
-  const formRet = useStepsForm<IRepository, HttpError, any>({ defaultValues: { repository: '', profile: '' }, refineCoreProps: { meta: { headers: { "Authentication" : `Bearer ${access_token}` }}}})
+  console.log('accessToken: ', accessToken)
+  const formRet = useStepsForm<any, HttpError, any>({ defaultValues: { repository: '', profile: '' }, refineCoreProps: { meta: { headers: { Authentication: `Bearer ${accessToken}` } } } })
   console.log('formRet', formRet)
   const {
     saveButtonProps,
diff --git a/src/components/profiles/index.ts b/src/components/profiles/index.ts
index 36a9284..1f96e3a 100644
--- a/src/components/profiles/index.ts
+++ b/src/components/profiles/index.ts
@@ -1,2 +1,2 @@
-export * from "./list";
-export * from "./show";
+export * from './list'
+export * from './show'
diff --git a/src/components/profiles/list.tsx b/src/components/profiles/list.tsx
index 0b121cf..ba133b8 100644
--- a/src/components/profiles/list.tsx
+++ b/src/components/profiles/list.tsx
@@ -1,5 +1,5 @@
 import { IResourceComponentsProps } from '@refinedev/core'
-import Link from '@mui/material/Link';
+import Link from '@mui/material/Link'
 
 import { List, useDataGrid } from '@refinedev/mui'
 
diff --git a/src/components/profiles/show.tsx b/src/components/profiles/show.tsx
index bc81ae0..ae51dff 100644
--- a/src/components/profiles/show.tsx
+++ b/src/components/profiles/show.tsx
@@ -1,6 +1,6 @@
-import { IResourceComponentsProps } from "@refinedev/core";
-import { MuiInferencer } from "@refinedev/inferencer/mui";
+import { IResourceComponentsProps } from '@refinedev/core'
+import { MuiInferencer } from '@refinedev/inferencer/mui'
 
 export const ProfilesShow: React.FC<IResourceComponentsProps> = () => {
-    return <MuiInferencer />;
-};
+  return <MuiInferencer />
+}
diff --git a/src/components/repositories/list.tsx b/src/components/repositories/list.tsx
index dece502..a9809c0 100644
--- a/src/components/repositories/list.tsx
+++ b/src/components/repositories/list.tsx
@@ -1,5 +1,5 @@
 import { IResourceComponentsProps } from '@refinedev/core'
-import Link from '@mui/material/Link';
+import Link from '@mui/material/Link'
 
 import { List, useDataGrid } from '@refinedev/mui'
 
diff --git a/src/components/profiles/IProfile.tsx b/src/interfaces/IProfile.tsx
similarity index 58%
rename from src/components/profiles/IProfile.tsx
rename to src/interfaces/IProfile.tsx
index 8a72bc7..9a8f631 100644
--- a/src/components/profiles/IProfile.tsx
+++ b/src/interfaces/IProfile.tsx
@@ -1,4 +1,4 @@
-interface IProfile = {
+export interface IProfile {
   id: string
 }
 
diff --git a/src/interfaces/IRepository.tsx b/src/interfaces/IRepository.tsx
index 8de99e8..dde8ae7 100644
--- a/src/interfaces/IRepository.tsx
+++ b/src/interfaces/IRepository.tsx
@@ -1,4 +1,4 @@
-interface IRepository = {
+export interface IRepository {
   id: string
 }
 
diff --git a/src/interfaces/index.d.ts b/src/interfaces/index.d.ts
index 13cd313..9aa7cc0 100644
--- a/src/interfaces/index.d.ts
+++ b/src/interfaces/index.d.ts
@@ -1,2 +1,2 @@
 export * from './IRepository'
-export * form './IProfile
+export * from './IProfile'
diff --git a/src/providers/dataProvider.tsx b/src/providers/dataProvider.tsx
index 4c1eba3..0814e10 100644
--- a/src/providers/dataProvider.tsx
+++ b/src/providers/dataProvider.tsx
@@ -36,7 +36,7 @@ const apiDataProvider = (apiUrl: string): DataProvider => {
   const callOperation = async (resource: string, operation: string, kwargs: any) => {
     const resourceObj: any = apiResources[resource] || apiResources.default
     const func: any = apiOperations[resource][operation]
-    var headers = kwargs?.meta?.headers
+    const headers = kwargs?.meta?.headers
     if (func && (operation === 'get' || operation === 'list')) {
       if (kwargs?.id) {
         return (await func.apply(resourceObj, [kwargs.id])).data
@@ -44,7 +44,7 @@ const apiDataProvider = (apiUrl: string): DataProvider => {
         return (await func.apply(resourceObj)).data
       }
     } else if (func && operation === 'create') {
-      return await func.apply(resourceObj, kwargs.variables.concat({headers: headers}));
+      return await func.apply(resourceObj, kwargs.variables.concat({ headers }))
     }
     throw new Error('Not implemented')
   }
-- 
GitLab