import { FunctionalComponent } from 'preact';
import { LinkButton, Text } from '@/preferences/components';
import { Button } from '@/components/Button';
import { WebApplication } from '@/ui_models/application';
import { useState } from 'preact/hooks';
import { loadPurchaseFlowUrl } from '@/purchaseFlow/PurchaseFlowWrapper';
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 {
if (!(await loadPurchaseFlowUrl(application))) {
setPurchaseFlowError(errorMessage);
}
} catch (e) {
setPurchaseFlowError(errorMessage);
} finally {
setIsLoadingPurchaseFlow(false);
}
};
return (
<>