PromucFlow_constructor/app/client/src/pages/AppViewer/AppPage.tsx

42 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-03-11 13:59:46 +00:00
import React, { useEffect } from "react";
import styled from "styled-components";
2019-11-25 05:07:27 +00:00
import WidgetFactory from "utils/WidgetFactory";
2020-03-11 13:59:46 +00:00
import AnalyticsUtil from "utils/AnalyticsUtil";
import { useDynamicAppLayout } from "utils/hooks/useDynamicAppLayout";
import { DSLWidget } from "widgets/constants";
import { RenderModes } from "constants/WidgetConstants";
2020-01-16 11:46:21 +00:00
const PageView = styled.div<{ width: number }>`
2019-11-05 05:09:50 +00:00
height: 100%;
position: relative;
2020-12-24 04:32:25 +00:00
width: ${(props) => props.width}px;
2020-01-16 11:46:21 +00:00
margin: 0 auto;
`;
type AppPageProps = {
dsl: DSLWidget;
2020-03-11 13:59:46 +00:00
pageName?: string;
pageId?: string;
appName?: string;
};
export function AppPage(props: AppPageProps) {
useDynamicAppLayout();
2020-03-11 13:59:46 +00:00
useEffect(() => {
AnalyticsUtil.logEvent("PAGE_LOAD", {
pageName: props.pageName,
pageId: props.pageId,
appName: props.appName,
2020-03-11 13:59:46 +00:00
mode: "VIEW",
});
}, [props.pageId, props.pageName]);
return (
<PageView className="t--app-viewer-page" width={props.dsl.rightColumn}>
{props.dsl.widgetId &&
WidgetFactory.createWidget(props.dsl, RenderModes.PAGE)}
</PageView>
);
}
export default AppPage;