Skip to content

Commit

Permalink
Merge pull request #293 from factly/feat/analytics
Browse files Browse the repository at this point in the history
feat: add analytics field in space
  • Loading branch information
deshetti authored Apr 11, 2021
2 parents 6c6f93b + 205f4ae commit 56d37eb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/config/routesConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {

//Pages
import Dashboard from '../pages/dashboard';
import Analytics from '../pages/analytics';

//Spaces
import Spaces from '../pages/spaces';
Expand Down Expand Up @@ -115,7 +116,7 @@ const routes = {
},
analytics: {
path: '/analytics',
Component: Dashboard, // component is empty for now
Component: Analytics,
title: 'Analytics',
},
spaces: {
Expand Down
26 changes: 26 additions & 0 deletions src/pages/analytics/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { Result, Skeleton, Space } from 'antd';
import { useSelector } from 'react-redux';

function Analytics() {
const { space, loading } = useSelector(({ spaces }) => {
return {
space: spaces.details[spaces.selected],
loading: spaces.loading,
};
});

if (loading) return <Skeleton />;

return (
<Space direction="vertical">
{space.analytics && space.analytics.plausible && space.analytics.plausible.embed_code ? (
<div dangerouslySetInnerHTML={{ __html: space.analytics.plausible.embed_code }} />
) : (
<Result title="No analytics found" />
)}
</Space>
);
}

export default Analytics;
20 changes: 16 additions & 4 deletions src/pages/spaces/components/SpaceEditForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const SpaceEditForm = ({ onCreate, data = {} }) => {
<Steps.Step title="Basic" />
<Steps.Step title="Media" />
<Steps.Step title="Contact" />
<Steps.Step title="Analytics" />
</Steps>
<Form
{...layout}
Expand All @@ -48,7 +49,7 @@ const SpaceEditForm = ({ onCreate, data = {} }) => {
onReset();
}}
scrollToFirstError={true}
onFinishFailed={(errors) => {
onFinishFailed={() => {
setCurrent(0);
}}
onValuesChange={() => {
Expand Down Expand Up @@ -144,16 +145,27 @@ const SpaceEditForm = ({ onCreate, data = {} }) => {
<Input style={{ width: '100%' }} />
</Form.Item>
</div>
<div style={current === 3 ? { display: 'block' } : { display: 'none' }}>
<Form.Item name={['analytics', 'plausible', 'server_url']} label="Server URL">
<Input style={{ width: '100%' }} />
</Form.Item>
<Form.Item name={['analytics', 'plausible', 'domain']} label="Domain">
<Input style={{ width: '100%' }} />
</Form.Item>
<Form.Item name={['analytics', 'plausible', 'embed_code']} label="Embed Code">
<Input.TextArea style={{ width: '100%' }} />
</Form.Item>
</div>
<Form.Item>
<Button disabled={current === 0} onClick={() => setCurrent(current - 1)}>
Back
</Button>
{current < 2 ? (
<Button disabled={current === 2} onClick={() => setCurrent(current + 1)}>
{current < 3 ? (
<Button disabled={current === 3} onClick={() => setCurrent(current + 1)}>
Next
</Button>
) : null}
{current === 2 ? (
{current === 3 ? (
<Button disabled={!valueChange} type="primary" htmlType="submit">
Update
</Button>
Expand Down

0 comments on commit 56d37eb

Please sign in to comment.