generated from wrappid/wrappid-module
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
here json is works, but in ui at first time it works but from child it update in json but not in ui, also add id, also initially when the page is load in json there is no id is visible Ref: #54
- Loading branch information
Showing
3 changed files
with
65 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 13 additions & 16 deletions
29
app/components/page-builder/content-components/JsonCanvasViewer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
import React from "react"; | ||
|
||
import { CoreBox, CoreClasses } from "@wrappid/core"; | ||
import { useSelector } from "react-redux"; | ||
|
||
export default function JsonCanvasViewer() { | ||
// Fetch the selected layout and placeholders from the Redux store | ||
const selectedLayout = useSelector((state) => state.testBuilderReducer?.selectedLayout); | ||
const layoutName = selectedLayout || "BlankLayout"; | ||
const componentsInBoxes = useSelector((state) => state.testBuilderReducer?.componentsInBoxes) || []; | ||
|
||
const [pageJson, setPageJson] = React.useState({ layout: layoutName }); | ||
// Create the pageJson structure based on the Redux data | ||
const pageJson = { | ||
layout : selectedLayout || "BlankLayout", | ||
placeholders: componentsInBoxes | ||
}; | ||
|
||
// Update pageJson when layout changes | ||
React.useEffect(() => { | ||
if (layoutName) { | ||
setPageJson((prevPageJson) => ({ | ||
...prevPageJson, | ||
layout: layoutName, // Replace the layout with the new selected layout | ||
})); | ||
} | ||
}, [layoutName]); | ||
return ( | ||
<> | ||
<CoreBox component="pre" styleClasses={[CoreClasses.HEIGHT.VH_75, CoreClasses.OVERFLOW.OVERFLOW_AUTO, CoreClasses.PADDING.P2]}> | ||
{JSON.stringify(pageJson, null, 2)} | ||
<CoreBox | ||
component="pre" | ||
styleClasses={[CoreClasses.HEIGHT.VH_75, CoreClasses.OVERFLOW.OVERFLOW_AUTO, CoreClasses.PADDING.P2]} | ||
> | ||
{JSON.stringify(pageJson, null, 2)} | ||
</CoreBox> | ||
</> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters