fix: add ability to subscribe without account (#722)
This commit is contained in:
@@ -8,6 +8,7 @@ RAILS_SERVE_STATIC_FILES=true
|
|||||||
SECRET_KEY_BASE=test
|
SECRET_KEY_BASE=test
|
||||||
APP_HOST=http://localhost:3001
|
APP_HOST=http://localhost:3001
|
||||||
PURCHASE_URL=https://standardnotes.com/purchase
|
PURCHASE_URL=https://standardnotes.com/purchase
|
||||||
|
PLANS_URL=https://standardnotes.com/plans
|
||||||
DASHBOARD_URL=http://standardnotes.com/dashboard
|
DASHBOARD_URL=http://standardnotes.com/dashboard
|
||||||
|
|
||||||
SF_DEFAULT_SERVER=http://localhost:3000
|
SF_DEFAULT_SERVER=http://localhost:3000
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ declare global {
|
|||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
_purchase_url?: string;
|
_purchase_url?: string;
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
|
_plans_url?: string;
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
_dashboard_url?: string;
|
_dashboard_url?: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export const NoSubscription: FunctionalComponent<{
|
|||||||
<LinkButton
|
<LinkButton
|
||||||
className="min-w-20 mt-3 mr-3"
|
className="min-w-20 mt-3 mr-3"
|
||||||
label="Learn More"
|
label="Learn More"
|
||||||
link="https://standardnotes.com/plans"
|
link={window._plans_url as string}
|
||||||
/>
|
/>
|
||||||
{application.hasAccount() &&
|
{application.hasAccount() &&
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -11,10 +11,13 @@ export type PurchaseFlowWrapperProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getPurchaseFlowUrl = async (application: WebApplication): Promise<string | undefined> => {
|
export const getPurchaseFlowUrl = async (application: WebApplication): Promise<string | undefined> => {
|
||||||
const token = await application.getNewSubscriptionToken();
|
|
||||||
if (token) {
|
|
||||||
const currentUrl = window.location.href;
|
const currentUrl = window.location.href;
|
||||||
const successUrl = isDesktopApplication() ? `standardnotes://${currentUrl}` : currentUrl;
|
const successUrl = isDesktopApplication() ? `standardnotes://${currentUrl}` : currentUrl;
|
||||||
|
if (application.noAccount()) {
|
||||||
|
return `${window._purchase_url}/offline?&success_url=${successUrl}`;
|
||||||
|
}
|
||||||
|
const token = await application.getNewSubscriptionToken();
|
||||||
|
if (token) {
|
||||||
return `${window._purchase_url}?subscription_token=${token}&success_url=${successUrl}`;
|
return `${window._purchase_url}?subscription_token=${token}&success_url=${successUrl}`;
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ export const CreateAccount: FunctionComponent<Props> = observer(
|
|||||||
setCurrentPane(PurchaseFlowPane.SignIn);
|
setCurrentPane(PurchaseFlowPane.SignIn);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const subscribeWithoutAccount = () => {
|
||||||
|
loadPurchaseFlowUrl(application).catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
application.alertService.alert(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleCreateAccount = async () => {
|
const handleCreateAccount = async () => {
|
||||||
if (!email) {
|
if (!email) {
|
||||||
emailInputRef?.current!.focus();
|
emailInputRef?.current!.focus();
|
||||||
@@ -192,6 +199,13 @@ export const CreateAccount: FunctionComponent<Props> = observer(
|
|||||||
disabled={isCreatingAccount}
|
disabled={isCreatingAccount}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={subscribeWithoutAccount}
|
||||||
|
disabled={isCreatingAccount}
|
||||||
|
className="p-0 bg-default border-0 font-medium color-info cursor-pointer hover:underline"
|
||||||
|
>
|
||||||
|
Subscribe without account
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<Illustration />
|
<Illustration />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
window._enable_unfinished_features = "<%= ENV['ENABLE_UNFINISHED_FEATURES'] %>" === 'true';
|
window._enable_unfinished_features = "<%= ENV['ENABLE_UNFINISHED_FEATURES'] %>" === 'true';
|
||||||
window._websocket_url = "<%= ENV['WEBSOCKET_URL'] %>";
|
window._websocket_url = "<%= ENV['WEBSOCKET_URL'] %>";
|
||||||
window._purchase_url = "<%= ENV['PURCHASE_URL'] %>";
|
window._purchase_url = "<%= ENV['PURCHASE_URL'] %>";
|
||||||
|
window._plans_url = "<%= ENV['PLANS_URL'] %>";
|
||||||
window._dashboard_url = "<%= ENV['DASHBOARD_URL'] %>";
|
window._dashboard_url = "<%= ENV['DASHBOARD_URL'] %>";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
data-enable-unfinished-features="<%= env.ENABLE_UNFINISHED_FEATURES %>"
|
data-enable-unfinished-features="<%= env.ENABLE_UNFINISHED_FEATURES %>"
|
||||||
data-web-socket-url="<%= env.DEV_WEBSOCKET_URL %>"
|
data-web-socket-url="<%= env.DEV_WEBSOCKET_URL %>"
|
||||||
data-purchase-url="<%= env.PURCHASE_URL %>"
|
data-purchase-url="<%= env.PURCHASE_URL %>"
|
||||||
|
data-plans-url="<%= env.PLANS_URL %>"
|
||||||
data-dashboard-url="<%= env.DASHBOARD_URL %>"
|
data-dashboard-url="<%= env.DASHBOARD_URL %>"
|
||||||
>
|
>
|
||||||
<script>
|
<script>
|
||||||
@@ -42,6 +43,7 @@
|
|||||||
window._enable_unfinished_features = document.body.dataset.enableUnfinishedFeatures === 'true';
|
window._enable_unfinished_features = document.body.dataset.enableUnfinishedFeatures === 'true';
|
||||||
window._websocket_url = document.body.dataset.webSocketUrl;
|
window._websocket_url = document.body.dataset.webSocketUrl;
|
||||||
window._purchase_url = document.body.dataset.purchaseUrl;
|
window._purchase_url = document.body.dataset.purchaseUrl;
|
||||||
|
window._plans_url = document.body.dataset.plansUrl;
|
||||||
window._dashboard_url = document.body.dataset.dashboardUrl;
|
window._dashboard_url = document.body.dataset.dashboardUrl;
|
||||||
</script>
|
</script>
|
||||||
<application-group-view />
|
<application-group-view />
|
||||||
|
|||||||
Reference in New Issue
Block a user