Added check for preview mode to allow mock pages

no issue

- By default, we have guards to allow pages based on logged in state
- For preview mode, we switch off this guard to allow signin/signup pages to open
This commit is contained in:
Rish 2020-07-08 10:37:19 +05:30
parent df1952ba01
commit 9ac11c562e
6 changed files with 16 additions and 5 deletions

View File

@ -2,6 +2,7 @@ import AppContext from '../../AppContext';
import MemberAvatar from '../common/MemberGravatar';
import ActionButton from '../common/ActionButton';
import Switch from '../common/Switch';
import isPreviewMode from '../../utils/is-preview-mode';
const React = require('react');
@ -261,7 +262,7 @@ export default class AccountHomePage extends React.Component {
componentDidMount() {
const {member} = this.context;
if (!member) {
if (!member && !isPreviewMode()) {
this.context.onAction('switchPage', {
page: 'signup'
});

View File

@ -1,6 +1,7 @@
import AppContext from '../../AppContext';
import ActionButton from '../common/ActionButton';
import PlansSection from '../common/PlansSection';
import isPreviewMode from '../../utils/is-preview-mode';
const React = require('react');
@ -18,7 +19,7 @@ export default class AccountPlanPage extends React.Component {
componentDidMount() {
const {member} = this.context;
if (!member) {
if (!member && !isPreviewMode()) {
this.context.onAction('switchPage', {
page: 'signup'
});

View File

@ -3,6 +3,7 @@ import MemberAvatar from '../common/MemberGravatar';
import ActionButton from '../common/ActionButton';
import InputField from '../common/InputField';
import Switch from '../common/Switch';
import isPreviewMode from '../../utils/is-preview-mode';
const React = require('react');
@ -20,7 +21,7 @@ export default class AccountProfilePage extends React.Component {
componentDidMount() {
const {member} = this.context;
if (!member) {
if (!member && !isPreviewMode()) {
this.context.onAction('switchPage', {
page: 'signup'
});

View File

@ -1,6 +1,7 @@
import ActionButton from '../common/ActionButton';
import InputField from '../common/InputField';
import AppContext from '../../AppContext';
import isPreviewMode from '../../utils/is-preview-mode';
const React = require('react');
@ -16,7 +17,7 @@ export default class SigninPage extends React.Component {
componentDidMount() {
const {member} = this.context;
if (member) {
if (member && !isPreviewMode()) {
this.context.onAction('switchPage', {
page: 'accountHome'
});

View File

@ -2,6 +2,7 @@ import ActionButton from '../common/ActionButton';
import InputField from '../common/InputField';
import AppContext from '../../AppContext';
import PlansSection from '../common/PlansSection';
import isPreviewMode from '../../utils/is-preview-mode';
const React = require('react');
@ -19,7 +20,7 @@ class SignupPage extends React.Component {
componentDidMount() {
const {member} = this.context;
if (member) {
if (member && !isPreviewMode()) {
this.context.onAction('switchPage', {
page: 'accountHome'
});

View File

@ -0,0 +1,6 @@
function isPreviewMode() {
const [path, qs] = window.location.hash.substr(1).split('?');
return (path === '/portal' && qs);
}
export default isPreviewMode;