Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jzongker committed Nov 19, 2024
2 parents 24a254c + d694088 commit f2e2861
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export function ContentEditorClient(props: Props) {
const loadData = async (id: string) =>
await ApiHelper.get("/pages/" + UserHelper.currentUserChurch.church.id + "/tree?id=" + id, "ContentApi");

const handleDone = () => {
redirect("/admin/site/pages/preview/" + id);
const handleDone = (url?: string) => {
if (url && url !== '') redirect(url);
else redirect("/admin/site/pages/preview/" + id);
};

return (
Expand Down
16 changes: 14 additions & 2 deletions src/components/admin/ContentEditor/ContentEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface Props extends WrapperPageProps {
loadData: (id:string) => Promise<any>,
pageId?: string,
blockId?: string
onDone?: () => void
onDone?: (url?: string) => void
};

export default function ContentEditor(props: Props) {
Expand Down Expand Up @@ -140,6 +140,18 @@ export default function ContentEditor(props: Props) {
}
}

const handleDone = () => {
let url = '';
if (props.pageId) {
const page = container as PageInterface;
if (page.layout === "embed") {
if (page.url.includes("/member")) url = '/admin';
else if (page.url.includes("/stream")) url='/admin/video/settings';
}
}
props.onDone(url);
}

/*Todo: affix the sidebar with CSS instead*/
useEffect(() => {
const onScroll = (e:any) => { setScrollTop(e.target.documentElement.scrollTop); };
Expand Down Expand Up @@ -224,7 +236,7 @@ export default function ContentEditor(props: Props) {
<div style={{backgroundColor:"#FFF", position:"sticky", top:0, width:"100%", zIndex:1000, boxShadow:"0px 2px 2px black", marginBottom:10}}>
<Grid container spacing={2}>
<Grid item xs={4} style={{paddingLeft:40, paddingTop:8}}>
<SmallButton icon={"done"} text="Done" onClick={props.onDone} />
<SmallButton icon={"done"} text="Done" onClick={handleDone} />
</Grid>
<Grid item xs={4} style={{textAlign:"center"}}>
<b>
Expand Down

0 comments on commit f2e2861

Please sign in to comment.