From 8add31f01d65647a42e3f798bbeaeb8e0b2eea9c Mon Sep 17 00:00:00 2001 From: varuntree Date: Thu, 25 Apr 2024 16:28:23 +0530 Subject: [PATCH 1/3] added-package --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index fe39a0d0..856d2814 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@mui/material": "^5.15.11", "@samagra-x/chatui": "^1.0.3", "bootstrap-css-only": "^4.4.1", + "decap-cms-app": "^3.1.10", "i18next": "^23.10.0", "lodash": "^4.17.21", "moment": "^2.30.1", From 49fda3c164d9f245eed7f7e85537f9628a211735 Mon Sep 17 00:00:00 2001 From: varuntree Date: Fri, 26 Apr 2024 17:08:16 +0530 Subject: [PATCH 2/3] integrate_/admin --- public/admin/MoleculePreview.tsx | 20 ++++++++++++++++++++ public/admin/cms.js | 4 ++++ public/admin/config.yml | 19 +++++++++++++++++++ public/admin/index.html | 28 ++++++++++++++++++++++++++++ src/App.tsx | 4 ++-- 5 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 public/admin/MoleculePreview.tsx create mode 100644 public/admin/cms.js create mode 100644 public/admin/config.yml create mode 100644 public/admin/index.html diff --git a/public/admin/MoleculePreview.tsx b/public/admin/MoleculePreview.tsx new file mode 100644 index 00000000..f79f6e79 --- /dev/null +++ b/public/admin/MoleculePreview.tsx @@ -0,0 +1,20 @@ +import React from 'react'; + +const MoleculePreview = ({ entry }) => { + const data = entry.getIn(['data']).toJS(); + return ( +
+
+

{data.title}

+

{data.description}

+ {/* Render your molecule component here using data.config */} +
+
+ {/* Assume this is where your molecule is rendered */} + +
+
+ ); +} + +export default MoleculePreview; diff --git a/public/admin/cms.js b/public/admin/cms.js new file mode 100644 index 00000000..a18c7091 --- /dev/null +++ b/public/admin/cms.js @@ -0,0 +1,4 @@ +import CMS from 'netlify-cms-app'; +import MoleculePreview from './MoleculePreview'; + +CMS.registerPreviewTemplate('molecules', MoleculePreview); diff --git a/public/admin/config.yml b/public/admin/config.yml new file mode 100644 index 00000000..7786013d --- /dev/null +++ b/public/admin/config.yml @@ -0,0 +1,19 @@ +backend: + name: git-gateway + branch: integrate_cms + +load_config_file: false + +# Make the collections for all the molecules +# and need to refactor the currect structure of the code make each coponent +# having its own md_file(cofig) + +collections: + - name: "molecules" + label: "Molecules" + folder: "src/molecules" + create: true + fields: + - {name: "title", label: "Title", widget: "string"} + - {name: "description", label: "Description", widget: "text"} + - {name: "config", label: "Config", widget: "json"} diff --git a/public/admin/index.html b/public/admin/index.html new file mode 100644 index 00000000..f424dafb --- /dev/null +++ b/public/admin/index.html @@ -0,0 +1,28 @@ + + + + + + + Content Manager + + + + + + + + + \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 0ae1f6a8..b13c2aa3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,7 +15,7 @@ import HomePage from './molecules/home-page' import FeedbackPage from './molecules/feedback' import ShareButtons from './molecules/share-buttons' import { ChatUI } from './molecules/chat-ui' -import AdminRoute from './components/InputForm' +{/* import AdminRoute from './components/InputForm' 8 */} function App() { return ( @@ -37,7 +37,7 @@ function App() { } /> } /> } /> - } /> + {/*} /> */} From 87e776e8786f24f07d66c1151b2f83bf1393ca72 Mon Sep 17 00:00:00 2001 From: varuntree Date: Fri, 26 Apr 2024 23:02:09 +0530 Subject: [PATCH 3/3] added_adminauth --- public/admin/index.html | 7 ++----- src/components/InputForm/faqPage.tsx | 1 - src/components/InputForm/historyPage.tsx | 1 - src/hook/useConfig.ts | 7 ++++--- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/public/admin/index.html b/public/admin/index.html index f424dafb..2f3018f7 100644 --- a/public/admin/index.html +++ b/public/admin/index.html @@ -8,11 +8,6 @@ - - - + + \ No newline at end of file diff --git a/src/components/InputForm/faqPage.tsx b/src/components/InputForm/faqPage.tsx index b4c7705c..d64b7292 100644 --- a/src/components/InputForm/faqPage.tsx +++ b/src/components/InputForm/faqPage.tsx @@ -1,5 +1,4 @@ import { Box } from '@mui/material' -import React from 'react' import { CheckBoxOption, InputField, PageTitle } from './customeField' import { gap, marginBotton } from './constant' import { useConfig } from '../../hook/useConfig' diff --git a/src/components/InputForm/historyPage.tsx b/src/components/InputForm/historyPage.tsx index 64fd8aff..065e06ec 100644 --- a/src/components/InputForm/historyPage.tsx +++ b/src/components/InputForm/historyPage.tsx @@ -1,5 +1,4 @@ import { Box } from '@mui/material' -import React from 'react' import { CheckBoxOption, InputField, PageTitle } from './customeField' import { gap, marginBotton } from './constant' import { useConfig } from '../../hook/useConfig' diff --git a/src/hook/useConfig.ts b/src/hook/useConfig.ts index 8dd9711e..5c507d6c 100644 --- a/src/hook/useConfig.ts +++ b/src/hook/useConfig.ts @@ -1,16 +1,17 @@ + import { useConfigContext } from '../context/configContext' export const useConfig = (key: string, name: string) => { const { config } = useConfigContext() - return config?.[key]?.[name] + return (config as any)?.[key]?.[name] } export const useThemeConfig = (key: string) => { const { config } = useConfigContext() - return config?.[key] + return (config as any)?.[key] } export const useUiConfig = (key: string, name: string) => { const { uiConfig } = useConfigContext() - return uiConfig?.[key]?.[name] + return (uiConfig as any)?.[key]?.[name] }