Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 20 additions & 0 deletions public/admin/MoleculePreview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';

const MoleculePreview = ({ entry }) => {
const data = entry.getIn(['data']).toJS();
return (
<div style={{ display: 'flex', width: '100%' }}>
<div style={{ flex: 1, padding: '20px' }}>
<h1>{data.title}</h1>
<p>{data.description}</p>
{/* Render your molecule component here using data.config */}
</div>
<div style={{ flex: 1, padding: '20px' }}>
{/* Assume this is where your molecule is rendered */}

</div>
</div>
);
}

export default MoleculePreview;
4 changes: 4 additions & 0 deletions public/admin/cms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import CMS from 'netlify-cms-app';
import MoleculePreview from './MoleculePreview';

CMS.registerPreviewTemplate('molecules', MoleculePreview);
19 changes: 19 additions & 0 deletions public/admin/config.yml
Original file line number Diff line number Diff line change
@@ -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"}
25 changes: 25 additions & 0 deletions public/admin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="noindex" />
<title>Content Manager</title>
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
</head>
<body>
<script>
if (window.netlifyIdentity) {
window.netlifyIdentity.on("init", (user) => {
if (!user) {
window.netlifyIdentity.on("login", () => {
document.location.href = "/admin/";
});
}
});
}
</script>
<!-- Include the script that builds the page and powers Decap CMS -->
<script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -37,7 +37,7 @@ function App() {
<Route path="/share-buttons" element={<ShareButtons />} />
<Route path="/chat-ui" element={<ChatUI />} />
<Route path="/molecules" element={<Components />} />
<Route path="/admin" element={<AdminRoute />} />
{/*<Route path="/admin" element={<AdminRoute />} /> */}
</Routes>
</>
</>
Expand Down
1 change: 0 additions & 1 deletion src/components/InputForm/faqPage.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
1 change: 0 additions & 1 deletion src/components/InputForm/historyPage.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
7 changes: 4 additions & 3 deletions src/hook/useConfig.ts
Original file line number Diff line number Diff line change
@@ -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]
}