Merge branch 'develop' into feat/prefs-defaults
This commit is contained in:
@@ -1,23 +1,63 @@
|
||||
import { FunctionalComponent } from "preact";
|
||||
import { Text } from '@/preferences/components';
|
||||
import { Button } from '@/components/Button';
|
||||
import { WebApplication } from "@/ui_models/application";
|
||||
import { useState } from "preact/hooks";
|
||||
import { isDesktopApplication } from "@/utils";
|
||||
|
||||
export const NoSubscription: FunctionalComponent = () => (
|
||||
<>
|
||||
<Text>You don't have a Standard Notes subscription yet.</Text>
|
||||
<div className="flex">
|
||||
<Button
|
||||
className="min-w-20 mt-3 mr-3"
|
||||
type="normal"
|
||||
label="Refresh"
|
||||
onClick={() => null}
|
||||
/>
|
||||
<Button
|
||||
className="min-w-20 mt-3"
|
||||
type="primary"
|
||||
label="Purchase subscription"
|
||||
onClick={() => null}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
export const NoSubscription: FunctionalComponent<{
|
||||
application: WebApplication;
|
||||
}> = ({ application }) => {
|
||||
const [isLoadingPurchaseFlow, setIsLoadingPurchaseFlow] = useState(false);
|
||||
const [purchaseFlowError, setPurchaseFlowError] = useState<string | undefined>(undefined);
|
||||
|
||||
const onPurchaseClick = async () => {
|
||||
const errorMessage = 'There was an error when attempting to redirect you to the subscription page.';
|
||||
setIsLoadingPurchaseFlow(true);
|
||||
try {
|
||||
const url = await application.getPurchaseFlowUrl();
|
||||
if (url) {
|
||||
const currentUrl = window.location.href;
|
||||
const successUrl = isDesktopApplication() ? `standardnotes://${currentUrl}` : currentUrl;
|
||||
console.log(successUrl);
|
||||
window.location.assign(`${url}&success_url=${successUrl}`);
|
||||
} else {
|
||||
setPurchaseFlowError(errorMessage);
|
||||
}
|
||||
} catch (e) {
|
||||
setPurchaseFlowError(errorMessage);
|
||||
} finally {
|
||||
setIsLoadingPurchaseFlow(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Text>You don't have a Standard Notes subscription yet.</Text>
|
||||
{isLoadingPurchaseFlow && (
|
||||
<Text>
|
||||
Redirecting you to the subscription page...
|
||||
</Text>
|
||||
)}
|
||||
{purchaseFlowError && (
|
||||
<Text className="color-danger">
|
||||
{purchaseFlowError}
|
||||
</Text>
|
||||
)}
|
||||
<div className="flex">
|
||||
<Button
|
||||
className="min-w-20 mt-3 mr-3"
|
||||
type="normal"
|
||||
label="Refresh"
|
||||
onClick={() => null}
|
||||
/>
|
||||
<Button
|
||||
className="min-w-20 mt-3"
|
||||
type="primary"
|
||||
label="Purchase subscription"
|
||||
onClick={onPurchaseClick}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ export const Subscription: FunctionComponent<Props> = observer(({
|
||||
) : userSubscription && userSubscription.endsAt > now ? (
|
||||
<SubscriptionInformation subscriptionState={subscriptionState} />
|
||||
) : (
|
||||
<NoSubscription />
|
||||
<NoSubscription application={application} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -55,6 +55,7 @@ export class WebApplication extends SNApplication {
|
||||
scope: angular.IScope,
|
||||
defaultSyncServerHost: string,
|
||||
public bridge: Bridge,
|
||||
webSocketUrl: string,
|
||||
) {
|
||||
super(
|
||||
bridge.environment,
|
||||
@@ -67,6 +68,7 @@ export class WebApplication extends SNApplication {
|
||||
defaultSyncServerHost,
|
||||
AppVersion,
|
||||
isDev,
|
||||
webSocketUrl,
|
||||
);
|
||||
this.$compile = $compile;
|
||||
this.scope = scope;
|
||||
|
||||
@@ -64,6 +64,7 @@ export class ApplicationGroup extends SNApplicationGroup {
|
||||
scope,
|
||||
this.defaultSyncServerHost,
|
||||
this.bridge,
|
||||
this.webSocketUrl,
|
||||
);
|
||||
const appState = new AppState(
|
||||
this.$rootScope,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
is-open='ctrl.showAccountMenu',
|
||||
ng-click='ctrl.accountMenuPressed()'
|
||||
)
|
||||
.w-8.h-8.flex.items-center.justify-center.cursor-pointer.rounded-full(
|
||||
.w-8.h-full.flex.items-center.justify-center.cursor-pointer.rounded-full(
|
||||
ng-class="ctrl.showAccountMenu ? 'bg-border' : '' "
|
||||
)
|
||||
.w-5.h-5(
|
||||
@@ -26,7 +26,7 @@
|
||||
ng-click='ctrl.clickPreferences()'
|
||||
ng-if='ctrl.appState.enableUnfinishedFeatures'
|
||||
)
|
||||
.w-8.h-8.flex.items-center.justify-center.cursor-pointer
|
||||
.w-8.h-full.flex.items-center.justify-center.cursor-pointer
|
||||
.h-5
|
||||
icon(
|
||||
type="tune"
|
||||
|
||||
Reference in New Issue
Block a user