Skip to content

Commit

Permalink
add page_type option on create page. fixes creativetimofficial#2
Browse files Browse the repository at this point in the history
  • Loading branch information
madeabinawa committed Aug 15, 2022
1 parent 1db05ba commit 930dd3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/pages/page/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ const PageEditor = () => {
tags: selectedTags.map(item => item.value).join(",")
};

if (values.page_type === "editor") {
// if page_type is editor, then fill html_content with values.content from TextEditor component
finalValue.html_content = values?.content;
}

console.log(finalValue);

action === "create"
Expand All @@ -78,7 +83,9 @@ const PageEditor = () => {
slug: action === "edit" ? slug : "",
tags: action === "edit" ? tags : "",
html_content: action === "edit" ? html_content : "",
css_content: action === "edit" ? css_content : ""
css_content: action === "edit" ? css_content : "",
content: action === "edit" && type === "editor" ? html_content : "", // for TextEditor component
page_type: type
},
onSubmit: formSubmitHandler,
});
Expand Down
10 changes: 8 additions & 2 deletions src/pages/page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ const PageMenu = () => {
<TableCell>
<SuiTypography variant="h6">Slug</SuiTypography>
</TableCell>
<TableCell>
<SuiTypography variant="h6">Type</SuiTypography>
</TableCell>
<TableCell>
<SuiTypography variant="h6">Tags</SuiTypography>
</TableCell>
Expand All @@ -156,8 +159,11 @@ const PageMenu = () => {
<TableCell component="th" scope="row">
<SuiTypography variant="caption">{row.slug}</SuiTypography>
</TableCell>
<TableCell component="th" scope="row">
<SuiTypography variant="caption">{row.page_type}</SuiTypography>
</TableCell>
<TableCell>
<SuiTypography variant="caption">{row.tags}</SuiTypography>
<SuiTypography variant="caption">{row?.tags?.split(",").join(", ")}</SuiTypography>
</TableCell>
<TableCell>
<SuiBox display="flex" alignItems="center">
Expand All @@ -166,7 +172,7 @@ const PageMenu = () => {
size="small"
variant="text"
color="dark"
onClick={() => navigate("editor/edit", { state: { ...row } })}
onClick={() => navigate("editor/edit", { state: { ...row, type: row.page_type } })}
>
<Icon>edit</Icon>&nbsp;edit
</SuiButton>
Expand Down

0 comments on commit 930dd3e

Please sign in to comment.