feat: Pass period & plan params to purchase page (#733)

This commit is contained in:
Aman Harwara
2021-11-12 20:32:35 +05:30
committed by GitHub
parent 873aa1558e
commit 3c3131adef

View File

@@ -10,7 +10,9 @@ export type PurchaseFlowWrapperProps = {
application: WebApplication;
};
export const getPurchaseFlowUrl = async (application: WebApplication): Promise<string | undefined> => {
export const getPurchaseFlowUrl = async (
application: WebApplication
): Promise<string | undefined> => {
const currentUrl = window.location.origin;
const successUrl = isDesktopApplication() ? `standardnotes://` : currentUrl;
if (application.noAccount()) {
@@ -27,8 +29,11 @@ export const loadPurchaseFlowUrl = async (
application: WebApplication
): Promise<boolean> => {
const url = await getPurchaseFlowUrl(application);
const params = new URLSearchParams(window.location.search);
const period = params.get('period') ? `&period=${params.get('period')}` : '';
const plan = params.get('plan') ? `&plan=${params.get('plan')}` : '';
if (url) {
window.location.assign(url);
window.location.assign(`${url}${period}${plan}`);
return true;
}
return false;