Skip to content

Commit c3c9adc

Browse files
siddharthkpCompuIves
authored andcommitted
Add checks for patron redirect + remove badge from editor (codesandbox#3131)
* remove patron badge from sandbox header * add redirection check for ppatron
1 parent 48b65c7 commit c3c9adc

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

packages/app/src/app/pages/Patron/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@ import { Content } from './elements';
1212

1313
const Patron: React.FC = () => {
1414
const {
15-
state: { user },
15+
state: { hasLoadedApp, isLoggedIn, user },
1616
actions,
1717
} = useOvermind();
1818

19-
if (user && user.subscription && user.subscription.plan === 'pro') {
19+
if (!isLoggedIn) {
2020
location.href = '/pro';
2121
}
22+
// don't send them away before authentication
23+
if (hasLoadedApp && user) {
24+
if (
25+
!user.subscription || // if no subscription, get pro
26+
user.subscription.plan !== 'patron' // if subscription but not patron, go to pro
27+
) {
28+
location.href = '/pro';
29+
}
30+
}
2231

2332
useEffect(() => {
2433
actions.patron.patronMounted();

packages/app/src/app/pages/Sandbox/Editor/Header/Header.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { UserMenu } from 'app/pages/common/UserMenu';
77
import {
88
SaveAllButton,
99
RefreshButton,
10-
PatronButton,
1110
PreferencesButton,
1211
NewSandboxButton,
1312
LikeButton,
@@ -37,7 +36,6 @@ export const Header: React.FC<IHeaderProps> = ({ zenMode }) => {
3736
preferences: {
3837
settings: { experimentVSCode: vscode },
3938
},
40-
isPatron,
4139
updateStatus,
4240
hasLogIn,
4341
isLoggedIn,
@@ -65,7 +63,6 @@ export const Header: React.FC<IHeaderProps> = ({ zenMode }) => {
6563

6664
<Right>
6765
{updateStatus === 'available' && <RefreshButton />}
68-
{!isLoggedIn || (!isPatron && <PatronButton />)}
6966
{!isLoggedIn && <PreferencesButton />}
7067
<NewSandboxButton />
7168
{isLoggedIn && <LikeButton />}

0 commit comments

Comments
 (0)