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", 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..2f3018f7 --- /dev/null +++ b/public/admin/index.html @@ -0,0 +1,25 @@ + + + + + + + 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() { } /> } /> } /> - } /> + {/*} /> */} 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] }